forked from wenjun1055/c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.10.c
28 lines (24 loc) · 669 Bytes
/
4.10.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
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#ifdef SOLARIS
#include <sys/mkdev.h>
#endif
int main(int argc, char **argv)
{
int i;
struct stat buf;
for (i = 1; i < argc; i++) {
printf("%s : ", *(argv + i));
if (stat(*(argv + i), &buf) < 0) {
printf("stat error\n");
continue;
}
printf("dev = %d/%d", major(buf.st_dev), minor(buf.st_dev));
if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode)) {
printf(" (%s) rdev = %d/%d", (S_ISCHR(buf.st_mode)) ? "character" : "block", major(buf.st_dev), minor(buf.st_dev));
}
printf("\n");
}
return 0;
}