Deleted Added
full compact
create.c (114601) create.c (121299)
1/*-
2 * Copyright (c) 1989, 1993
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

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

32 */
33
34#if 0
35#ifndef lint
36static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
37#endif /* not lint */
38#endif
39#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
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

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

32 */
33
34#if 0
35#ifndef lint
36static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
37#endif /* not lint */
38#endif
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/usr.sbin/mtree/create.c 114601 2003-05-03 21:06:42Z obrien $");
40__FBSDID("$FreeBSD: head/usr.sbin/mtree/create.c 121299 2003-10-21 07:58:52Z phk $");
41
42#include <sys/param.h>
43#include <sys/stat.h>
44#include <dirent.h>
45#include <err.h>
46#include <errno.h>
47#include <fcntl.h>
48#include <fts.h>

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

80static u_long flags = 0xffffffff;
81
82static int dsort(const FTSENT * const *, const FTSENT * const *);
83static void output(int, int *, const char *, ...) __printflike(3, 4);
84static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *);
85static void statf(int, FTSENT *);
86
87void
41
42#include <sys/param.h>
43#include <sys/stat.h>
44#include <dirent.h>
45#include <err.h>
46#include <errno.h>
47#include <fcntl.h>
48#include <fts.h>

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

80static u_long flags = 0xffffffff;
81
82static int dsort(const FTSENT * const *, const FTSENT * const *);
83static void output(int, int *, const char *, ...) __printflike(3, 4);
84static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *);
85static void statf(int, FTSENT *);
86
87void
88cwalk()
88cwalk(void)
89{
89{
90 register FTS *t;
91 register FTSENT *p;
90 FTS *t;
91 FTSENT *p;
92 time_t cl;
93 char *argv[2], host[MAXHOSTNAMELEN];
94 char dot[] = ".";
95 int indent = 0;
96
97 (void)time(&cl);
98 (void)gethostname(host, sizeof(host));
99 (void)printf(

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

140 }
141 }
142 (void)fts_close(t);
143 if (sflag && keys & F_CKSUM)
144 warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
145}
146
147static void
92 time_t cl;
93 char *argv[2], host[MAXHOSTNAMELEN];
94 char dot[] = ".";
95 int indent = 0;
96
97 (void)time(&cl);
98 (void)gethostname(host, sizeof(host));
99 (void)printf(

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

140 }
141 }
142 (void)fts_close(t);
143 if (sflag && keys & F_CKSUM)
144 warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
145}
146
147static void
148statf(indent, p)
149 int indent;
150 FTSENT *p;
148statf(int indent, FTSENT *p)
151{
152 struct group *gr;
153 struct passwd *pw;
154 uint32_t val;
155 off_t len;
156 int fd, offset;
157 char *fflags;
158 char *escaped_name;

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

269
270#define MAXGID 5000
271#define MAXUID 5000
272#define MAXMODE MBITS + 1
273#define MAXFLAGS 256
274#define MAXS 16
275
276static int
149{
150 struct group *gr;
151 struct passwd *pw;
152 uint32_t val;
153 off_t len;
154 int fd, offset;
155 char *fflags;
156 char *escaped_name;

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

267
268#define MAXGID 5000
269#define MAXUID 5000
270#define MAXMODE MBITS + 1
271#define MAXFLAGS 256
272#define MAXS 16
273
274static int
277statd(t, parent, puid, pgid, pmode, pflags)
278 FTS *t;
279 FTSENT *parent;
280 uid_t *puid;
281 gid_t *pgid;
282 mode_t *pmode;
283 u_long *pflags;
275statd(FTS *t, FTSENT *parent, uid_t *puid, gid_t *pgid, mode_t *pmode, u_long *pflags)
284{
276{
285 register FTSENT *p;
286 register gid_t sgid;
287 register uid_t suid;
288 register mode_t smode;
289 register u_long sflags;
277 FTSENT *p;
278 gid_t sgid;
279 uid_t suid;
280 mode_t smode;
281 u_long sflags;
290 struct group *gr;
291 struct passwd *pw;
292 gid_t savegid = *pgid;
293 uid_t saveuid = *puid;
294 mode_t savemode = *pmode;
295 u_long saveflags = *pflags;
296 u_short maxgid, maxuid, maxmode, maxflags;
297 u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS];

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

392 *pgid = savegid;
393 *pmode = savemode;
394 *pflags = saveflags;
395 }
396 return (0);
397}
398
399static int
282 struct group *gr;
283 struct passwd *pw;
284 gid_t savegid = *pgid;
285 uid_t saveuid = *puid;
286 mode_t savemode = *pmode;
287 u_long saveflags = *pflags;
288 u_short maxgid, maxuid, maxmode, maxflags;
289 u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS];

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

384 *pgid = savegid;
385 *pmode = savemode;
386 *pflags = saveflags;
387 }
388 return (0);
389}
390
391static int
400dsort(a, b)
401 const FTSENT * const *a, * const *b;
392dsort(const FTSENT * const *a, const FTSENT * const *b)
402{
403 if (S_ISDIR((*a)->fts_statp->st_mode)) {
404 if (!S_ISDIR((*b)->fts_statp->st_mode))
405 return (1);
406 } else if (S_ISDIR((*b)->fts_statp->st_mode))
407 return (-1);
408 return (strcmp((*a)->fts_name, (*b)->fts_name));
409}

--- 18 unchanged lines hidden ---
393{
394 if (S_ISDIR((*a)->fts_statp->st_mode)) {
395 if (!S_ISDIR((*b)->fts_statp->st_mode))
396 return (1);
397 } else if (S_ISDIR((*b)->fts_statp->st_mode))
398 return (-1);
399 return (strcmp((*a)->fts_name, (*b)->fts_name));
400}

--- 18 unchanged lines hidden ---