blob: fdaf102cf3c8446ce112657406eace81e4d064c9 (
plain)
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
|
/*
* getiversion
*
* Get version number for an inode on an ext2 file system.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <stdio.h>
#include <sys/fs/ext2fs.h>
int
main(int argc, char **argv)
{
int i, fd;
u_int32_t vers;
if (argc <= 1) {
fprintf(stderr, "usage: getiversion file ...\n");
return 1;
}
for (i = 1; i < argc; i++) {
if ((fd = open(argv[i], O_RDONLY)) < 0
|| ioctl(fd, EXT2_IOC_GETVERSION, &vers) < 0) {
perror(argv[i]);
continue;
} else {
printf("%-20s %d\n", argv[i], vers);
}
close(fd);
}
return 0;
}
|