Commit Graph

518 Commits

Author SHA1 Message Date
christos b985414b8f Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
2018-01-09 03:31:12 +00:00
christos cd1c6201df We computed the length of the string already, so use it... 2017-11-07 15:57:38 +00:00
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
hannken 4f4cfe27b2 Enter fstrans from _vfs_busy() and leave from vfs_unbusy().
Adapt sched_sync() and do_sys_sync().
2017-05-07 08:26:58 +00:00
hannken 01d31ceb6d Return ENOENT if trying to suspend an unmounted file system. 2017-05-07 08:25:54 +00:00
riastradh 6fa7b15833 Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.
No change to vp -- the plan is to replace the node by the
componentname in the vop parameters, and let all directory vops do
lookups internally.

Proposed on tech-kern with no objections:
https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html
2017-04-26 03:02:47 +00:00
hannken 20bb034f5b Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
2017-04-17 08:32:00 +00:00
hannken ebb8f73b4b Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount.  Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
2017-04-17 08:31:01 +00:00
hannken a315c73868 Switch do_sys_sync() and do_sys_getvfsstat() to mountlist iterator. 2017-04-12 10:28:39 +00:00
hannken 4ac834d923 Fix a logic error introduced with Rev. 1.507: defer setting MNT_RDONLY
only if going from read-write to read-only.

Should fix PR kern/52045 (panic: ffs_sync: rofs mod, fs=/ after fsck)
2017-03-07 11:54:16 +00:00
hannken b038eea5e1 Suspend the mounted file system while updating. 2017-03-01 10:45:24 +00:00
hannken 90ead62d2f Change the protocol to update a mounted file system from read-write
to read-only and vice versa:

- Add an internal flag IMNT_WANTRDONLY.
- Set either IMNT_WANTRDWR or IMNT_WANTRDONLY if going from or to read-only.
- After successfull call to VFS_MOUNT() set or clear MNT_RDONLY.

Adapt tmpfs and rumpfs to the new protocol.  Other file systems will be
updated when they get the IMNT_CAN_RWTORO property.

Welcome to 7.99.64
2017-03-01 10:44:47 +00:00
hannken 90afdff6e3 Take fstrans_start before syncing a file system. 2017-02-17 08:26:07 +00:00
dholland 585fe4a842 typo in comment 2016-07-31 20:34:04 +00:00
dholland daa427b465 Fix kern/50841: races in sys_lseek. 2015-11-28 15:26:29 +00:00
martin 6ae6da2395 Fix inverted KASSERT 2015-10-28 14:05:04 +00:00
martin f39ddc9a21 Apease bogus gcc warning. 2015-10-25 09:27:14 +00:00
maxv ea498aca7e Change do_sys_mount() so that it only takes as argument the type of the
drive instead of its associated vfsops. Makes it more friendly, and allows
compat binaries to autoload VFS modules if needed.

sent on tech-kern@, ok christos@
2015-10-23 19:40:10 +00:00
maxv 6647020bbc Unused inits (harmless).
Found by Brainy.
2015-07-24 13:02:52 +00:00
dholland 28bb489865 Use NOFOLLOW intead of <empty>. Purely cosmetic as NOFOLLOW is 0, but
it's supposed to be there for clarity.
2015-06-12 19:06:32 +00:00
hannken e10a32f7f7 Remove miscfs/syncfs and
- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
  - vfs_syncer_add_to_worklist(struct mount *mp) to add
  - vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@
2015-05-06 15:57:07 +00:00
riastradh e6d0ae95b0 Cull unused INRENAME and INRELOOKUP from callers. 2015-04-21 03:19:03 +00:00
riastradh 46e71c7d57 Make VOP_LINK return directory still locked and referenced.
Ride 7.99.10 bump.
2015-04-20 22:59:19 +00:00
riastradh 2b82c270f5 But rename(..., "x/..") is still supposed to yield EINVAL. Go figure. 2015-04-09 05:08:15 +00:00
riastradh d0319a8396 Tests claim rename(..., "x/.") yields EISDIR, so do that. Fixes zfs. 2015-04-09 05:03:58 +00:00
martin 906a6a13d7 A syscall like posix_fallocate() that is not supposed to set errno in
userland needs to always return 0 and store the error code *retval.
2015-02-15 10:48:21 +00:00
manu e6a2cb8983 Do not follow symlinks in sys_unmount()
There are situations where the underlying filesystem is unreachable
(e.g: NFS) causing symlink resolution to hang. Such a situation
should be avoided by using umount -f -R (force and raw), but while -R
causes the symlink resolution to be skipped in umount(8), the kernel was
still doing it in sys_unmount(). This changes fixes that.

