diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-26 23:21:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-26 23:21:47 +0000 |
commit | f0ed376eda5d5c25d270e5100a881fb2d801bee6 (patch) | |
tree | 79166b700c497fbe798b6031e5bbff97e0933573 /miscutils/mountpoint.c | |
parent | 670a6626cabc1498f32b35f959591f8621d8447e (diff) | |
download | busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.gz busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.bz2 busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.zip |
remove bb_printf and the like
Diffstat (limited to 'miscutils/mountpoint.c')
-rw-r--r-- | miscutils/mountpoint.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c index dbc8fe0e9..b1bcab698 100644 --- a/miscutils/mountpoint.c +++ b/miscutils/mountpoint.c | |||
@@ -13,6 +13,8 @@ | |||
13 | 13 | ||
14 | int mountpoint_main(int argc, char **argv) | 14 | int mountpoint_main(int argc, char **argv) |
15 | { | 15 | { |
16 | struct stat st; | ||
17 | char *arg; | ||
16 | int opt = getopt32(argc, argv, "qdx"); | 18 | int opt = getopt32(argc, argv, "qdx"); |
17 | #define OPT_q (1) | 19 | #define OPT_q (1) |
18 | #define OPT_d (2) | 20 | #define OPT_d (2) |
@@ -20,47 +22,44 @@ int mountpoint_main(int argc, char **argv) | |||
20 | 22 | ||
21 | if (optind != argc - 1) | 23 | if (optind != argc - 1) |
22 | bb_show_usage(); | 24 | bb_show_usage(); |
23 | { | ||
24 | char *arg = argv[optind]; | ||
25 | struct stat st; | ||
26 | 25 | ||
27 | if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) { | 26 | arg = argv[optind]; |
28 | if (opt & OPT_x) { | ||
29 | if (S_ISBLK(st.st_mode)) | ||
30 | { | ||
31 | bb_printf("%u:%u\n", major(st.st_rdev), | ||
32 | minor(st.st_rdev)); | ||
33 | return EXIT_SUCCESS; | ||
34 | } else { | ||
35 | if (opt & OPT_q) | ||
36 | putchar('\n'); | ||
37 | else | ||
38 | bb_error_msg("%s: not a block device", arg); | ||
39 | } | ||
40 | return EXIT_FAILURE; | ||
41 | } else | ||
42 | if (S_ISDIR(st.st_mode)) { | ||
43 | dev_t st_dev = st.st_dev; | ||
44 | ino_t st_ino = st.st_ino; | ||
45 | char *p = xasprintf("%s/..", arg); | ||
46 | 27 | ||
47 | if (stat(p, &st) == 0) { | 28 | if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) { |
48 | short ret = (st_dev != st.st_dev) || | 29 | if (opt & OPT_x) { |
49 | (st_dev == st.st_dev && st_ino == st.st_ino); | 30 | if (S_ISBLK(st.st_mode)) { |
50 | if (opt & OPT_d) | 31 | printf("%u:%u\n", major(st.st_rdev), |
51 | bb_printf("%u:%u\n", major(st_dev), minor(st_dev)); | 32 | minor(st.st_rdev)); |
52 | else if (!(opt & OPT_q)) | 33 | return EXIT_SUCCESS; |
53 | bb_printf("%s is %sa mountpoint\n", arg, ret?"":"not "); | ||
54 | return !ret; | ||
55 | } | ||
56 | } else { | 34 | } else { |
57 | if (!(opt & OPT_q)) | 35 | if (opt & OPT_q) |
58 | bb_error_msg("%s: not a directory", arg); | 36 | putchar('\n'); |
59 | return EXIT_FAILURE; | 37 | else |
38 | bb_error_msg("%s: not a block device", arg); | ||
60 | } | 39 | } |
40 | return EXIT_FAILURE; | ||
41 | } else | ||
42 | if (S_ISDIR(st.st_mode)) { | ||
43 | dev_t st_dev = st.st_dev; | ||
44 | ino_t st_ino = st.st_ino; | ||
45 | char *p = xasprintf("%s/..", arg); | ||
46 | |||
47 | if (stat(p, &st) == 0) { | ||
48 | int ret = (st_dev != st.st_dev) || | ||
49 | (st_dev == st.st_dev && st_ino == st.st_ino); | ||
50 | if (opt & OPT_d) | ||
51 | printf("%u:%u\n", major(st_dev), minor(st_dev)); | ||
52 | else if (!(opt & OPT_q)) | ||
53 | printf("%s is %sa mountpoint\n", arg, ret?"":"not "); | ||
54 | return !ret; | ||
55 | } | ||
56 | } else { | ||
57 | if (!(opt & OPT_q)) | ||
58 | bb_error_msg("%s: not a directory", arg); | ||
59 | return EXIT_FAILURE; | ||
61 | } | 60 | } |
62 | if (!(opt & OPT_q)) | ||
63 | bb_perror_msg("%s", arg); | ||
64 | return EXIT_FAILURE; | ||
65 | } | 61 | } |
62 | if (!(opt & OPT_q)) | ||
63 | bb_perror_msg("%s", arg); | ||
64 | return EXIT_FAILURE; | ||
66 | } | 65 | } |