[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bugs #9043] find fails on automounter paths

From: James Youngman
Subject: [bugs #9043] find fails on automounter paths
Date: Wed, 24 Nov 2004 10:18:53 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Epiphany/1.2.9

This mail is an automated notification from the bugs tracker
 of the project: findutils.

[bugs #9043] Latest Modifications:

Changes by: 
                James Youngman <address@hidden>
                Wed 11/24/04 at 15:00 (GMT)

            What     | Removed                   | Added
       Fixed Release | 4.2.7                     | 4.2.8

------------------ Additional Follow-up Comments ----------------------------
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?

[bugs #9043] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=9043>
Project: findutils
Submitted by: VenkateswaraRao
On: Fri 05/21/04 at 10:25

Category:  find
Severity:  5 - Average
Item Group:  None
Resolution:  Fixed
Privacy:  Public
Assigned to:  None
Originator Name:  
Originator Email:  
Status:  Open
Release:  None
Fixed Release:  4.2.8

Summary:  find fails on automounter paths

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

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


Follow-up Comments

Date: Wed 11/24/04 at 15:00         By: James Youngman <jay>
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?

Date: Mon 11/22/04 at 02:56         By: 0 <None>
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=%dn", fd, nmnts);
    for (int i = 0; i < nmnts; ++i)
      printf("device number=%dn", 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.

Date: Sun 11/21/04 at 23:33         By: James Youngman <jay>
I believe that thsi problem has been addressed in findutils-4.2.7 in a way that 
should work on Solaris.

Date: Sun 11/21/04 at 22:24         By: James Youngman <jay>
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).

Date: Sun 11/21/04 at 21:52         By: 0 <None>
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
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
+  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 
+         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: 
              isfatal = 0;
              error (0, 0,
                     _("Filesystem %s has recently been unmounted."),
@@ -696,6 +712,7 @@
            case MountPointRecentlyMounted:
+             fprintf(stderr, "wd_sanity: 
              isfatal = 0;
              error (0, 0,
                     _("Filesystem %s has recently been mounted."),
@@ -703,6 +720,7 @@
            case MountPointStateUnchanged:
+             fprintf(stderr, "wd_sanity: 
              isfatal = 1;
@@ -710,6 +728,8 @@
       if (isfatal)
+         fprintf(stderr, "wd_sanity: direction=%sn",
+                 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]"),

Date: Sun 11/21/04 at 10:38         By: James Youngman <jay>
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 

Date: Mon 11/08/04 at 21:47         By: James Youngman <jay>
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?   

(marked postponed, pending a response)

CC List

CC Address                          | Comment
martin --DOT-- buchholz --AT-- sun --DOT-- com | 
levon --AT-- movementarian --DOT-- org | 

For detailed info, follow this link:

  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]