When the -R flag is not given, umount(8) does symlinks resolution through
realpath(3) before calling unmount(2), hence not doing it in the kernel
would not change behavior.
2014-11-26 10:50:36 +00:00
matt 45b1ec740d Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
2014-09-05 09:20:59 +00:00
maxv 382770f2eb 'result' -> 'error' 2014-07-25 16:28:12 +00:00
dholland 53d9b9366b typo in comment 2014-07-25 08:30:10 +00:00
dholland 738b7a54cf Add fdiscard and posix_fallocate syscalls. 2014-07-25 08:25:47 +00:00
maxv 374ecba24a This is weird; 'abort' already does all this, so simply use goto abort. 2014-06-30 17:51:31 +00:00
dholland 01e782f371 Revert the following changes:
src/sys/sys/quotactl.h 1.37
   src/sys/compat/netbsd32/netbsd32.h 1.101
   src/sys/compat/netbsd32/netbsd32_netbsd.c 1.188, 1.189
   src/sys/kern/vfs_quotactl.c 1.39
   src/sys/kern/vfs_syscalls.c 1.483
   src/sys/ufs/lfs/ulfs_quota.c 1.11
   src/sys/ufs/ufs/ufs_quota.c 1.116
   src/lib/libquota/quota_kernel.c 1.5

and do them correctly.

If you're going to change the name of something, you need to change
the name of *all* the things with the same name, not just a handful,
and you should change it to something similar so it still matches the
rest of the system rather than just picking an arbitrarily different
name.

Hi, Joerg.

To wit, rename the quotactl "delete" operation to "del", because
"delete" is a reserved word in C++ and for some reason Joerg wants to
run internal interfaces used only by C code through his C++ compiler.
Do not rename it to "remove" instead, because this doesn't match
libquota or the rest of the usage throughout the system; and rename
all the related identifiers, not just the ones that blew the mind of
Joerg's C++ compiler.

Because this is not a user-facing API (the only userland consumer
sys/quotactl.h is libquota) it is sort of ok to make arbitrary
source-incompatible changes; however, by the same token it's completely
unnecessary. If it *were* a user-facing API that someone might have a
semi-rational reason to want to run a C++ compiler on, it would be
incorrect to change it at this point.
2014-06-28 22:27:50 +00:00
christos 9ab46539af Don't initialize the fh pointer to NULL when the allocation functions fail
and allow NULL in the free functions. It just leads to writing sloppy code
for no good reason.
2014-06-26 01:46:03 +00:00
njoly 6b27a22c99 Follow OpenGroup online documents for truncate[1] and ftruncate[2].
Fail with EINVAL for length argument negative values.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
2014-06-14 11:37:35 +00:00
joerg ef53e37514 Don't t use a C++ keyword as field name. 2014-06-12 21:39:45 +00:00
maxv 6547a55a59 This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.

If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
2014-04-20 21:26:51 +00:00
maxv 4a1b3781e1 Memory leak (only triggerable from root).
ok christos@
2014-04-18 05:22:13 +00:00
maxv cf89d4e5af Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
2014-04-16 19:25:28 +00:00
maxv 23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
maxv 18ff15fb2d Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.

ok christos@
2014-04-04 06:47:02 +00:00
maxv 2632b9d940 Fix a potential - but very unlikely - NULL pointer dereference.
(it does not introduce a new error code for open(), since
 pathbuf_copyin() is already there and can return ENOMEM)

Found by my code scanner.
2014-03-22 08:15:25 +00:00
njoly 9f120b8d09 Remove argument name from prototype. 2014-02-15 22:32:16 +00:00
christos cee146c035 Add compat_10, open NULL == open "." 2014-01-25 17:24:45 +00:00
christos 1525b564a7 expose do_open 2014-01-25 02:28:31 +00:00
hannken 04c776e5c8 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
2014-01-23 10:13:55 +00:00
hannken 1139274440 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
2014-01-17 10:55:01 +00:00
christos 9d605174d9 Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
2013-11-27 17:24:43 +00:00
christos 0b725b63c7 change the mountlist CIRCLEQ into a TAILQ 2013-11-23 13:35:36 +00:00
chs dc00ea6b1e expose various do_*at() functions for compat_linux. 2013-11-18 01:31:42 +00:00