chown.c (987d3799f3bb1ce1c70bc89e5de3b89488f894c8) chown.c (ae29e30076cd8807e15927bd7f32724964c1b862)
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

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

50#include <sys/stat.h>
51
52#include <err.h>
53#include <errno.h>
54#include <fts.h>
55#include <grp.h>
56#include <libgen.h>
57#include <pwd.h>
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

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

50#include <sys/stat.h>
51
52#include <err.h>
53#include <errno.h>
54#include <fts.h>
55#include <grp.h>
56#include <libgen.h>
57#include <pwd.h>
58#include <stdint.h>
58#include <stdio.h>
59#include <stdlib.h>
60#include <string.h>
61#include <unistd.h>
62
63void a_gid(const char *);
64void a_uid(const char *);
65void chownerr(const char *);

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

101 break;
102 case 'f':
103 fflag = 1;
104 break;
105 case 'h':
106 hflag = 1;
107 break;
108 case 'v':
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <unistd.h>
63
64void a_gid(const char *);
65void a_uid(const char *);
66void chownerr(const char *);

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

102 break;
103 case 'f':
104 fflag = 1;
105 break;
106 case 'h':
107 hflag = 1;
108 break;
109 case 'v':
109 vflag = 1;
110 vflag++;
110 break;
111 case '?':
112 default:
113 usage();
114 }
115 argv += optind;
116 argc -= optind;
117

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

186 (gid == (gid_t)-1 || gid == p->fts_statp->st_gid))
187 continue;
188 if ((hflag ? lchown : chown)(p->fts_accpath, uid, gid) == -1) {
189 if (!fflag) {
190 chownerr(p->fts_path);
191 rval = 1;
192 }
193 } else {
111 break;
112 case '?':
113 default:
114 usage();
115 }
116 argv += optind;
117 argc -= optind;
118

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

187 (gid == (gid_t)-1 || gid == p->fts_statp->st_gid))
188 continue;
189 if ((hflag ? lchown : chown)(p->fts_accpath, uid, gid) == -1) {
190 if (!fflag) {
191 chownerr(p->fts_path);
192 rval = 1;
193 }
194 } else {
194 if (vflag)
195 printf("%s\n", p->fts_path);
195 if (vflag) {
196 printf("%s", p->fts_path);
197 if (vflag > 1) {
198 if (ischown) {
199 printf(": %ju:%ju -> %ju:%ju",
200 (uintmax_t)
201 p->fts_statp->st_uid,
202 (uintmax_t)
203 p->fts_statp->st_gid,
204 (uid == (uid_t)-1) ?
205 (uintmax_t)
206 p->fts_statp->st_uid :
207 (uintmax_t)uid,
208 (gid == (gid_t)-1) ?
209 (uintmax_t)
210 p->fts_statp->st_gid :
211 (uintmax_t)gid);
212 } else {
213 printf(": %ju -> %ju",
214 (uintmax_t)
215 p->fts_statp->st_gid,
216 (gid == (gid_t)-1) ?
217 (uintmax_t)
218 p->fts_statp->st_gid :
219 (uintmax_t)gid);
220 }
221 }
222 printf("\n");
223 }
196 }
197 }
198 if (errno)
199 err(1, "fts_read");
200 exit(rval);
201}
202
203void

--- 80 unchanged lines hidden ---
224 }
225 }
226 if (errno)
227 err(1, "fts_read");
228 exit(rval);
229}
230
231void

--- 80 unchanged lines hidden ---