1 |
+ |
/* $MidnightBSD$ */ |
2 |
|
/* $OpenBSD: fsirand.c,v 1.9 1997/02/28 00:46:33 millert Exp $ */ |
3 |
|
|
4 |
|
/* |
33 |
|
|
34 |
|
#ifndef lint |
35 |
|
static const char rcsid[] = |
36 |
< |
"$MidnightBSD$"; |
36 |
> |
"$FreeBSD: stable/10/sbin/fsirand/fsirand.c 322860 2017-08-24 21:44:23Z mckusick $"; |
37 |
|
#endif /* not lint */ |
38 |
|
|
39 |
|
#include <sys/param.h> |
39 |
– |
#include <sys/disklabel.h> |
40 |
|
#include <sys/resource.h> |
41 |
|
|
42 |
|
#include <ufs/ufs/dinode.h> |
60 |
|
*/ |
61 |
|
static int sblock_try[] = SBLOCKSEARCH; |
62 |
|
|
63 |
< |
int printonly = 0, force = 0, ignorelabel = 0; |
63 |
> |
static int printonly = 0, force = 0, ignorelabel = 0; |
64 |
|
|
65 |
|
int |
66 |
|
main(int argc, char *argv[]) |
120 |
|
char sbuf[SBLOCKSIZE], sbuftmp[SBLOCKSIZE]; |
121 |
|
int i, devfd, n, cg; |
122 |
|
u_int32_t bsize = DEV_BSIZE; |
123 |
– |
struct disklabel label; |
123 |
|
|
124 |
|
if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) { |
125 |
|
warn("can't open %s", device); |
126 |
|
return (1); |
127 |
|
} |
128 |
|
|
130 |
– |
/* Get block size (usually 512) from disklabel if possible */ |
131 |
– |
if (!ignorelabel) { |
132 |
– |
if (ioctl(devfd, DIOCGDINFO, &label) < 0) |
133 |
– |
warn("can't read disklabel, using sector size of %d", |
134 |
– |
bsize); |
135 |
– |
else |
136 |
– |
bsize = label.d_secsize; |
137 |
– |
} |
138 |
– |
|
129 |
|
dp1 = NULL; |
130 |
|
dp2 = NULL; |
131 |
|
|
264 |
|
dp2 = &((struct ufs2_dinode *)inodebuf)[n]; |
265 |
|
if (inumber >= ROOTINO) { |
266 |
|
if (printonly) |
267 |
< |
(void)printf("ino %d gen %08x\n", |
268 |
< |
inumber, |
267 |
> |
(void)printf("ino %ju gen %08x\n", |
268 |
> |
(uintmax_t)inumber, |
269 |
|
sblock->fs_magic == FS_UFS1_MAGIC ? |
270 |
|
dp1->di_gen : dp2->di_gen); |
271 |
|
else if (sblock->fs_magic == FS_UFS1_MAGIC) |