History log of /openbsd-current/sys/ufs/ufs/ufs_lookup.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.61 03-Feb-2024 beck

Remove Softdep.

Softdep has been a no-op for some time now, this removes it to get
it out of the way.

Flensing mostly done in Talinn, with some help from krw@

ok deraadt@


# 1.60 09-Jan-2024 guenther

Delete support for FFS filesystems before the in-inode symlink
optimization. As observed by ali_farzanrad(at)riseup.net, support
for these was broken in the 5.5 release in early 2014 by the time_t
changes. No one noticed before now, so clearly this isn't something
we need to continue to support; rejecting in ffs_validate() is an
improvement.

Also: simplify DIRSIZ(), drop OLDDIRFMT and NEWDIRFMT, tests of
fs_maxsymlinklen against zero, #ifdef tests of FS_44INODEFMT, and
remove support for newfs -O0, last used in 2016.

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.59 11-Jan-2022 jsg

spelling
ok jmc@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.58 09-Oct-2020 mpi

Do not dereference `vp' after vput(9)ing it.

From dholland@NetBSD

ok anton@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.57 09-May-2019 deraadt

Nope, the right byte layout is happening, but we still need to figure out
a reported baddir panic. Discussed with guenther tedu kettenis millert..


# 1.56 09-May-2019 deraadt

For filenames which are a multiple of 4 bytes long, the zero pad is
incorrectly placed underneath the last 4 bytes (and then overwritten)
rather than afterwards.
We got confused and followed FreeBSD's lead, which curiously increased
the leakage of kernel stack from 3 bytes to 4...
ok millert kettenis


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.60 09-Jan-2024 guenther

Delete support for FFS filesystems before the in-inode symlink
optimization. As observed by ali_farzanrad(at)riseup.net, support
for these was broken in the 5.5 release in early 2014 by the time_t
changes. No one noticed before now, so clearly this isn't something
we need to continue to support; rejecting in ffs_validate() is an
improvement.

Also: simplify DIRSIZ(), drop OLDDIRFMT and NEWDIRFMT, tests of
fs_maxsymlinklen against zero, #ifdef tests of FS_44INODEFMT, and
remove support for newfs -O0, last used in 2016.

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.59 11-Jan-2022 jsg

spelling
ok jmc@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.58 09-Oct-2020 mpi

Do not dereference `vp' after vput(9)ing it.

From dholland@NetBSD

ok anton@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.57 09-May-2019 deraadt

Nope, the right byte layout is happening, but we still need to figure out
a reported baddir panic. Discussed with guenther tedu kettenis millert..


# 1.56 09-May-2019 deraadt

For filenames which are a multiple of 4 bytes long, the zero pad is
incorrectly placed underneath the last 4 bytes (and then overwritten)
rather than afterwards.
We got confused and followed FreeBSD's lead, which curiously increased
the leakage of kernel stack from 3 bytes to 4...
ok millert kettenis


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.59 11-Jan-2022 jsg

spelling
ok jmc@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.58 09-Oct-2020 mpi

Do not dereference `vp' after vput(9)ing it.

From dholland@NetBSD

ok anton@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.57 09-May-2019 deraadt

Nope, the right byte layout is happening, but we still need to figure out
a reported baddir panic. Discussed with guenther tedu kettenis millert..


# 1.56 09-May-2019 deraadt

For filenames which are a multiple of 4 bytes long, the zero pad is
incorrectly placed underneath the last 4 bytes (and then overwritten)
rather than afterwards.
We got confused and followed FreeBSD's lead, which curiously increased
the leakage of kernel stack from 3 bytes to 4...
ok millert kettenis


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.58 09-Oct-2020 mpi

Do not dereference `vp' after vput(9)ing it.

From dholland@NetBSD

ok anton@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.57 09-May-2019 deraadt

Nope, the right byte layout is happening, but we still need to figure out
a reported baddir panic. Discussed with guenther tedu kettenis millert..


# 1.56 09-May-2019 deraadt

For filenames which are a multiple of 4 bytes long, the zero pad is
incorrectly placed underneath the last 4 bytes (and then overwritten)
rather than afterwards.
We got confused and followed FreeBSD's lead, which curiously increased
the leakage of kernel stack from 3 bytes to 4...
ok millert kettenis


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.57 09-May-2019 deraadt

Nope, the right byte layout is happening, but we still need to figure out
a reported baddir panic. Discussed with guenther tedu kettenis millert..


# 1.56 09-May-2019 deraadt

For filenames which are a multiple of 4 bytes long, the zero pad is
incorrectly placed underneath the last 4 bytes (and then overwritten)
rather than afterwards.
We got confused and followed FreeBSD's lead, which curiously increased
the leakage of kernel stack from 3 bytes to 4...
ok millert kettenis


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.55 04-May-2019 deraadt

