/
e3showinode.c
48 lines (39 loc) · 879 Bytes
/
e3showinode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// e3showinode
// Utilities to make sense out of really damaged ext2/ext3 filesystems.
//
// If you have to make an assumption, write it down. Better assumptions may
// lead to better grades.
#include <stdlib.h>
#include <stdio.h>
#include "e3tools.h"
#include "superblock.h"
int main(int argc, char **argv)
{
e3tools_t e3t;
struct ext2_inode inode;
int inum;
int arg;
if (e3tools_init(&e3t, &argc, &argv) < 0)
{
printf("e3tools initialization failed -- bailing out\n");
return 1;
}
if (argc < 2)
{
printf("Usage: %s e3tools_options inode_number\n", argv[0]);
e3tools_usage();
exit(1);
}
for (arg = 1; arg < argc; arg++)
{
inum = strtoll(argv[arg], NULL, 0);
if (inode_find(&e3t, inum, &inode) < 0)
{
printf("Error reading inode %d\n", inum);
exit(1);
}
inode_print(&e3t, &inode, inum);
}
e3tools_close(&e3t);
return 0;
}