bugfindutils - Bugs: bug #42318, find with xdev traverses other...

 
 

bug #42318: find with xdev traverses other filesystem when mountpiont is subdirectory

Submitted by:  Nishit Patel <nishitpatel>
Submitted on:  Thu May 8 13:34:22 2014  
 
Category: findSeverity: 3 - Normal
Item Group: Wrong resultStatus: None
Privacy: PublicAssigned to: James Youngman <jay>
Originator Name: forestOpen/Closed: Open
Release: 4.4.2Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu Mar 30 18:25:01 2017, comment #11:

I think the interpretation of "continue descending past" is the key issue for the POSIX conformance question.

No matter how the POSIX interpretation comes out, I think I would be quite reluctant to give different behaviour to "-mount" and "-xdev" because I suspect that could be very surprising to users.

James Youngman <jay>
Project AdministratorIn charge of this item.
Wed Mar 29 20:29:42 2017, comment #10:

I wonder if the useful solution would be to define "-mount" to give the Solaris behavior, and "-xdev" to give the current behavior.

Dale Worley <worley>
Wed Mar 29 15:13:55 2017, comment #9:

From POSIX section mentioned
"it shall cause find not to continue descending past directories that have a different device ID (st_dev"
Key is the reference to primary.
Primary will have one st_dev, the mount point will have another one.
The directory on which a file system is mounted has indeed a different device ID.

Example:
testserver ~ # stat /mnt/|grep Device
Device: fd01h/64769d Inode: 8196 Links: 3
testserver ~ # stat /mnt/testmount/|grep Device
Device: fd07h/64775d Inode: 2 Links: 2
testserver ~ #

So, i would read this as "if the directory has a different Device, do not list it".

That of course is different from the current behavior.

BTW, http://austingroupbugs.net/view.php?id=1133 has been opened to clarify POSIX understanding.
There is also a very interesting comment on the behavior that has to be kept regarding -H and -L (symbolic link related) behavior.

"I can see making it a requirement mount names show when
neither -H or -L specified, whether -xdev set or not, and hidden when either option and -xdev is specified, treating the direct name as a symbolic link body, essentially. This may be a breaking change, but covers both observed behaviors. "

Daniele Palumbo <rocco83>
Fri Mar 24 16:16:41 2017, comment #8:

I ran into this link to the Solaris man page for find, and it's clear that it's built on a different code base, because the description of -xdev is different:
http://docs.oracle.com/cd/E19253-01/816-5165/6mbb0m9ft/index.html

-xdev

Same as the -mount primary.

-mount

Always true. Restricts the search to the file system containing the directory specified. Does not list mount points to other file systems.

Gnu find does list mount points but it does not list files within them, which the Posix documentation arguably specifies, the Solaris documentation makes it clear that mount points themselves are not to be listed.

Dale Worley <worley>
Thu Mar 23 17:11:42 2017, comment #7:

RHEL 7

testserver ~ # uname -a
Linux testserver 3.10.0-229.el7.x86_64 #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
testserver ~ # rpm -qf /usr/bin/find
findutils-4.5.11-3.el7.x86_64
testserver ~ # df|grep test
/dev/mapper/myvg-mounttest 999320 2572 927936 1% /mnt/testmount
testserver ~ # find /mnt/ -xdev
/mnt/
/mnt/testmount
testserver ~ #

Daniele Palumbo <rocco83>
Thu Mar 23 17:07:36 2017, comment #6:

Solaris 11.3

root@testserver:~# pkg info entire
Name: entire
Summary: entire incorporation including Support Repository Update (Oracle Solaris 11.3.9.4.0).
[...]
Version: 0.5.11 (Oracle Solaris 11.3.9.4.0)
Build Release: 5.11
Branch: 0.175.3.9.0.4.0
Packaging Date: June 10, 2016 12:51:48 AM
[...]

root@testserver:~# zfs list /mnt/testmount
NAME USED AVAIL REFER MOUNTPOINT
rpool/mounttest 31K 46.2G 31K /mnt/testmount
root@testserver:~# find /mnt -xdev -type d
/mnt
root@testserver:~#

Not listed at all.

Daniele Palumbo <rocco83>
Wed Mar 22 13:57:46 2017, comment #5:

How does the (much simpler)

# find /mnt -xdev -type d

behave?

Dale Worley <worley>
Tue Mar 21 19:20:33 2017, comment #4:

Seems that Solaris 10 is acting in a different way.
The mountpoint is not listed.

So i am wondering which is the correct interpretation for POSIX...

Solaris 10 U11 with the find command which is/was included in the SUNWcsu package (as part of KU patch).

-bash-3.2# more /etc/release
Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Assembled 17 January 2013
-bash-3.2# uname -a
SunOS xxxxxxxx 5.10 Generic_150400-26 sun4v sparc sun4v

-bash-3.2# ls -l /usr/bin/find
-r-xr-xr-x 1 root bin 28124 Oct 3 2008 /usr/bin/find

