15 #include <hammer2/hammer2_disk.h>
18 int fd; /* Device fd */
19 struct hammer2_blockref sroot; /* Superroot blockref */
23 struct hammer2_inode_data dat; /* raw inode data */
24 off_t doff; /* disk inode offset */
28 struct hammer2_blockref ref;
36 struct hammer2_volume_data volhdr;
40 rc = pread(hfs->fd, &volhdr, HAMMER2_VOLUME_SIZE, 0);
41 if (volhdr.magic == HAMMER2_VOLUME_ID_HBO) {
42 printf("Valid HAMMER2 filesystem\n");
47 hfs->sroot = volhdr.sroot_blockref;
51 shread(hfs, ino, buf, off, len)
59 * Read [off, off+len) from inode ino rather than from disk
60 * offsets; correctly decodes blockrefs/indirs/...
64 struct inode *hlookup1(hfs, ino, name)
69 static struct inode filino;
73 bzero(&filino, sizeof(struct inode));
77 off += sizeof(struct hammer2_inode_data))
79 rc = shread(hfs, ino, &filino.dat, off,
80 sizeof(struct hammer2_inode_data));
81 if (rc != sizeof(struct hammer2_inode_data))
83 if (strcmp(name, &filino.dat.filename) == 0)
90 struct inode *hlookup(hfs, name)
94 /* Name is of form /SUPERROOT/a/b/c/file */
98 void hstat(hfs, ino, sb)
110 struct hammer2 hammer2;
116 fprintf(stderr, "usage: hammer2 <dev>\n");
120 hammer2.fd = open(argv[1], O_RDONLY);
121 if (hammer2.fd < 0) {
122 fprintf(stderr, "unable to open %s\n", argv[1]);
126 if (hinit(&hammer2)) {
127 fprintf(stderr, "invalid fs\n");
132 for (i = 2; i < argc; i++) {
133 ino = hlookup(&hammer2, argv[i]);
135 fprintf(stderr, "hlookup %s\n", argv[i]);
138 hstat(&hammer2, ino, &sb);
140 printf("%s %lld", argv[i], sb.st_size);