2 /* Translate internal FS device number to a /dev/ name. */
11 #include <sys/types.h>
12 #include <minix/config.h>
13 #include <minix/const.h>
15 #define PATH_DEV "/dev"
18 main(int argc
, char *argv
[])
23 if(argc
<= 1 || argc
> 3) {
24 fprintf(stderr
, "Usage: \n"
25 "%s <major> <minor>\n"
26 "%s <devicenumber>\n", argv
[0], argv
[0]);
28 } else if(argc
== 2) dev_n
= atoi(argv
[1]);
29 else if(argc
== 3) dev_n
= (atoi(argv
[1]) << MAJOR
) | atoi(argv
[2]);
31 if(chdir(PATH_DEV
) < 0) {
32 perror(PATH_DEV
" chdir");
36 if(!(dev
=opendir("."))) {
37 perror(". in " PATH_DEV
);
41 while((e
=readdir(dev
))) {
43 if(stat(e
->d_name
, &st
) < 0) {
46 if((st
.st_mode
& (S_IFBLK
| S_IFCHR
)) && dev_n
== st
.st_rdev
) {
47 printf("%s/%s\n", PATH_DEV
, e
->d_name
);