bugfindutils - Bugs: bug #9043, find fails on automounter paths

 
 

bug #9043: find fails on automounter paths

Submitter:  VenkateswaraRao <parimiv>
Submitted:  Fri 21 May 2004 10:25:33 AM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  None Fixed Release:  4.2.8
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 26 Nov 2004 05:36:51 AM UTC, comment #10: 

I tested out 4.2.8 on Solaris 9 and it indeed fixes the
problem.  Solaris automount points only generate a warning.

$ find make -name foobar
find: Warning: filesystem /net/.../make has recently been mounted.

Now, I am divided on whether a warning should be issued at
all, since the automount mechanism is supposed to be
mostly transparent to users.  Find doesn't issue warnings
when crossing "ordinary" mount points, for example.

I suspect the warnings will get tedious for users on
systems with automounted filesystems, and should default
to OFF.  Detection of directories that have turned into
symlinks is another matter, since it's an indication of
mutation in the underlying data that is likely to be
malicious.

(Martin Buchholz)

Anonymous
Wed 24 Nov 2004 07:32:26 PM UTC, comment #9: 

Thanks, Martin.  I agree with your concern about the warning (though it was a useful diagnostic during development).  I have modified the CVS code to silence this warning for nfs or autofs filesystems.

James Youngman <jay>
Group administrator
Wed 24 Nov 2004 05:49:34 PM UTC, comment #8: 

I tested out 4.2.8 on Solaris 9 and it indeed fixes the
problem.  Solaris automount points only generate a warning.

$ find make -name foobar
find: Warning: filesystem /net/.../make has recently been mounted.

Now, I am divided on whether a warning should be issued at
all, since the automount mechanism is supposed to be
mostly transparent to users.  Find doesn't issue warnings
when crossing "ordinary" mount points, for example.

I suspect the warnings will get tedious for users on
systems with automounted filesystems, and should default
to OFF.  Detection of directories that have turned into
symlinks is another matter, since it's an indication of
mutation in the underlying data that is likely to be
malicious.

(Martin Buchholz)

Anonymous
Wed 24 Nov 2004 03:00:04 PM UTC, comment #7: 

I have implemented the change Martin suggests in findutils (and tested it on a Solaris 9 box with automount running).   Some other changes were required, but it now seems to work.   The code has been released as findutils-4.2.8 on alpha.gnu.org.   Could you confirm please Martin that this works for you?

James Youngman <jay>
Group administrator
Mon 22 Nov 2004 02:56:00 AM UTC, comment #6: 

Unfortunately, the recently released 4.2.7 did not
resolve this problem. (martin.buchholz at sun.com)

If collecting a list of currently mounted filesystems,
you want to collect a list of dev_t, not strings,
which are much harder to deal with, esp. wrt. uniqueness.

Here is a sample program on Solaris 9 to get all dev_t
for all mounted filesystems:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mntio.h>
#include <sys/mkdev.h>

int main (int argc, char *argv[])
{
    int fd = open("/etc/mnttab", O_RDONLY);
    int nmnts = -1;
    uint32_t *devlist;
    ioctl(fd, MNTIOC_NMNTS, &nmnts);
    devlist = (uint32_t*) calloc(2 * nmnts, sizeof(uint32_t));
    ioctl(fd, MNTIOC_GETDEVLIST, devlist);
    printf("fd=%d nmnts=%d\n", fd, nmnts);
    for (int i = 0; i < nmnts; ++i)
      printf("device number=%d\n", makedev(devlist[2*i], devlist[2*i+1]));
    return 0;
}

Of course, this is non-portable, but can be
(tediously but straightforwardly) autoconfiscated.

I don't know if there's a more portable way to get
a list of dev_t for all mounted filesystems.

If was_mounted == is_mounted == 0, then
find knows that it cannot determine the mount history.

I re-instrumented 4.2.7 with similar debugging
code as in 4.2.6, and this time got
was_mounted == is_mounted == 1, defeating an assumption
in the new code.
(patch available on request)

mount_points= / /proc .../
get_mount_point_state: dir=/net/SOMEHOST/export/disk7/jdk1.6.0/j2se/src was_mounted=1 is_mounted=1
wd_sanity: stateChange=MountPointStateUnchanged
wd_sanity: direction=down
find: /net/SOMEHOST/export/disk7/jdk1.6.0/j2se/src changed during execution of find (old device number 81032647, new device number 80744662, filesystem type is nfs) [ref 831]

So get_mounted_filesystems() now correctly returns
a list of mounted filesystems on Solaris, but this does
not solve the problem, since the automounter seems to
be a mounted filesystem that replaces itself with the
"real" filesystem (with a different dev_t) later.

To be reliable, I think we'll have to do the autoconfigury
to determine the list of dev_t's, or give up on this
error check.

Another approach is to give up on this check if the
filesystem involved is NFS (but determining that portably
might be another configure nightmare).  Well, this is
why we concentrate such arcane knowledge in utilities
like find.

Anonymous
Sun 21 Nov 2004 11:33:06 PM UTC, comment #5: 

I believe that thsi problem has been addressed in findutils-4.2.7 in a way that should work on Solaris.

James Youngman <jay>
Group administrator
Sun 21 Nov 2004 10:24:57 PM UTC, comment #4: 

