blob: 895f3f9a22eb0d3846acba7a6dbaf2b76caba362 (
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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#ifndef FIBMAP
#define FIBMAP 1
#endif
int main ( int argc , char ** argv )
{
int fd,lba=0;
if (argc!=2) {
printf("Bad usage.\n");
return 1;
}
if ((fd = open(argv[1], O_RDONLY)) == -1) {
printf("Cannot open file %s: %s\n",
argv[1] ? argv[1] : "(NULL)", strerror(errno));
return 1;
}
if (ioctl(fd, FIBMAP, &lba) != 0) {
printf("fibmap ioctl: %s (Hint: %s is not suid root?)\n",strerror(errno),argv[0]);
close(fd);
return 1;
}
close(fd);
printf("%d\n",lba);
return 0;
}
|