fix silly indirect-through-zero bug
[unix-history] / usr / src / usr.sbin / mtree / create.c
index 40d69ac..7c5243a 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)create.c   5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)create.c   5.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -48,12 +48,12 @@ cwalk()
 
        argv[0] = ".";
        argv[1] = (char *)NULL;
 
        argv[0] = ".";
        argv[1] = (char *)NULL;
-       if (!(t = ftsopen(argv, ftsoptions, dsort))) {
+       if (!(t = fts_open(argv, ftsoptions, dsort))) {
                (void)fprintf(stderr,
                (void)fprintf(stderr,
-                   "mtree: ftsopen: %s.\n", strerror(errno));
+                   "mtree: fts_open: %s.\n", strerror(errno));
                exit(1);
        }
                exit(1);
        }
-       while (p = ftsread(t)) {
+       while (p = fts_read(t)) {
                switch(p->fts_info) {
                case FTS_D:
                        if (dflag)
                switch(p->fts_info) {
                case FTS_D:
                        if (dflag)
@@ -64,18 +64,6 @@ cwalk()
                        if (!strcmp(p->fts_name, "."))
                                continue;
                        break;
                        if (!strcmp(p->fts_name, "."))
                                continue;
                        break;
-               case FTS_DC:
-                       (void)fprintf(stderr,
-                           "mtree: directory cycle: %s.\n", p->fts_path);
-                       continue;
-               case FTS_DNR:
-                       (void)fprintf(stderr,
-                           "mtree: %s: unable to read.\n", p->fts_path);
-                       continue;
-               case FTS_DNX:
-                       (void)fprintf(stderr,
-                           "mtree: %s: unable to search.\n", p->fts_path);
-                       continue;
                case FTS_DP:
                        if (p->fts_level <= 0)
                                continue;
                case FTS_DP:
                        if (p->fts_level <= 0)
                                continue;
@@ -83,14 +71,12 @@ cwalk()
                                (void)putchar('\t');
                        (void)printf("..\n");
                        continue;
                                (void)putchar('\t');
                        (void)printf("..\n");
                        continue;
+               case FTS_DNR:
                case FTS_ERR:
                case FTS_ERR:
+               case FTS_NS:
                        (void)fprintf(stderr, "mtree: %s: %s.\n",
                            p->fts_path, strerror(errno));
                        continue;
                        (void)fprintf(stderr, "mtree: %s: %s.\n",
                            p->fts_path, strerror(errno));
                        continue;
-               case FTS_NS:
-                       (void)fprintf(stderr,
-                           "mtree: can't stat: %s.\n", p->fts_path);
-                       continue;
                default:
                        if (dflag)
                                continue;
                default:
                        if (dflag)
                                continue;
@@ -139,6 +125,7 @@ cwalk()
                }
                (void)putchar('\n');
        }
                }
                (void)putchar('\n');
        }
+       (void)fts_close(t);
 }
 
 #define        MAXGID  5000
 }
 
 #define        MAXGID  5000
@@ -162,7 +149,7 @@ statdir(t, parent, puid, pgid, pmode, tabs)
        mode_t savemode;
        u_short maxgid, maxuid, maxmode, g[MAXGID], u[MAXUID], m[MAXMODE];
 
        mode_t savemode;
        u_short maxgid, maxuid, maxmode, g[MAXGID], u[MAXUID], m[MAXMODE];
 
-       if (!(p = ftschildren(t))) {
+       if (!(p = fts_children(t))) {
                if (errno) {
                        (void)fprintf(stderr, "mtree: %s: %s.\n",
                            RP(parent), strerror(errno));
                if (errno) {
                        (void)fprintf(stderr, "mtree: %s: %s.\n",
                            RP(parent), strerror(errno));