diff options
author | kraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-12-06 15:55:23 +0000 |
---|---|---|
committer | kraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-12-06 15:55:23 +0000 |
commit | cb7bf618f2fa0efe53799d54b12b3dfac6bacc46 (patch) | |
tree | e02182bd51b722505acc3a0b571d25e147a2efca /df.c | |
parent | 8cef3856449656f06c84d19795a7b883e1bbeb15 (diff) | |
download | busybox-w32-cb7bf618f2fa0efe53799d54b12b3dfac6bacc46.tar.gz busybox-w32-cb7bf618f2fa0efe53799d54b12b3dfac6bacc46.tar.bz2 busybox-w32-cb7bf618f2fa0efe53799d54b12b3dfac6bacc46.zip |
Fix exit status on failure.
git-svn-id: svn://busybox.net/trunk/busybox@1383 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'df.c')
-rw-r--r-- | df.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint) | |||
36 | long blocks_percent_used; | 36 | long blocks_percent_used; |
37 | 37 | ||
38 | if (statfs(mountPoint, &s) != 0) { | 38 | if (statfs(mountPoint, &s) != 0) { |
39 | perror(mountPoint); | 39 | perrorMsg("%s", mountPoint); |
40 | return FALSE; | 40 | return FALSE; |
41 | } | 41 | } |
42 | 42 | ||
@@ -63,12 +63,13 @@ static int df(char *device, const char *mountPoint) | |||
63 | 63 | ||
64 | extern int df_main(int argc, char **argv) | 64 | extern int df_main(int argc, char **argv) |
65 | { | 65 | { |
66 | int status = EXIT_SUCCESS; | ||
67 | |||
66 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", | 68 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", |
67 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); | 69 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); |
68 | 70 | ||
69 | if (argc > 1) { | 71 | if (argc > 1) { |
70 | struct mntent *mountEntry; | 72 | struct mntent *mountEntry; |
71 | int status; | ||
72 | 73 | ||
73 | if (**(argv + 1) == '-') { | 74 | if (**(argv + 1) == '-') { |
74 | usage(df_usage); | 75 | usage(df_usage); |
@@ -76,32 +77,30 @@ extern int df_main(int argc, char **argv) | |||
76 | while (argc > 1) { | 77 | while (argc > 1) { |
77 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { | 78 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { |
78 | errorMsg("%s: can't find mount point.\n", argv[1]); | 79 | errorMsg("%s: can't find mount point.\n", argv[1]); |
79 | exit(FALSE); | 80 | status = EXIT_FAILURE; |
80 | } | 81 | } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
81 | status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 82 | status = EXIT_FAILURE; |
82 | if (status != TRUE) | ||
83 | return EXIT_FAILURE; | ||
84 | argc--; | 83 | argc--; |
85 | argv++; | 84 | argv++; |
86 | } | 85 | } |
87 | return EXIT_SUCCESS; | ||
88 | } else { | 86 | } else { |
89 | FILE *mountTable; | 87 | FILE *mountTable; |
90 | struct mntent *mountEntry; | 88 | struct mntent *mountEntry; |
91 | 89 | ||
92 | mountTable = setmntent(mtab_file, "r"); | 90 | mountTable = setmntent(mtab_file, "r"); |
93 | if (mountTable == 0) { | 91 | if (mountTable == 0) { |
94 | perror(mtab_file); | 92 | perrorMsg("%s", mtab_file); |
95 | return EXIT_FAILURE; | 93 | return EXIT_FAILURE; |
96 | } | 94 | } |
97 | 95 | ||
98 | while ((mountEntry = getmntent(mountTable))) { | 96 | while ((mountEntry = getmntent(mountTable))) { |
99 | df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 97 | if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
98 | status = EXIT_FAILURE; | ||
100 | } | 99 | } |
101 | endmntent(mountTable); | 100 | endmntent(mountTable); |
102 | } | 101 | } |
103 | 102 | ||
104 | return EXIT_FAILURE; | 103 | return status; |
105 | } | 104 | } |
106 | 105 | ||
107 | /* | 106 | /* |