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 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 |
74int dumpfs(const char *); 75int dumpcg(const char *, int, int); 76void pbits(void *, int); 77void usage(void) __dead2; |
78 79int |
80main(int argc, char *argv[]) |
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 |
106dumpfs(const char *name) |
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 |
244dumpcg(const char *name, int fd, int c) |
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 |
309pbits(void *vp, int max) |
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 |
331usage(void) |
332{ 333 (void)fprintf(stderr, "usage: dumpfs filesys | device\n"); 334 exit(1); 335} |