# mountpoint /mnt/testmount
-bash-3.2# ls -ld /mnt
drwxr-xr-x 3 root sys 3 Mar 21 14:52 /mnt
-bash-3.2# ls -ld /mnt/testmount
drwxr-xr-x 2 root root 2 Mar 21 14:52 /mnt/testmount
-bash-3.2# ls -lR /mnt/testmount
/mnt/testmount:
total 0

# mount ZFS fs mounttest on testmount
-bash-3.2# zfs mount zones_rpool/mounttest
-bash-3.2# zfs list zones_rpool/mounttest
NAME USED AVAIL REFER MOUNTPOINT
zones_rpool/mounttest 31K 88.8G 31K /mnt/testmount

# create dirs
-bash-3.2# mkdir -m 777 /mnt/testmount/ww_dir1
-bash-3.2# mkdir -m 777 /mnt/testmount/ww_dir2
-bash-3.2# mkdir -m 755 /mnt/testmount/dir3

# find /mnt
-bash-3.2# find /mnt -xdev -perm -o+w -a ! -perm -1000
# find /mnt/testmount
-bash-3.2# find /mnt/testmount -xdev -perm -o+w -a ! -perm -1000
/mnt/testmount/ww_dir2
/mnt/testmount/ww_dir1

# chmod mountpoint
-bash-3.2# chmod 777 /mnt/testmount

# repeat finds
-bash-3.2# find /mnt -xdev -perm -o+w -a ! -perm -1000
-bash-3.2# ls -ld /mnt/testmount
drwxrwxrwx 5 root root 5 Mar 21 18:32 /mnt/testmount
-bash-3.2# ls -lR /mnt/testmount
/mnt/testmount:
total 9
drwxr-xr-x 2 root root 2 Mar 21 18:32 dir3
drwxrwxrwx 2 root root 2 Mar 21 18:32 ww_dir1
drwxrwxrwx 2 root root 2 Mar 21 18:32 ww_dir2
/mnt/testmount/dir3:
total 0
/mnt/testmount/ww_dir1:
total 0
/mnt/testmount/ww_dir2:
total 0
-bash-3.2# find /mnt/testmount -xdev -perm -o+w -a ! -perm -1000
/mnt/testmount
/mnt/testmount/ww_dir2
/mnt/testmount/ww_dir1

# umount testmount
-bash-3.2# zfs umount /mnt/testmount
-bash-3.2# find /mnt/testmount -xdev -perm -o+w -a ! -perm -1000
-bash-3.2# find /mnt -xdev -perm -o+w -a ! -perm -1000

Daniele Palumbo <rocco83>
Mon Mar 20 15:03:39 2017, comment #3:

My reading of the phrase "descend past" is that find will examine the directory itself but will not proceed "past" it. This depends on the detailed connotations of the word "past". And similarly I think the documentation in comment #1 has the same meaning.

But it's not a good thing that a delicate consideration of the wording of the manual page is needed to understand it correctly. Not all the readers are native English speakers.

I think it would be better to say "find will list a directory which is a mount point but it will not recursively list any of its contents".

Dale Worley <worley>
Fri Mar 17 20:04:44 2017, comment #2:

POSIX states:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html

-xdev
The primary shall always evaluate as true; it shall cause find not
to continue descending past directories that have a different device
ID (st_dev, see the stat() function defined in the System Interfaces
volume of POSIX.1-2008). If any -xdev primary is specified, it shall
apply to the entire expression even if the -xdev primary would not
normally be evaluated.

I'm not 100% sure, but I read "not to continue descending past directories"
to mean that find should print the mount point entry.

Have a nice day,
Berny

Bernhard Voelker <berny>
Project Member
Fri Mar 17 14:43:57 2017, comment #1:

Should be renamed to:
"find -mount (or -xdev) is listing permission for root directory of other mounted filesystem."

https://www.gnu.org/software/findutils/manual/html_mono/find.html#Filesystems
---
[...]
Don't descend directories on other filesystems. These options are synonyms.
[...]
---

root directory in a filesystem is a directory (everything is a file), even if mounted not in system root.
So root directory reside always in the mounted filesystem, as permission.

To put it in other terms:
Taking in consideration ext4, when a filesystem is mounted, the permission on the root directory for the mounted filesystem are taken from the root directory of the mounted filesystem itself.
The same apply to all *nix filesystem that handle permissions, including NFS.

Suppose to have:
/mnt/testmount, a directory with no content and permission 755
mount then /dev/mapper/myvg-mounttest in this directory.
The root directory of this filesystem already has permission set to 777.
ls -l will show 777 now for the same directory.
This is fine.

If find with -mount is used to spot all 777 permissions, this will be listed.

Result should be instead:
1) no entries for that mountpoint at all (because of -mount this is effectively not in our find)
2) the directory entry with permission of the original filesystem directory (likely not possible)

Maybe worth the case to check also other OS implementation, like AIX and Solaris.

