chown.c (10b3b54548f2290bbe8d8f88c59c28d12b7a635d) chown.c (1901b124620ea354267e8b765e7d6a9bb3967755)
1/*
2 * Copyright (c) 1988, 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

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

68int ischown;
69const char *gname;
70
71int
72main(int argc, char **argv)
73{
74 FTS *ftsp;
75 FTSENT *p;
1/*
2 * Copyright (c) 1988, 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

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

68int ischown;
69const char *gname;
70
71int
72main(int argc, char **argv)
73{
74 FTS *ftsp;
75 FTSENT *p;
76 int Hflag, Lflag, Rflag, fflag, hflag, vflag;
76 int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
77 int ch, fts_options, rval;
78 char *cp;
79
80 ischown = (strcmp(basename(argv[0]), "chown") == 0);
81
77 int ch, fts_options, rval;
78 char *cp;
79
80 ischown = (strcmp(basename(argv[0]), "chown") == 0);
81
82 Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
83 while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
82 Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0;
83 while ((ch = getopt(argc, argv, "HLPRfhvx")) != -1)
84 switch (ch) {
85 case 'H':
86 Hflag = 1;
87 Lflag = 0;
88 break;
89 case 'L':
90 Lflag = 1;
91 Hflag = 0;

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

100 fflag = 1;
101 break;
102 case 'h':
103 hflag = 1;
104 break;
105 case 'v':
106 vflag++;
107 break;
84 switch (ch) {
85 case 'H':
86 Hflag = 1;
87 Lflag = 0;
88 break;
89 case 'L':
90 Lflag = 1;
91 Hflag = 0;

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

100 fflag = 1;
101 break;
102 case 'h':
103 hflag = 1;
104 break;
105 case 'v':
106 vflag++;
107 break;
108 case 'x':
109 xflag = 1;
110 break;
108 case '?':
109 default:
110 usage();
111 }
112 argv += optind;
113 argc -= optind;
114
115 if (argc < 2)

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

123 if (Hflag)
124 fts_options |= FTS_COMFOLLOW;
125 else if (Lflag) {
126 fts_options &= ~FTS_PHYSICAL;
127 fts_options |= FTS_LOGICAL;
128 }
129 } else
130 fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
111 case '?':
112 default:
113 usage();
114 }
115 argv += optind;
116 argc -= optind;
117
118 if (argc < 2)

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

126 if (Hflag)
127 fts_options |= FTS_COMFOLLOW;
128 else if (Lflag) {
129 fts_options &= ~FTS_PHYSICAL;
130 fts_options |= FTS_LOGICAL;
131 }
132 } else
133 fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
134 if (xflag)
135 fts_options |= FTS_XDEV;
131
132 uid = (uid_t)-1;
133 gid = (gid_t)-1;
134 if (ischown) {
135 if ((cp = strchr(*argv, ':')) != NULL) {
136 *cp++ = '\0';
137 a_gid(cp);
138 }

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

296}
297
298void
299usage(void)
300{
301
302 if (ischown)
303 (void)fprintf(stderr, "%s\n%s\n",
136
137 uid = (uid_t)-1;
138 gid = (gid_t)-1;
139 if (ischown) {
140 if ((cp = strchr(*argv, ':')) != NULL) {
141 *cp++ = '\0';
142 a_gid(cp);
143 }

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

301}
302
303void
304usage(void)
305{
306
307 if (ischown)
308 (void)fprintf(stderr, "%s\n%s\n",
304 "usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group]"
309 "usage: chown [-fhvx] [-R [-H | -L | -P]] owner[:group]"
305 " file ...",
310 " file ...",
306 " chown [-fhv] [-R [-H | -L | -P]] :group file ...");
311 " chown [-fhvx] [-R [-H | -L | -P]] :group file ...");
307 else
308 (void)fprintf(stderr, "%s\n",
312 else
313 (void)fprintf(stderr, "%s\n",
309 "usage: chgrp [-fhv] [-R [-H | -L | -P]] group file ...");
314 "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ...");
310 exit(1);
311}
315 exit(1);
316}