Deleted Added
full compact
dumpfs.c (19074) dumpfs.c (23673)
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

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

33
34#ifndef lint
35static char copyright[] =
36"@(#) Copyright (c) 1983, 1992, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
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

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

33
34#ifndef lint
35static char copyright[] =
36"@(#) Copyright (c) 1983, 1992, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41static char sccsid[] = "@(#)dumpfs.c 8.2 (Berkeley) 2/2/94";
41static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95";
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/time.h>
46
47#include <ufs/ufs/dinode.h>
48#include <ufs/ffs/fs.h>
49
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/time.h>
46
47#include <ufs/ufs/dinode.h>
48#include <ufs/ffs/fs.h>
49
50#include <unistd.h>
51#include <fcntl.h>
50#include <err.h>
52#include <errno.h>
51#include <errno.h>
52#include <fcntl.h>
53#include <fstab.h>
54#include <stdio.h>
55#include <stdlib.h>
56#include <string.h>
53#include <fstab.h>
54#include <stdio.h>
55#include <stdlib.h>
56#include <string.h>
57#include <unistd.h>
57
58union {
59 struct fs fs;
60 char pad[MAXBSIZE];
61} fsun;
62#define afs fsun.fs
63
64union {

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

77int
78main(argc, argv)
79 int argc;
80 char *argv[];
81{
82 register struct fstab *fs;
83 int ch, eval;
84
58
59union {
60 struct fs fs;
61 char pad[MAXBSIZE];
62} fsun;
63#define afs fsun.fs
64
65union {

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

78int
79main(argc, argv)
80 int argc;
81 char *argv[];
82{
83 register struct fstab *fs;
84 int ch, eval;
85
85 while ((ch = getopt(argc, argv, "")) != EOF)
86 while ((ch = getopt(argc, argv, "")) != -1)
86 switch(ch) {
87 case '?':
88 default:
89 usage();
90 }
91 argc -= optind;
92 argv += optind;
93

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

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;
115 if (read(fd, &afs, SBSIZE) != SBSIZE)
116 goto err;
117
87 switch(ch) {
88 case '?':
89 default:
90 usage();
91 }
92 argc -= optind;
93 argv += optind;
94

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

111
112 if ((fd = open(name, O_RDONLY, 0)) < 0)
113 goto err;
114 if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1)
115 goto err;
116 if (read(fd, &afs, SBSIZE) != SBSIZE)
117 goto err;
118
118 if (afs.fs_magic != FS_MAGIC) {
119 warnx("%s: superblock has bad magic number, skipping.",
120 name);
121 (void) close(fd);
122 return (1);
123 }
124
119 if (afs.fs_magic != FS_MAGIC) {
120 warnx("%s: superblock has bad magic number, skipped", name);
121 (void)close(fd);
122 return (1);
123 }
124
125 if (afs.fs_postblformat == FS_42POSTBLFMT)
126 afs.fs_nrpos = 8;
127 dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1);
128 printf("magic\t%x\ttime\t%s", afs.fs_magic,
129 ctime(&afs.fs_time));
130 printf("cylgrp\t%s\tinodes\t%s\n",
131 afs.fs_postblformat == FS_42POSTBLFMT ? "static" : "dynamic",
132 afs.fs_inodefmt < FS_44INODEFMT ? "4.2/4.3BSD" : "4.4BSD");

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

214 for (i = 0; i < afs.fs_ncg; i++)
215 if (dumpcg(name, fd, i))
216 goto err;
217 (void)close(fd);
218 return (0);
219
220err: if (fd != -1)
221 (void)close(fd);
125 if (afs.fs_postblformat == FS_42POSTBLFMT)
126 afs.fs_nrpos = 8;
127 dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1);
128 printf("magic\t%x\ttime\t%s", afs.fs_magic,
129 ctime(&afs.fs_time));
130 printf("cylgrp\t%s\tinodes\t%s\n",
131 afs.fs_postblformat == FS_42POSTBLFMT ? "static" : "dynamic",
132 afs.fs_inodefmt < FS_44INODEFMT ? "4.2/4.3BSD" : "4.4BSD");

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

214 for (i = 0; i < afs.fs_ncg; i++)
215 if (dumpcg(name, fd, i))
216 goto err;
217 (void)close(fd);
218 return (0);
219
220err: if (fd != -1)
221 (void)close(fd);
222 (void)fprintf(stderr, "dumpfs: %s: %s\n", name, strerror(errno));
222 warn("%s", name);
223 return (1);
224};
225
226int
227dumpcg(name, fd, c)
228 char *name;
229 int fd, c;
230{
231 off_t cur;
232 int i, j;
233
234 printf("\ncg %d:\n", c);
235 if ((cur = lseek(fd, (off_t)(fsbtodb(&afs, cgtod(&afs, c))) *
236 (off_t)dev_bsize, SEEK_SET)) == (off_t)-1)
237 return (1);
238 if (read(fd, &acg, afs.fs_bsize) != afs.fs_bsize) {
223 return (1);
224};
225
226int
227dumpcg(name, fd, c)
228 char *name;
229 int fd, c;
230{
231 off_t cur;
232 int i, j;
233
234 printf("\ncg %d:\n", c);
235 if ((cur = lseek(fd, (off_t)(fsbtodb(&afs, cgtod(&afs, c))) *
236 (off_t)dev_bsize, SEEK_SET)) == (off_t)-1)
237 return (1);
238 if (read(fd, &acg, afs.fs_bsize) != afs.fs_bsize) {
239 (void)fprintf(stderr, "dumpfs: %s: error reading cg\n", name);
239 warnx("%s: error reading cg", name);
240 return (1);
241 }
242 printf("magic\t%x\ttell\t%qx\ttime\t%s",
243 afs.fs_postblformat == FS_42POSTBLFMT ?
244 ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
245 cur, ctime(&acg.cg_time));
246 printf("cgx\t%d\tncyl\t%d\tniblk\t%d\tndblk\t%d\n",
247 acg.cg_cgx, acg.cg_ncyl, acg.cg_niblk, acg.cg_ndblk);

--- 75 unchanged lines hidden ---
240 return (1);
241 }
242 printf("magic\t%x\ttell\t%qx\ttime\t%s",
243 afs.fs_postblformat == FS_42POSTBLFMT ?
244 ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
245 cur, ctime(&acg.cg_time));
246 printf("cgx\t%d\tncyl\t%d\tniblk\t%d\tndblk\t%d\n",
247 acg.cg_cgx, acg.cg_ncyl, acg.cg_niblk, acg.cg_ndblk);

--- 75 unchanged lines hidden ---