BSD 4_3_Reno release
[unix-history] / usr / src / usr.sbin / mtree / create.c
index c38a0ab..b7cfbba 100644 (file)
@@ -2,11 +2,23 @@
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)create.c   5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)create.c   5.14 (Berkeley) 6/25/90";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -35,6 +47,7 @@ cwalk()
        gid_t gid;
        mode_t mode;
        int tabs, dsort();
        gid_t gid;
        mode_t mode;
        int tabs, dsort();
+       char *argv[2];
        char curp[MAXPATHLEN], *inotype(), *getlogin(), *rlink();
 
        if (!getwd(curp)) {
        char curp[MAXPATHLEN], *inotype(), *getlogin(), *rlink();
 
        if (!getwd(curp)) {
@@ -42,10 +55,12 @@ cwalk()
                exit(1);
        }
        (void)time(&clock);
                exit(1);
        }
        (void)time(&clock);
-       (void)printf("#\n#\t  fs: %s\n#\t  by: %s\n#\tdate: %s#\n",
+       (void)printf("#\t  fs: %s\n#\t  by: %s\n#\tdate: %s\n",
            curp, getlogin(), ctime(&clock));
 
            curp, getlogin(), ctime(&clock));
 
-       if (!(t = ftsopen(".", ftsoptions, dsort))) {
+       argv[0] = ".";
+       argv[1] = (char *)NULL;
+       if (!(t = ftsopen(argv, ftsoptions, dsort))) {
                (void)fprintf(stderr,
                    "mtree: ftsopen: %s.\n", strerror(errno));
                exit(1);
                (void)fprintf(stderr,
                    "mtree: ftsopen: %s.\n", strerror(errno));
                exit(1);
@@ -127,6 +142,8 @@ cwalk()
                }
                LABEL;
                (void)printf("size=%ld", p->fts_statb.st_size);
                }
                LABEL;
                (void)printf("size=%ld", p->fts_statb.st_size);
+               LABEL;
+               (void)printf("time=%ld", p->fts_statb.st_mtime);
 
                if (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE) {
                        LABEL;
 
                if (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE) {
                        LABEL;
@@ -134,13 +151,13 @@ cwalk()
                }
                (void)putchar('\n');
        }
                }
                (void)putchar('\n');
        }
+       (void)ftsclose(t);
 }
 
 #define        MAXGID  5000
 #define        MAXUID  5000
 }
 
 #define        MAXGID  5000
 #define        MAXUID  5000
-#define        MAXMODE 0777 + 1
+#define        MAXMODE MBITS + 1
 
 
-static
 statdir(t, parent, puid, pgid, pmode, tabs)
        FTS *t;
        FTSENT *parent;
 statdir(t, parent, puid, pgid, pmode, tabs)
        FTS *t;
        FTSENT *parent;
@@ -174,7 +191,7 @@ statdir(t, parent, puid, pgid, pmode, tabs)
        *tabs = 1;
        maxuid = maxgid = maxmode = 0;
        for (; p; p = p->fts_link) {
        *tabs = 1;
        maxuid = maxgid = maxmode = 0;
        for (; p; p = p->fts_link) {
-               mode = p->fts_statb.st_mode&0777;
+               mode = p->fts_statb.st_mode & MBITS;
                if (mode < MAXMODE && ++m[mode] > maxmode) {
                        savemode = mode;
                        maxmode = m[mode];
                if (mode < MAXMODE && ++m[mode] > maxmode) {
                        savemode = mode;
                        maxmode = m[mode];
@@ -192,7 +209,7 @@ statdir(t, parent, puid, pgid, pmode, tabs)
                if (p->fts_namelen > 7)
                        *tabs = 2;
        }
                if (p->fts_namelen > 7)
                        *tabs = 2;
        }
-       (void)printf("\n/set group=%u, mode=%#o, nlink=1, owner=%u, type=file\n",
+       (void)printf("\n/set group=%u mode=%#o nlink=1 owner=%u type=file\n",
            savegid, savemode, saveuid);
        *puid = saveuid;
        *pgid = savegid;
            savegid, savemode, saveuid);
        *puid = saveuid;
        *pgid = savegid;
@@ -200,7 +217,6 @@ statdir(t, parent, puid, pgid, pmode, tabs)
        return(0);
 }
 
        return(0);
 }
 
-static
 dsort(p1, p2)
        FTSENT **p1, **p2;
 {
 dsort(p1, p2)
        FTSENT **p1, **p2;
 {