I will shortly issue a release in which get_mounted_filesystems() does not return NULL on Solaris.    I've also addressed the issue of relative pathnames (in a failrly simplistic way).

James Youngman <jay>
Group administrator
Sun 21 Nov 2004 09:52:50 PM UTC, comment #3: 

I (martin.buchholz at sun.com) tried the fix as of
2004-11-21, but it didn't work.  I instrumented the code as
below to print debug info.

$ find test -name foobar
get_mount_point_state: dir=test was_mounted=0 is_mounted=0
mount_points=
wd_sanity: stateChange=MountPointStateUnchanged
wd_sanity: direction=down
find: test changed during execution of find (old device number 81032649, new device number 80744648, filesystem type is nfs) [ref 827]

$ find -version; uname -a
GNU find version 4.2.6
SunOS suttles 5.9 Generic_112233-05 sun4u sparc SUNW,Sun-Blade-1000

I see two serious problems with the fix in 4.2.6:
1. get_mounted_filesystems does not always return useful
   information.  On Solaris it appears to return NULL.
   FSTYPE_MNTENT is not defined in config.h.
2. Even if mount_points contained a complete list of mounted
   filesystems, the call to list_item_present might pass
   in a relative name, and thus not be found.  Some kind
   of complicated canonicalization would be required to
   check whether the filesystem in question was recently
   mounted or unmounted.

--- find/find.c~ 2004-11-21 04:18:59.000000000 -0800
+++ find/find.c 2004-11-21 13:26:56.133944000 -0800
@@ -586,6 +586,18 @@
   return 0;
 }
 
+static void
+print_mount_points(void)
+{
+  const char *s = mount_points;
+  fprintf(stderr, "mount_points=");
+  while (s && *s) {
+    fprintf(stderr, " %s", s);
+    s+=strlen(s);
+  }
+  fprintf(stderr,"\n");
+}
+
 
 /* Determine if a directory has recently had a filesystem
  * mounted on it or unmounted from it.
@@ -605,6 +617,9 @@
  
   is_mounted = list_item_present(dir, mount_points);
 
+  fprintf(stderr, "get_mount_point_state: dir=%s was_mounted=%d is_mounted=%d\n",
+   dir, was_mounted, is_mounted);
+  print_mount_points();
   if (was_mounted == is_mounted)
     return MountPointStateUnchanged;
   else if (is_mounted)
@@ -689,6 +704,7 @@
    switch (transition)
      {
      case MountPointRecentlyUnmounted:
+       fprintf(stderr, "wd_sanity: stateChange=MountPointRecentlyUnmounted\n");
        isfatal = 0;
        error (0, 0,
       _("Filesystem %s has recently been unmounted."),
@@ -696,6 +712,7 @@
        break;
       
      case MountPointRecentlyMounted:
+       fprintf(stderr, "wd_sanity: stateChange=MountPointRecentlyMounted\n");
        isfatal = 0;
        error (0, 0,
       _("Filesystem %s has recently been mounted."),
@@ -703,6 +720,7 @@
        break;
 
      case MountPointStateUnchanged:
+       fprintf(stderr, "wd_sanity: stateChange=MountPointStateUnchanged\n");
        isfatal = 1;
        break;
      }
@@ -710,6 +728,8 @@
 
       if (isfatal)
  {
+   fprintf(stderr, "wd_sanity: direction=%s\n",
+   direction == TraversingDown ? "down" : "up");
    fstype = filesystem_type(thing_to_stat, ".", newinfo);
    error (isfatal, 0,
  _("%s%s changed during execution of %s (old device number %ld, new device number %ld, filesystem type is %s) [ref %ld]"),

Anonymous
Sun 21 Nov 2004 10:38:53 AM UTC, comment #2: 

I think that automountd is the common factor here.  When you chdir() into an aoutomounted directory, that directory is mounted which causes the device number (and inode of course) to change.  This alarms the csanity check that we do.

James Youngman <jay>
Group administrator
Mon 08 Nov 2004 09:47:25 PM UTC, comment #1: 

findutils-4.2.4 has some extra diagnostics for this situation,  could you retest with that version and let me know what error message is produced?   Thanks.

(marked postponed, pending a response)

James Youngman <jay>
Group administrator
Fri 21 May 2004 10:25:33 AM UTC, original submission:  

The stat checks causing the find to quit where:
    * The find path is an SUN automounter directory and
    * It's not already mounted

<<SNIP>>
~> find /proj/test
find: /proj/test changed during execution of find
~> sudo umount /proj/test
~> gnu find /proj/test/.
/proj/test
/proj/test/file
...
<<>>

Thanks.

VenkateswaraRao <parimiv>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 11 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-11-24 jay Open/ClosedOpen Closed
2004-11-24 jay Fixed Release4.2.7 4.2.8
2004-11-21 jay StatusNone Fixed
    Fixed Release4.2.6 4.2.7
2004-11-21 jay Carbon-Copy- Added martin --DOT-- buchholz --AT-- sun --DOT-- com
2004-11-21 jay StatusFixed None
2004-11-21 jay StatusPostponed Fixed
    Fixed ReleaseNone 4.2.6
    Carbon-Copy- Added levon --AT-- movementarian --DOT-- org
2004-11-21 jay Dependencies- Depends on bugs #3998
2004-11-08 jay StatusNone Postponed

Back to the top

Powered by Savane 3.13-f8d8.
Corresponding source code