chmod.c (2a4562393f80633b81c11d4f7df00548d1cc3c48) chmod.c (5bb83b98dbde8326de7b8221ef899ca38ddb3180)
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 56 unchanged lines hidden (view full) ---

65 char *argv[];
66{
67 FTS *ftsp;
68 FTSENT *p;
69 mode_t *set;
70 long val;
71 int oct, omode;
72 int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 56 unchanged lines hidden (view full) ---

65 char *argv[];
66{
67 FTS *ftsp;
68 FTSENT *p;
69 mode_t *set;
70 long val;
71 int oct, omode;
72 int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
73 int vflag;
73 char *ep, *mode;
74
75 set = NULL;
76 omode = 0;
77 Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
74 char *ep, *mode;
75
76 set = NULL;
77 omode = 0;
78 Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
78 while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != -1)
79 while ((ch = getopt(argc, argv, "HLPRXfgorstuvwx")) != -1)
79 switch (ch) {
80 case 'H':
81 Hflag = 1;
82 Lflag = Pflag = 0;
83 break;
84 case 'L':
85 Lflag = 1;
86 Hflag = Pflag = 0;

--- 26 unchanged lines hidden (view full) ---

113 */
114 case 'g': case 'o': case 'r': case 's':
115 case 't': case 'u': case 'w': case 'X': case 'x':
116 if (argv[optind - 1][0] == '-' &&
117 argv[optind - 1][1] == ch &&
118 argv[optind - 1][2] == '\0')
119 --optind;
120 goto done;
80 switch (ch) {
81 case 'H':
82 Hflag = 1;
83 Lflag = Pflag = 0;
84 break;
85 case 'L':
86 Lflag = 1;
87 Hflag = Pflag = 0;

--- 26 unchanged lines hidden (view full) ---

114 */
115 case 'g': case 'o': case 'r': case 's':
116 case 't': case 'u': case 'w': case 'X': case 'x':
117 if (argv[optind - 1][0] == '-' &&
118 argv[optind - 1][1] == ch &&
119 argv[optind - 1][2] == '\0')
120 --optind;
121 goto done;
122 case 'v':
123 vflag = 1;
124 break;
121 case '?':
122 default:
123 usage();
124 }
125done: argv += optind;
126 argc -= optind;
127
128 if (argc < 2)

--- 57 unchanged lines hidden (view full) ---

186 continue;
187 default:
188 break;
189 }
190 if (chmod(p->fts_accpath, oct ? omode :
191 getmode(set, p->fts_statp->st_mode)) && !fflag) {
192 warn(p->fts_path);
193 rval = 1;
125 case '?':
126 default:
127 usage();
128 }
129done: argv += optind;
130 argc -= optind;
131
132 if (argc < 2)

--- 57 unchanged lines hidden (view full) ---

190 continue;
191 default:
192 break;
193 }
194 if (chmod(p->fts_accpath, oct ? omode :
195 getmode(set, p->fts_statp->st_mode)) && !fflag) {
196 warn(p->fts_path);
197 rval = 1;
198 } else {
199 if (vflag)
200 (void)printf("%s\n", p->fts_accpath);
194 }
195 }
196 if (errno)
197 err(1, "fts_read");
198 free(set);
199 exit(rval);
200}
201
202void
203usage()
204{
205 (void)fprintf(stderr,
201 }
202 }
203 if (errno)
204 err(1, "fts_read");
205 free(set);
206 exit(rval);
207}
208
209void
210usage()
211{
212 (void)fprintf(stderr,
206 "usage: chmod [-f -R [-H | -L | -P]] mode file ...\n");
213 "usage: chmod [-f -R [-H | -L | -P] -v] mode file ...\n");
207 exit(1);
208}
214 exit(1);
215}