create.c (60418) | create.c (61749) |
---|---|
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 --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = | 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 --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/usr.sbin/mtree/create.c 60418 2000-05-12 03:03:00Z wollman $"; | 39 "$FreeBSD: head/usr.sbin/mtree/create.c 61749 2000-06-17 14:19:33Z joe $"; |
40#endif /* not lint */ 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> --- 100 unchanged lines hidden (view full) --- 148statf(indent, p) 149 int indent; 150 FTSENT *p; 151{ 152 struct group *gr; 153 struct passwd *pw; 154 u_long len, val; 155 int fd, offset; | 40#endif /* not lint */ 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> --- 100 unchanged lines hidden (view full) --- 148statf(indent, p) 149 int indent; 150 FTSENT *p; 151{ 152 struct group *gr; 153 struct passwd *pw; 154 u_long len, val; 155 int fd, offset; |
156 char *fflags; |
|
156 char *escaped_name; 157 158 escaped_name = calloc(1, p->fts_namelen * 4 + 1); 159 if (escaped_name == NULL) 160 errx(1, "statf(): calloc() failed"); 161 strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL); 162 163 if (iflag || S_ISDIR(p->fts_statp->st_mode)) --- 87 unchanged lines hidden (view full) --- 251 } else { 252 output(indent, &offset, "ripemd160digest=%s", digest); 253 } 254 } 255#endif /* RMD160 */ 256 if (keys & F_SLINK && 257 (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) 258 output(indent, &offset, "link=%s", rlink(p->fts_accpath)); | 157 char *escaped_name; 158 159 escaped_name = calloc(1, p->fts_namelen * 4 + 1); 160 if (escaped_name == NULL) 161 errx(1, "statf(): calloc() failed"); 162 strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL); 163 164 if (iflag || S_ISDIR(p->fts_statp->st_mode)) --- 87 unchanged lines hidden (view full) --- 252 } else { 253 output(indent, &offset, "ripemd160digest=%s", digest); 254 } 255 } 256#endif /* RMD160 */ 257 if (keys & F_SLINK && 258 (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) 259 output(indent, &offset, "link=%s", rlink(p->fts_accpath)); |
259 if (keys & F_FLAGS && p->fts_statp->st_flags != flags) 260 output(indent, &offset, "flags=%s", 261 getflags(p->fts_statp->st_flags, "none")); | 260 if (keys & F_FLAGS && p->fts_statp->st_flags != flags) { 261 fflags = flags_to_string(p->fts_statp->st_flags); 262 output(indent, &offset, "flags=%s", fflags); 263 free(fflags); 264 } |
262 (void)putchar('\n'); 263} 264 265#define MAXGID 5000 266#define MAXUID 5000 267#define MAXMODE MBITS + 1 268#define MAXFLAGS 256 269#define MAXS 16 --- 15 unchanged lines hidden (view full) --- 285 struct group *gr; 286 struct passwd *pw; 287 gid_t savegid = *pgid; 288 uid_t saveuid = *puid; 289 mode_t savemode = *pmode; 290 u_long saveflags = 0; 291 u_short maxgid, maxuid, maxmode, maxflags; 292 u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS]; | 265 (void)putchar('\n'); 266} 267 268#define MAXGID 5000 269#define MAXUID 5000 270#define MAXMODE MBITS + 1 271#define MAXFLAGS 256 272#define MAXS 16 --- 15 unchanged lines hidden (view full) --- 288 struct group *gr; 289 struct passwd *pw; 290 gid_t savegid = *pgid; 291 uid_t saveuid = *puid; 292 mode_t savemode = *pmode; 293 u_long saveflags = 0; 294 u_short maxgid, maxuid, maxmode, maxflags; 295 u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS]; |
296 char *fflags; |
|
293 static int first = 1; 294 295 if ((p = fts_children(t, 0)) == NULL) { 296 if (errno) 297 err(1, "line %d: %s", lineno, RP(parent)); 298 return (1); 299 } 300 --- 68 unchanged lines hidden (view full) --- 369 lineno, savegid); 370 } 371 if (keys & F_GID) 372 (void)printf(" gid=%lu", (u_long)savegid); 373 if (keys & F_MODE) 374 (void)printf(" mode=%#o", savemode); 375 if (keys & F_NLINK) 376 (void)printf(" nlink=1"); | 297 static int first = 1; 298 299 if ((p = fts_children(t, 0)) == NULL) { 300 if (errno) 301 err(1, "line %d: %s", lineno, RP(parent)); 302 return (1); 303 } 304 --- 68 unchanged lines hidden (view full) --- 373 lineno, savegid); 374 } 375 if (keys & F_GID) 376 (void)printf(" gid=%lu", (u_long)savegid); 377 if (keys & F_MODE) 378 (void)printf(" mode=%#o", savemode); 379 if (keys & F_NLINK) 380 (void)printf(" nlink=1"); |
377 if (keys & F_FLAGS && saveflags) 378 (void)printf(" flags=%s", 379 getflags(saveflags, "none")); | 381 if (keys & F_FLAGS && saveflags) { 382 fflags = flags_to_string(saveflags); 383 (void)printf(" flags=%s", fflags); 384 free(fflags); 385 } |
380 (void)printf("\n"); 381 *puid = saveuid; 382 *pgid = savegid; 383 *pmode = savemode; 384 *pflags = saveflags; 385 } 386 return (0); 387} --- 46 unchanged lines hidden --- | 386 (void)printf("\n"); 387 *puid = saveuid; 388 *pgid = savegid; 389 *pmode = savemode; 390 *pflags = saveflags; 391 } 392 return (0); 393} --- 46 unchanged lines hidden --- |