Reproducer:
Prereq:
One disk (local or remote) mounted:
/dev/mapper/myvg-mounttest on /mnt/testmount type ext4 (rw,relatime,data=ordered)
/dev/mapper/myvg-mounttest 976M 2.6M 907M 1% /mnt/testmount

Content of the mounted filesystem:
testserver ~ # ls -laR /mnt/
/mnt/:
total 12
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 .
dr-xr-xr-x. 20 root root 4096 Feb 17 12:30 ..
drwxrwxrwx 5 root root 4096 Mar 15 14:16 testmount

/mnt/testmount:
total 32
drwxrwxrwx 5 root root 4096 Mar 15 14:16 .
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 ..
-rwxrwxrwx 1 root root 0 Mar 15 14:15 beta
drwxr-xr-x 2 root root 4096 Mar 15 14:16 charlie
drwx------ 2 root root 16384 Mar 15 14:14 lost+found
drwxrwxrwx 2 root root 4096 Mar 15 14:16 sigma

/mnt/testmount/charlie:
total 8
drwxr-xr-x 2 root root 4096 Mar 15 14:16 .
drwxrwxrwx 5 root root 4096 Mar 15 14:16 ..

/mnt/testmount/lost+found:
total 20
drwx------ 2 root root 16384 Mar 15 14:14 .
drwxrwxrwx 5 root root 4096 Mar 15 14:16 ..

/mnt/testmount/sigma:
total 8
drwxrwxrwx 2 root root 4096 Mar 15 14:16 .
drwxrwxrwx 5 root root 4096 Mar 15 14:16 ..
-rwxrwxrwx 1 root root 0 Mar 15 14:15 alpha
-rw-r--r-- 1 root root 0 Mar 15 14:16 charlie
testserver ~ #

Steps:
testserver ~ # cd /mnt/
testserver mnt # umount testmount/
testserver mnt # ls -la
total 12
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 .
dr-xr-xr-x. 20 root root 4096 Feb 17 12:30 ..
drwxr-xr-x 2 root root 4096 Mar 15 14:08 testmount
testserver mnt # find /mnt -mount -perm -o+w -a ! -perm -1000
testserver mnt # mount /dev/myvg/mounttest testmount/
testserver mnt # ls -la
total 12
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 .
dr-xr-xr-x. 20 root root 4096 Feb 17 12:30 ..
drwxrwxr-x 5 root root 4096 Mar 15 14:16 testmount
testserver mnt # find /mnt -mount -perm -o+w -a ! -perm -1000
testserver mnt # ls -la testmount/
total 32
drwxrwxr-x 5 root root 4096 Mar 15 14:16 .
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 ..
-rwxrwxrwx 1 root root 0 Mar 15 14:15 beta
drwxr-xr-x 2 root root 4096 Mar 15 14:16 charlie
drwx------ 2 root root 16384 Mar 15 14:14 lost+found
drwxrwxrwx 2 root root 4096 Mar 15 14:16 sigma
testserver mnt # chmod 777 testmount/
testserver mnt # ls -la
total 12
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 .
dr-xr-xr-x. 20 root root 4096 Feb 17 12:30 ..
drwxrwxrwx 5 root root 4096 Mar 15 14:16 testmount
testserver mnt # find /mnt -mount -perm -o+w -a ! -perm -1000
/mnt/testmount
testserver mnt # umount testmount/
testserver mnt # ls -la
total 12
drwxr-xr-x. 3 root root 4096 Mar 15 14:08 .
dr-xr-xr-x. 20 root root 4096 Feb 17 12:30 ..
drwxr-xr-x 2 root root 4096 Mar 15 14:08 testmount
testserver mnt # find /mnt -mount -perm -o+w -a ! -perm -1000
testserver mnt #

Daniele Palumbo <rocco83>
Thu May 8 13:34:22 2014, original submission:

Hello,

I want to see if there is option with find to ignore traversing into other filesystem.

When I issue find to perform some tests on local filesystem, it returns results with files that are on NFS mount. I believe find is only performing -xdev test on / and not on any subdirectories.

Is that expected behavior?

# find / -mount -nouser -printf "%F %M %u %g %p \n"
nfs drwxrwsr-x 9958 /abc/def/ghi
nfs drwxrwsr-x 9958 /abc/def/jkl

# df -h /abc/def/ghi
Filesystem Size Used Avail Use% Mounted on
x.x.x.x:/abc-nfs/def/ghi
x.xP x.xP xxxT xx% /abc/def/ghi

# df -h /abc/def
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 xxG xxG xxG xx% /

Nishit Patel <nishitpatel>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jay (Posted a comment)
  • -unavailable- added by worley (Posted a comment)
  • -unavailable- added by berny (Posted a comment)
  • -unavailable- added by rocco83 (Posted a comment)
  • -unavailable- added by nishitpatel (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Mar 30 18:25:57 2017jayCategoryNone=>find
      Item GroupNone=>Wrong result
      Assigned toNone=>jay

    Back to the top


    Powered by Savane 3.1-cleanup1