Re: svn commit: r330436 - head/bin/chflags
On Mon, 5 Mar 2018, Bruce Evans wrote: On Sun, 4 Mar 2018, Ian Lepore wrote: On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: Log: \xa0 chflags: Add -x option to not traverse mount points. Yay! \xa0One day later than I needed it, but still, yay! I recently noticed that find(1) needs an option to not look at mount points at all, and further options to classify mount points so that you can prune them. After reading the above and investigating further, I noticed that -x is broken in most FreeBSD utilities, since POSIX requires not looking at mount points at all for the few utilities that support -x. E.g., for du in 2001 draft 7 POSIX: ... This seems to be easy to fix by by skipping in callers of fts_read(). Fix for an old version of du: XX Index: du.c XX === XX RCS file: /home/ncvs/src/usr.bin/du/du.c,v XX retrieving revision 1.34 XX diff -u -2 -r1.34 du.c XX --- du.c 2 Jun 2004 07:09:34 - 1.34 XX +++ du.c 8 Mar 2018 00:57:12 - XX @@ -86,9 +86,11 @@ XX int listall; XX int depth; XX -int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; XX +int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag; XX +int xflag, ch, notused, rval; XX char**save; XX static char dot[] = "."; XX XX Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; XX +xflag = 0; XX XX save = argv; XX @@ -148,4 +150,5 @@ XX break; XX case 'x': XX +xflag = 1; XX ftsoptions |= FTS_XDEV; XX break; XX @@ -219,4 +222,7 @@ XX break; XX case FTS_DP: XX +if (xflag && p->fts_statp->st_dev != XX +p->fts_parent->fts_statp->st_dev) XX +break; XX if (ignorep(p)) XX break; This patch won't apply cleanly in -current because -current has large changes in all areas touched by the patch (mainly to undo formatting away from KNF). Bruce ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r330436 - head/bin/chflags
> On 3/5/2018 8:37 AM, Bryan Drewery wrote: > > On 3/4/2018 8:30 PM, Bruce Evans wrote: > >> On Sun, 4 Mar 2018, Ian Lepore wrote: > >> > >>> On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: > > Log: > \xa0 chflags: Add -x option to not traverse mount points. > >>> > >>> Yay! \xa0One day later than I needed it, but still, yay! > >> > >> I recently noticed that find(1) needs an option to not look at mount > >> points at all, and further options to classify mount points so that > >> you can prune them. > >> > >> After reading the above and investigating further, I noticed that -x > >> is broken in most FreeBSD utilities, since POSIX requires not looking > >> at mount points at all for the few utilities that support -x.? E.g., > >> for du in 2001 draft 7 POSIX: > >> > >> 12578??? -x??? When evaluating file sizes, evaluate only > >> those files that have the same device as > >> 12579? the file specified by the file operand. > >> 12580??? Specifying more than one of the mutually-exclusive > >> options -H and -L shall not be considered > > > > Yes I'm quite annoyed that my workaround for chflags not having -x, > > using `find -x ... -exec chflags`, is still trying to modify mountpoints > > but not descending into them. > > > > Note of course my chflags change suffers the same problem of course > since it's just using FTS (these are null-mounted read-only or > devfs/procfs paths): > > > # /scratch/obj/root/git/freebsd/amd64.amd64/bin/chflags/chflags.full -Rx > > schg /poudriere/data/.m/exp-11amd64-commit-test/ref > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/distfiles: > > Operation not supported > > chflags.full: > > /poudriere/data/.m/exp-11amd64-commit-test/ref/compat/linux/proc: Operation > > not supported > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/proc: > > Operation not supported > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/dev: Invalid > > argument > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/rescue: > > Read-only file system > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/tests: > > Read-only file system > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/share: > > Read-only file system > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/ports: > > Read-only file system > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/src: > > Read-only file system > > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/packages: > > Read-only file system > > Personally I find this behavior surprising and wrong and think all of > the tools -x[dev] behavior should not interact with these paths either > by default or with an option. Isnt part of the problem the directory under the mount point is technically a part of the parent file system, such that FTS is getting that, but then stating aginst the root of mounted directory? Would it be wrong to make it return the data for the hidden, and probably empty directory that is mounted over the top of, as technically that is part of the traversed file system. I also think this may be time for a change, especially in the zfs world of lots of datasets! > > >> > >> Mount points are on a different device, but FreeBSD du -x is broken by > >> using FTS_XDEV and not filtering out the mount points. Linux du -x > >> (an old version in /compat/linyx/usr/bin) works correctly. > -- > Regards, > Bryan Drewery -- Rod Grimes rgri...@freebsd.org ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r330436 - head/bin/chflags
On 3/5/2018 8:37 AM, Bryan Drewery wrote: > On 3/4/2018 8:30 PM, Bruce Evans wrote: >> On Sun, 4 Mar 2018, Ian Lepore wrote: >> >>> On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: Log: \xa0 chflags: Add -x option to not traverse mount points. >>> >>> Yay! \xa0One day later than I needed it, but still, yay! >> >> I recently noticed that find(1) needs an option to not look at mount >> points at all, and further options to classify mount points so that >> you can prune them. >> >> After reading the above and investigating further, I noticed that -x >> is broken in most FreeBSD utilities, since POSIX requires not looking >> at mount points at all for the few utilities that support -x. E.g., >> for du in 2001 draft 7 POSIX: >> >> 12578 -x When evaluating file sizes, evaluate only >> those files that have the same device as >> 12579 the file specified by the file operand. >> 12580 Specifying more than one of the mutually-exclusive >> options -H and -L shall not be considered > > Yes I'm quite annoyed that my workaround for chflags not having -x, > using `find -x ... -exec chflags`, is still trying to modify mountpoints > but not descending into them. > Note of course my chflags change suffers the same problem of course since it's just using FTS (these are null-mounted read-only or devfs/procfs paths): > # /scratch/obj/root/git/freebsd/amd64.amd64/bin/chflags/chflags.full -Rx schg > /poudriere/data/.m/exp-11amd64-commit-test/ref > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/distfiles: > Operation not supported > chflags.full: > /poudriere/data/.m/exp-11amd64-commit-test/ref/compat/linux/proc: Operation > not supported > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/proc: Operation > not supported > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/dev: Invalid > argument > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/rescue: > Read-only file system > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/tests: > Read-only file system > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/share: > Read-only file system > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/ports: > Read-only file system > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/usr/src: > Read-only file system > chflags.full: /poudriere/data/.m/exp-11amd64-commit-test/ref/packages: > Read-only file system Personally I find this behavior surprising and wrong and think all of the tools -x[dev] behavior should not interact with these paths either by default or with an option. >> >> Mount points are on a different device, but FreeBSD du -x is broken by >> using FTS_XDEV and not filtering out the mount points. Linux du -x >> (an old version in /compat/linyx/usr/bin) works correctly. > > -- Regards, Bryan Drewery signature.asc Description: OpenPGP digital signature
Re: svn commit: r330436 - head/bin/chflags
On 3/4/2018 8:30 PM, Bruce Evans wrote: > On Sun, 4 Mar 2018, Ian Lepore wrote: > >> On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: >>> >>> Log: >>> \xa0 chflags: Add -x option to not traverse mount points. >> >> Yay! \xa0One day later than I needed it, but still, yay! > > I recently noticed that find(1) needs an option to not look at mount > points at all, and further options to classify mount points so that > you can prune them. > > After reading the above and investigating further, I noticed that -x > is broken in most FreeBSD utilities, since POSIX requires not looking > at mount points at all for the few utilities that support -x. E.g., > for du in 2001 draft 7 POSIX: > > 12578 -x When evaluating file sizes, evaluate only > those files that have the same device as > 12579 the file specified by the file operand. > 12580 Specifying more than one of the mutually-exclusive > options -H and -L shall not be considered Yes I'm quite annoyed that my workaround for chflags not having -x, using `find -x ... -exec chflags`, is still trying to modify mountpoints but not descending into them. > > Mount points are on a different device, but FreeBSD du -x is broken by > using FTS_XDEV and not filtering out the mount points. Linux du -x > (an old version in /compat/linyx/usr/bin) works correctly. -- Regards, Bryan Drewery signature.asc Description: OpenPGP digital signature
Re: svn commit: r330436 - head/bin/chflags
On Sun, 4 Mar 2018, Ian Lepore wrote: On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: Log: \xa0 chflags: Add -x option to not traverse mount points. Yay! \xa0One day later than I needed it, but still, yay! I recently noticed that find(1) needs an option to not look at mount points at all, and further options to classify mount points so that you can prune them. After reading the above and investigating further, I noticed that -x is broken in most FreeBSD utilities, since POSIX requires not looking at mount points at all for the few utilities that support -x. E.g., for du in 2001 draft 7 POSIX: 12578-xWhen evaluating file sizes, evaluate only those files that have the same device as 12579 the file specified by the file operand. 12580Specifying more than one of the mutually-exclusive options -H and -L shall not be considered Mount points are on a different device, but FreeBSD du -x is broken by using FTS_XDEV and not filtering out the mount points. Linux du -x (an old version in /compat/linyx/usr/bin) works correctly. (Elsewhere, POSIX uses the terms "mount point" and "file system" without specifying what they mean. E.g., for FTW_MOUNT which corresponds tp FTS_XDEV, it says "The walk does not cross a mount point". It is also unclear what "cross" means here -- the names of mount points are in the same file system although everything (?) else is in another file system. "mount point" should be specified as "a file whose device differs from the device of its directory", and "file system" should be specified as "all files on the system with the same given device". The latter allows the trees for file system to have weird topologies but is as good as anything. It is better than "all files under a mount point with the same device as the mount point". With the latter definition, given stat structs or even pathnames to 2 files, you would potentially have to walk all files starting at the root directory (if there is one) to determine if the 2 files satisfy the topological condtion of being under the same mount point.) FTS_XDEV is documented as doing the wrong thing for du -x by saying that it doesn't "descend" "into directories that have a different device number than the file from which the descent began". Its description of "same device" is too verbose. It would benefit from formally specifying mount points and file systems and "cross" too. Its "descent" is just good enough without a formal specification since the mount point is at level 0 in the new file system and a descent of 0 levels is not a descent in informal use (like for "negative", but unlike for ascent/positive where it is unclear if 0 levels is an degenerate ascent). The old POSIX draft uses "same.*device" just once according to a simple grep. This is the one quoted above for du -x. Old POSIX find doesn't even have -x. It has -xdev. This is strange, since FreeBSD's man page has said since long before 2001 that it is -xdev that is deprecated. It specifies -xdev using "descending", like for FTS_XDEV but with worse verbose wording. find(1) seems to be missing a classification option for mount points in both FreeBSD and POSIX. This could be used to prune mount points, but pruning is much harder than using a flag that works like -x should work. Perhaps something can be done with pruning levels for any utility that supports -x). E.g. -xx could descend to N levels, where the level counter is set to 0 when a mount point is _first_ reached. Then -xx-1 would give the correct du -x behaviour of not doing the degenerate descent to level 0; -xx0 would give the find behaviour of doing the degenerate descent to level 0; -xx1 would descend 1 level; other positive descents are easy to implement; ther negative descents are too hard to implement. Bruce ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r330436 - head/bin/chflags
On Mon, 2018-03-05 at 01:56 +, Bryan Drewery wrote: > Author: bdrewery > Date: Mon Mar 5 01:56:07 2018 > New Revision: 330436 > URL: https://svnweb.freebsd.org/changeset/base/330436 > > Log: > chflags: Add -x option to not traverse mount points. Yay! One day later than I needed it, but still, yay! -- Ian ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"