need to change iphlen earlier; icmp_error needs original ip_len; cleanups
[unix-history] / usr / src / usr.bin / find / function.c
index 24901e2..80fc274 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)function.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)function.c 5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -300,17 +300,20 @@ f_fstype(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        PLAN *plan;
        FTSENT *entry;
 {
-       extern dev_t curdev;
+       static dev_t curdev;    /* need a guaranteed illegal dev value */
+       static int first = 1;
        struct statfs sb;
        static short val;
 
        /* only check when we cross mount point */
        struct statfs sb;
        static short val;
 
        /* only check when we cross mount point */
-       if (curdev != entry->fts_statb.st_dev) {
+       if (first || curdev != entry->fts_statb.st_dev) {
+               curdev = entry->fts_statb.st_dev;
                if (statfs(entry->fts_accpath, &sb)) {
                        (void)fprintf(stderr, "find: %s: %s.\n",
                            entry->fts_accpath, strerror(errno));
                        exit(1);
                }
                if (statfs(entry->fts_accpath, &sb)) {
                        (void)fprintf(stderr, "find: %s: %s.\n",
                            entry->fts_accpath, strerror(errno));
                        exit(1);
                }
+               first = 0;
                val = plan->flags == MOUNT_NONE ? sb.f_flags : sb.f_type;
        }
        return(plan->flags == MOUNT_NONE ?
                val = plan->flags == MOUNT_NONE ? sb.f_flags : sb.f_type;
        }
        return(plan->flags == MOUNT_NONE ?
@@ -610,6 +613,7 @@ c_perm(perm)
        char *perm;
 {
        PLAN *new;
        char *perm;
 {
        PLAN *new;
+       mode_t *set, *setmode();
 
        ftsoptions &= ~FTS_NOSTAT;
 
 
        ftsoptions &= ~FTS_NOSTAT;
 
@@ -620,10 +624,10 @@ c_perm(perm)
                ++perm;
        }
 
                ++perm;
        }
 
-       if (setmode(perm))
+       if ((set = setmode(perm)) == NULL)
                bad_arg("-perm", "illegal mode string");
 
                bad_arg("-perm", "illegal mode string");
 
-       new->m_data = getmode(0);
+       new->m_data = getmode(set, 0);
        return(new);
 }
  
        return(new);
 }
  
@@ -730,7 +734,7 @@ f_type(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        PLAN *plan;
        FTSENT *entry;
 {
-       return(entry->fts_statb.st_mode & plan->m_data);
+       return((entry->fts_statb.st_mode & S_IFMT) == plan->m_data);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -815,17 +819,14 @@ c_user(username)
  *
  *     Always true, causes find not to decend past directories that have a
  *     different device ID (st_dev, see stat() S5.6.2 [POSIX.1])
  *
  *     Always true, causes find not to decend past directories that have a
  *     different device ID (st_dev, see stat() S5.6.2 [POSIX.1])
- *
- *     Note: this checking is done in find_execute().
  */
 PLAN *
 c_xdev()
 {
  */
 PLAN *
 c_xdev()
 {
-       extern int xdev;
        PLAN *new;
     
        PLAN *new;
     
-       xdev = 1;
        ftsoptions &= ~FTS_NOSTAT;
        ftsoptions &= ~FTS_NOSTAT;
+       ftsoptions |= FTS_XDEV;
 
        NEW(T_XDEV, f_always_true);
        return(new);
 
        NEW(T_XDEV, f_always_true);
        return(new);