6 const char block_device_usage[] = "block_device mount-point";
8 static dev_t *my_device;
9 static char *my_device_name;
12 match_mount(const struct FileInfo * i) {
13 if ( S_ISBLK(i->stat.st_mode)
14 && (i->stat.st_rdev == *my_device)) {
15 my_device_name=strdup(i->source);
22 block_device_main(struct FileInfo * i, int argc, char * * argv)
24 char *device_name = block_device(argv[1],i);
25 if ( device_name == NULL )
27 printf("%s\n", device_name);
31 char * block_device(const char *name, struct FileInfo *i)
37 if ( stat(name, &s) ) return (char *) NULL;
39 i=(struct FileInfo*)malloc(sizeof(struct FileInfo));
42 memset((void *)i, 0, sizeof(struct FileInfo));
43 my_device=(dev_t *)malloc(sizeof(dev_t));
44 *my_device = s.st_dev;
45 my_device_name = NULL;
48 i->processDirectoriesAfterTheirContents=1;
49 descend(i, match_mount);
51 if ( my_device_name ) {
52 buf = strdup(my_device_name);
58 ,"Can't find special file for block device %d, %d.\n"
59 ,(int) *my_device >> 8 & 0xff
60 ,(int) *my_device & 0xff);