new version of get/setmode
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 17 Apr 1990 05:10:08 +0000 (21:10 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 17 Apr 1990 05:10:08 +0000 (21:10 -0800)
SCCS-vsn: usr.bin/xinstall/xinstall.c 5.22
SCCS-vsn: bin/chmod/chmod.c 5.10

usr/src/bin/chmod/chmod.c
usr/src/usr.bin/xinstall/xinstall.c

index a4ff0b6..9d651e7 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)chmod.c    5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)chmod.c    5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -43,6 +43,7 @@ main(argc, argv)
        register FTSENT *p;
        register int oct, omode;
        register char *mode;
        register FTSENT *p;
        register int oct, omode;
        register char *mode;
+       mode_t *set, *setmode();
        struct stat sb;
        int ch, fflag, rflag;
 
        struct stat sb;
        int ch, fflag, rflag;
 
@@ -76,7 +77,7 @@ done: argv += optind;
                omode = (int)strtol(mode, (char **)NULL, 8);
                oct = 1;
        } else {
                omode = (int)strtol(mode, (char **)NULL, 8);
                oct = 1;
        } else {
-               if (setmode(mode) == -1) {
+               if (!(set = setmode(mode))) {
                        (void)fprintf(stderr, "chmod: invalid file mode.\n");
                        exit(1);
                }
                        (void)fprintf(stderr, "chmod: invalid file mode.\n");
                        exit(1);
                }
@@ -98,8 +99,8 @@ done: argv += optind;
                                        error(p->path);
                                continue;
                        }
                                        error(p->path);
                                continue;
                        }
-                       if (chmod(p->accpath,
-                           oct ? omode : getmode(p->statb.st_mode) && !fflag))
+                       if (chmod(p->accpath, oct ?
+                           omode : getmode(set, p->statb.st_mode) && !fflag))
                                error(p->path);
                }
                exit(retval);
                                error(p->path);
                }
                exit(retval);
@@ -111,7 +112,7 @@ done:       argv += optind;
        } else
                while (*++argv)
                        if ((lstat(*argv, &sb) ||
        } else
                while (*++argv)
                        if ((lstat(*argv, &sb) ||
-                           chmod(*argv, getmode(sb.st_mode))) && !fflag)
+                           chmod(*argv, getmode(set, sb.st_mode))) && !fflag)
                                error(*argv);
        exit(retval);
 }
                                error(*argv);
        exit(retval);
 }
index 93ab735..a3c03a1 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)xinstall.c 5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)xinstall.c 5.22 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -47,6 +47,7 @@ main(argc, argv)
        extern char *optarg;
        extern int optind;
        struct stat from_sb, to_sb;
        extern char *optarg;
        extern int optind;
        struct stat from_sb, to_sb;
+       mode_t *set, *setmode();
        int ch, no_target;
        char *to_name;
 
        int ch, no_target;
        char *to_name;
 
@@ -59,12 +60,12 @@ main(argc, argv)
                        group = optarg;
                        break;
                case 'm':
                        group = optarg;
                        break;
                case 'm':
-                       if (setmode(optarg) == -1) {
+                       if (!(set = setmode(optarg))) {
                                (void)fprintf(stderr,
                                    "install: invalid file mode.\n");
                                exit(1);
                        }
                                (void)fprintf(stderr,
                                    "install: invalid file mode.\n");
                                exit(1);
                        }
-                       mode = getmode(0);
+                       mode = getmode(set, 0);
                        break;
                case 'o':
                        owner = optarg;
                        break;
                case 'o':
                        owner = optarg;