3 bytes of kernel stack address space were leaked into on-disk directories.
With some gritty work up to 254 bytes can be discovered. More details at
https://svnweb.freebsd.org/changeset/base/347066
The impact on OpenBSD is very limited:
1 - such stack bytes can be found in raw-device reads, from group operator.
If you can read the raw disks you can undertake other more powerful actions.
2 - read(2) upon directory fd was disabled July 1997 because I didn't like
how grep * would display garbage and mess up the tty, and applying vis(3)
for just directory reads seemed silly. read(2) was changed to return
0 (EOF). Sep 2016 this was further changed to EISDIR, so you still cannot
see the bad bytes.
3 - In 2013 when guenther adapted the getdents(2) directory-reading system
call to 64-bit ino_t, the userland data format changed to 8-byte-alignment,
making it incompatible with the 4-byte-alignment UFS on-disk format. As
a result of code refactoring the bad bytes were not copied to userland.
Bad bytes will remain in old directories on old filesystems, but nothing makes
those bytes user visible. There will be no errata or syspatch issued. I
urge other systems which do expose the information to userland to issue
errata quickly, since this is a 254 byte infoleak of the stack which is great
for ROP-chain building to attack some other bug. Especially if the kernel
has no layout/link-order randomization ...
ok kettenis jca millert otto ...


Revision tags: OPENBSD_6_5_BASE
# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.54 23-Dec-2018 natano

Rectify some issues with the noperm mount flag; the root vnode was not
protected properly and files without any x bit set were accidentaly considered
executable when checked with access(2).

Issues found and reported by deraadt, halex, reyk, tb
ok deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.53 06-Sep-2018 jsg

fix whitespace


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.52 02-May-2018 visa

Remove proc from the parameters of vn_lock(). The parameter is
unnecessary because curproc always does the locking.

OK mpi@


# 1.51 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.50 10-Sep-2016 natano

Add a noperm mount flag for FFS to be used for building release sets
without root privileges. This is only the kernel/mount flag; additional
work in the build Makefile's will be necessary such that the files in
$DESTDIR are created with correct permissions.

tedu couldn't find anything wrong with it in a quick review
idea & ok deraadt


Revision tags: OPENBSD_6_0_BASE
# 1.49 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


# 1.48 27-Feb-2016 natano

Move mnt_maxsymlink from struct mount to struct ufsmount.

The concept of differentiating between "short" and "long" symlinks is
specific to ufs/, so it shouldn't creep into the generic fs layer.
Inspired by a similar commit to NetBSD.

While there replace all references to mnt_maxsymlinklen in ufs/ext2fs
with EXT2_MAXSYMLINKLEN, which is the constant max short symlink len for
ext2fs. This allows to get rid of some (mnt_maxsymlinklen == 0) checks
there, which is always false for ext2fs.

input and ok stefan@
ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.47 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.46 07-Dec-2014 tedu

don't truncate the dirhash if ufs truncate fails.
adapted from a freebsd commit by david hill


Revision tags: OPENBSD_5_6_BASE
# 1.45 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


Revision tags: OPENBSD_5_5_BASE
# 1.44 12-Dec-2013 tedu

bcmp -> memcmp


# 1.43 12-Dec-2013 tedu

replace old bcopy/bzero with standard functions. ok kettenis


Revision tags: OPENBSD_5_4_BASE
# 1.42 30-May-2013 guenther

UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.

otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.41 18-Sep-2011 bluhm

Fix more printf format string bugs in sys/ufs.
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.40 23-Sep-2010 oga

The only sensible argument for VOP_* calls that take a struct proc pointer is
curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this
pointer, which was fine until the called vnode function tried to do
something with it. Typically, this code was then copy/pasted to various
parts of the tree.

Accept the facts of life and switch all of these over to passing curproc
for now until the argument can be removed.

Discovered by stsp trying to create a softraid on top of a vnd, which
crashed with a NULL deref in vndioctl.

softraid bits tested by mikeb and jsing. raidframe bits tested by pea,
matthieu and naddy. The rest tested by at least thib, jsing and myself.

ok thib@, jsing@.


Revision tags: OPENBSD_4_8_BASE
# 1.39 20-Apr-2010 tedu

remove proc.h include from uvm_map.h. This has far reaching effects, as
sysctl.h was reliant on this particular include, and many drivers included
sysctl.h unnecessarily. remove sysctl.h or add proc.h as needed.
ok deraadt


Revision tags: OPENBSD_4_7_BASE
# 1.38 09-Jul-2009 thib

Remove the VREF() macro and replaces all instances with a call to verf(),
which is exactly what the macro does.

Macro's that are nothing more then:
#define FUNCTION(arg) function(arg)
are almost always pointless and should go away.

OK blambert@
Agreed by many.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


Revision tags: OPENBSD_4_1_BASE
# 1.36 17-Nov-2006 pedro

There is no need to set IN_CHANGE or IN_UPDATE when no on-disk data is
being touched, fixes PR 3634, okay mickey@, thib@ and beck@.


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.35 28-Dec-2005 pedro

Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.


# 1.34 10-Nov-2005 pedro

Use ANSI function declarations and deregister, no binary change.
Diff from Rui Reis <rui@rui.cx>, thanks.


