Annotation of /trunk/mkinitrd-magellan/klibc/usr/klibc/tests/stat.c
Parent Directory | Revision Log
Revision 1297 -
(hide annotations)
(download)
Fri May 27 15:12:11 2011 UTC (13 years ago) by niro
File MIME type: text/plain
File size: 1690 byte(s)
Fri May 27 15:12:11 2011 UTC (13 years ago) by niro
File MIME type: text/plain
File size: 1690 byte(s)
-updated to klibc-1.5.22 with mntproc definitions patch included
1 | niro | 532 | #include <stdio.h> |
2 | #include <stdlib.h> | ||
3 | #include <sys/stat.h> | ||
4 | #include <sys/sysmacros.h> | ||
5 | #include <sys/types.h> | ||
6 | |||
7 | static void do_stat(const char *path) | ||
8 | { | ||
9 | struct stat st; | ||
10 | |||
11 | if (stat(path, &st)) { | ||
12 | perror(path); | ||
13 | exit(1); | ||
14 | } | ||
15 | |||
16 | printf("Path = %s\n" | ||
17 | " st_dev = %#jx (%u,%u)\n" | ||
18 | " st_ino = %ju\n" | ||
19 | " st_mode = %#jo\n" | ||
20 | " st_nlink = %ju\n" | ||
21 | " st_uid = %ju\n" | ||
22 | " st_gid = %ju\n" | ||
23 | " st_rdev = %#jx (%u,%u)\n" | ||
24 | " st_size = %ju\n" | ||
25 | " st_blksize = %ju\n" | ||
26 | " st_blocks = %ju\n", | ||
27 | path, | ||
28 | (uintmax_t) st.st_dev, major(st.st_dev), minor(st.st_dev), | ||
29 | (uintmax_t) st.st_ino, | ||
30 | (uintmax_t) st.st_mode, | ||
31 | (uintmax_t) st.st_nlink, | ||
32 | (uintmax_t) st.st_uid, | ||
33 | (uintmax_t) st.st_gid, | ||
34 | (uintmax_t) st.st_rdev, major(st.st_rdev), minor(st.st_rdev), | ||
35 | (uintmax_t) st.st_size, | ||
36 | (uintmax_t) st.st_blksize, (uintmax_t) st.st_blocks); | ||
37 | |||
38 | #ifdef _STATBUF_ST_NSEC | ||
39 | printf(" st_atim = %jd.%09u\n" | ||
40 | " st.mtim = %jd.%09u\n" | ||
41 | " st.ctim = %jd.%09u\n", | ||
42 | (uintmax_t) st.st_atim.tv_sec, (unsigned int)st.st_atim.tv_nsec, | ||
43 | (uintmax_t) st.st_mtim.tv_sec, (unsigned int)st.st_mtim.tv_nsec, | ||
44 | (uintmax_t) st.st_ctim.tv_sec, (unsigned int)st.st_ctim.tv_nsec); | ||
45 | #else | ||
46 | printf(" st_atime = %jd\n" | ||
47 | " st.mtime = %jd\n" | ||
48 | " st.ctime = %jd\n", | ||
49 | (uintmax_t) st.st_atime, | ||
50 | (uintmax_t) st.st_mtime, (uintmax_t) st.st_ctime); | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | int main(int argc, char *argv[]) | ||
55 | { | ||
56 | int i; | ||
57 | |||
58 | for (i = 1; i < argc; i++) | ||
59 | do_stat(argv[i]); | ||
60 | |||
61 | return 0; | ||
62 | } |