create.c (99800) | create.c (99802) |
---|---|
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 99800 2002-07-11 18:31:16Z alfred $"; | 39 "$FreeBSD: head/usr.sbin/mtree/create.c 99802 2002-07-11 18:42:53Z alfred $"; |
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> --- 36 unchanged lines hidden (view full) --- 84static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *); 85static void statf(int, FTSENT *); 86 87void 88cwalk() 89{ 90 register FTS *t; 91 register FTSENT *p; | 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> --- 36 unchanged lines hidden (view full) --- 84static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *); 85static void statf(int, FTSENT *); 86 87void 88cwalk() 89{ 90 register FTS *t; 91 register FTSENT *p; |
92 time_t clock; | 92 time_t cl; |
93 char *argv[2], host[MAXHOSTNAMELEN]; | 93 char *argv[2], host[MAXHOSTNAMELEN]; |
94 char dot[] = "."; |
|
94 int indent = 0; 95 | 95 int indent = 0; 96 |
96 (void)time(&clock); | 97 (void)time(&cl); |
97 (void)gethostname(host, sizeof(host)); 98 (void)printf( 99 "#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n#\t date: %s", | 98 (void)gethostname(host, sizeof(host)); 99 (void)printf( 100 "#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n#\t date: %s", |
100 getlogin(), host, fullpath, ctime(&clock)); | 101 getlogin(), host, fullpath, ctime(&cl)); |
101 | 102 |
102 argv[0] = "."; | 103 argv[0] = dot; |
103 argv[1] = NULL; 104 if ((t = fts_open(argv, ftsoptions, dsort)) == NULL) 105 err(1, "line %d: fts_open", lineno); 106 while ((p = fts_read(t))) { 107 if (iflag) 108 indent = p->fts_level * 4; 109 if (check_excludes(p->fts_name, p->fts_path)) { 110 fts_set(t, p, FTS_SKIP); --- 92 unchanged lines hidden (view full) --- 203 if (keys & F_MODE && (p->fts_statp->st_mode & MBITS) != mode) 204 output(indent, &offset, "mode=%#o", p->fts_statp->st_mode & MBITS); 205 if (keys & F_NLINK && p->fts_statp->st_nlink != 1) 206 output(indent, &offset, "nlink=%u", p->fts_statp->st_nlink); 207 if (keys & F_SIZE) 208 output(indent, &offset, "size=%qd", p->fts_statp->st_size); 209 if (keys & F_TIME) 210 output(indent, &offset, "time=%ld.%ld", | 104 argv[1] = NULL; 105 if ((t = fts_open(argv, ftsoptions, dsort)) == NULL) 106 err(1, "line %d: fts_open", lineno); 107 while ((p = fts_read(t))) { 108 if (iflag) 109 indent = p->fts_level * 4; 110 if (check_excludes(p->fts_name, p->fts_path)) { 111 fts_set(t, p, FTS_SKIP); --- 92 unchanged lines hidden (view full) --- 204 if (keys & F_MODE && (p->fts_statp->st_mode & MBITS) != mode) 205 output(indent, &offset, "mode=%#o", p->fts_statp->st_mode & MBITS); 206 if (keys & F_NLINK && p->fts_statp->st_nlink != 1) 207 output(indent, &offset, "nlink=%u", p->fts_statp->st_nlink); 208 if (keys & F_SIZE) 209 output(indent, &offset, "size=%qd", p->fts_statp->st_size); 210 if (keys & F_TIME) 211 output(indent, &offset, "time=%ld.%ld", |
211 p->fts_statp->st_mtimespec.tv_sec, | 212 (long)p->fts_statp->st_mtimespec.tv_sec, |
212 p->fts_statp->st_mtimespec.tv_nsec); 213 if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { 214 if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 || 215 crc(fd, &val, &len)) 216 err(1, "line %d: %s", lineno, p->fts_accpath); 217 (void)close(fd); 218 output(indent, &offset, "cksum=%lu", val); 219 } --- 205 unchanged lines hidden --- | 213 p->fts_statp->st_mtimespec.tv_nsec); 214 if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { 215 if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 || 216 crc(fd, &val, &len)) 217 err(1, "line %d: %s", lineno, p->fts_accpath); 218 (void)close(fd); 219 output(indent, &offset, "cksum=%lu", val); 220 } --- 205 unchanged lines hidden --- |