Revision tags: OPENBSD_3_8_BASE
# 1.33 20-Jul-2005 pedro

Reintroduce the changes made by tedu in revision 1.50 of ffs_softdep.c,
this time with a small tweak: when flushing the dependencies, don't
update the inode twice, but update once, and then, if needed, fsync it.
Doing so fixes the inode hangs some people were seeing.

Various testing for a while, especially krw@ and millert@, okay deraadt@


# 1.32 03-Jul-2005 drahn

Extended Attributes was a piece to get to ACLs, however ACLs have not
been worked on, so EA is pointless. Also the code is not enabled
in GENERIC so it is not being tested or maintained.


# 1.31 19-Jun-2005 deraadt

wrap a goto label in the proper #ifdef


# 1.30 18-Jun-2005 millert

Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@


# 1.29 10-Jun-2005 pedro

Tweak softdep_change_linkcnt() so we can specify whether we're willing
to be co-opted by softdep or not, and use this new interface to inform
softdep in ufs_inactive() that the inode mode has changed.

We don't want to be co-opted there as that might lead to undesired
circular dependencies such as a vput() depending on another vput() to
complete, or a process that is trying to free up a vnode being blocked
trying to acquire a new vnode.

Okay tedu@ deraadt@, thanks to all those who tested.


Revision tags: OPENBSD_3_7_BASE
# 1.28 07-Dec-2004 tedu

prev softdep merge could lead to inode wait deadlock for unknown reasons.
revert.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 07-May-2004 tedu

fatty softdep merge with freebsd. fixes a variety of possible issues.
relevant changes to ffs_softdep.c were 1.95, 1.96, 1.97, 1.98, 1.103, and
1.107 in freebsd. testing marc and otto. ok deraadt


# 1.26 16-Apr-2004 tedu

fix niklas's panic and pr3672 with freebsd rev 1.54 (don't trust DIRSIZ)
extra testing otto@ sturm@ tdeval@


Revision tags: OPENBSD_3_5_BASE
# 1.25 09-Jan-2004 tedu

branches: 1.25.2;
back out vnode parents. weird breakge found in ports tree


# 1.24 06-Jan-2004 tedu

keep track of a vnode's parent dir. ufs only, and unused atm, but
the fun stuff is coming. testing by brad.


# 1.23 28-Dec-2003 tedu

add ian dowse's dirhash code from freebsd.
by building a hash table for large directories, lookups and deletions
become about constant time. this is an excellent improvement for dirs with
10k or more files.
some more cleanup to come, but the code works.
enabled with option UFS_DIRHASH
testing brad millert otto


Revision tags: OPENBSD_3_4_BASE
# 1.22 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.21 12-Feb-2003 jason

Remove commons; inspired by netbsd.


# 1.20 31-Jan-2003 art

File system locking fixups, mostly from NetBSD:
- cache_lookup
move common code from various fs's here
always return with vnode and parent locked
adjust return codes
- PDIRUNLOCK - new flag set if lookup couldn't lock parent vnode
- kernfs and procfs
lock vnode in get_root
don't unlock (again) in kernfs_freevp
fix memory leak in procfs

From tedu@stanford.edu
deraadt@ and various other ok


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 22-Feb-2002 drahn

Extended Attribute support from FreeBSD/TrustedBSD ok art@, deraadt@


Revision tags: UBC_BASE
# 1.18 06-Nov-2001 miod

branches: 1.18.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.17 27-Jun-2001 art

Remove old vm.


# 1.16 23-Jun-2001 csapuntz

Privatize several vnode operations that are not used by the generic code.


Revision tags: OPENBSD_2_9_BASE
# 1.15 27-Feb-2001 art

Cosmetic fixes.
From FreeBSD, through NetBSD.


# 1.14 27-Feb-2001 art

Move a brelse to after the last access to bp->b_data.
I found this in 1998. Why didn't I commit it then?


# 1.13 21-Feb-2001 csapuntz

Latest soft updates from FreeBSD/Kirk McKusick

Snapshot-related code has been commented out.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.12 26-Feb-1999 art

branches: 1.12.6;
compat with uvm vnode pager


Revision tags: OPENBSD_2_4_BASE
# 1.11 28-Jul-1998 millert

Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more


Revision tags: OPENBSD_2_3_BASE
# 1.10 11-Dec-1997 csapuntz

Fix rename in a better way


# 1.9 11-Dec-1997 csapuntz

Earlier patch broke rename. Disalbed it temporarily as I search for a solution.


# 1.8 02-Dec-1997 csapuntz

Unlock child temporarily while truncating directory. This prevents
a double locking bug in the soft updates code.


# 1.7 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.6 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.5 06-Oct-1997 csapuntz

VFS Lite2 Changes


# 1.4 30-May-1997 downsj

Integrate new ext2fs, reverting ufs support for the old one.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.3 31-Aug-1996 pefo

Cleanup exec


# 1.2 27-Feb-1996 niklas

From NetBSD: update to 960217 sources


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision