dumpfs.c (92806) | dumpfs.c (92839) |
---|---|
1/* 2 * Copyright (c) 1983, 1992, 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 --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95"; 43#endif 44static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1992, 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 --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/sbin/dumpfs/dumpfs.c 92806 2002-03-20 17:55:10Z obrien $"; | 45 "$FreeBSD: head/sbin/dumpfs/dumpfs.c 92839 2002-03-20 22:57:10Z imp $"; |
46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/time.h> 50 51#include <ufs/ffs/fs.h> 52 53#include <err.h> --- 12 unchanged lines hidden (view full) --- 66union { 67 struct cg cg; 68 char pad[MAXBSIZE]; 69} cgun; 70#define acg cgun.cg 71 72long dev_bsize = 1; 73 | 46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/time.h> 50 51#include <ufs/ffs/fs.h> 52 53#include <err.h> --- 12 unchanged lines hidden (view full) --- 66union { 67 struct cg cg; 68 char pad[MAXBSIZE]; 69} cgun; 70#define acg cgun.cg 71 72long dev_bsize = 1; 73 |
74int dumpfs __P((char *)); 75int dumpcg __P((char *, int, int)); 76void pbits __P((void *, int)); 77void usage __P((void)); | 74int dumpfs(const char *); 75int dumpcg(const char *, int, int); 76void pbits(void *, int); 77void usage(void) __dead2; |
78 79int | 78 79int |
80main(argc, argv) 81 int argc; 82 char *argv[]; | 80main(int argc, char *argv[]) |
83{ 84 struct fstab *fs; 85 int ch, eval; 86 87 while ((ch = getopt(argc, argv, "")) != -1) 88 switch(ch) { 89 case '?': 90 default: --- 9 unchanged lines hidden (view full) --- 100 if ((fs = getfsfile(*argv)) == NULL) 101 eval |= dumpfs(*argv); 102 else 103 eval |= dumpfs(fs->fs_spec); 104 exit(eval); 105} 106 107int | 81{ 82 struct fstab *fs; 83 int ch, eval; 84 85 while ((ch = getopt(argc, argv, "")) != -1) 86 switch(ch) { 87 case '?': 88 default: --- 9 unchanged lines hidden (view full) --- 98 if ((fs = getfsfile(*argv)) == NULL) 99 eval |= dumpfs(*argv); 100 else 101 eval |= dumpfs(fs->fs_spec); 102 exit(eval); 103} 104 105int |
108dumpfs(name) 109 char *name; | 106dumpfs(const char *name) |
110{ 111 ssize_t n; 112 int fd, c, i, j, k, size; 113 114 if ((fd = open(name, O_RDONLY, 0)) < 0) 115 goto err; 116 if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1) 117 goto err; --- 121 unchanged lines hidden (view full) --- 239 240err: if (fd != -1) 241 (void)close(fd); 242 warn("%s", name); 243 return (1); 244}; 245 246int | 107{ 108 ssize_t n; 109 int fd, c, i, j, k, size; 110 111 if ((fd = open(name, O_RDONLY, 0)) < 0) 112 goto err; 113 if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1) 114 goto err; --- 121 unchanged lines hidden (view full) --- 236 237err: if (fd != -1) 238 (void)close(fd); 239 warn("%s", name); 240 return (1); 241}; 242 243int |
247dumpcg(name, fd, c) 248 char *name; 249 int fd, c; | 244dumpcg(const char *name, int fd, int c) |
250{ 251 off_t cur; 252 int i, j; 253 254 printf("\ncg %d:\n", c); 255 if ((cur = lseek(fd, (off_t)(fsbtodb(&afs, cgtod(&afs, c))) * 256 (off_t)dev_bsize, SEEK_SET)) == (off_t)-1) 257 return (1); --- 48 unchanged lines hidden (view full) --- 306 printf(" %d", cg_blks(&afs, &acg, i)[j]); 307 } 308 printf("\n"); 309 } 310 return (0); 311}; 312 313void | 245{ 246 off_t cur; 247 int i, j; 248 249 printf("\ncg %d:\n", c); 250 if ((cur = lseek(fd, (off_t)(fsbtodb(&afs, cgtod(&afs, c))) * 251 (off_t)dev_bsize, SEEK_SET)) == (off_t)-1) 252 return (1); --- 48 unchanged lines hidden (view full) --- 301 printf(" %d", cg_blks(&afs, &acg, i)[j]); 302 } 303 printf("\n"); 304 } 305 return (0); 306}; 307 308void |
314pbits(vp, max) 315 void *vp; 316 int max; | 309pbits(void *vp, int max) |
317{ 318 int i; 319 char *p; 320 int count, j; 321 322 for (count = i = 0, p = vp; i < max; i++) 323 if (isset(p, i)) { 324 if (count) --- 5 unchanged lines hidden (view full) --- 330 i++; 331 if (i != j) 332 printf("-%d", i); 333 } 334 printf("\n"); 335} 336 337void | 310{ 311 int i; 312 char *p; 313 int count, j; 314 315 for (count = i = 0, p = vp; i < max; i++) 316 if (isset(p, i)) { 317 if (count) --- 5 unchanged lines hidden (view full) --- 323 i++; 324 if (i != j) 325 printf("-%d", i); 326 } 327 printf("\n"); 328} 329 330void |
338usage() | 331usage(void) |
339{ 340 (void)fprintf(stderr, "usage: dumpfs filesys | device\n"); 341 exit(1); 342} | 332{ 333 (void)fprintf(stderr, "usage: dumpfs filesys | device\n"); 334 exit(1); 335} |