aboutsummaryrefslogtreecommitdiff
path: root/coreutils/df.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 23:21:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 23:21:47 +0000
commitf0ed376eda5d5c25d270e5100a881fb2d801bee6 (patch)
tree79166b700c497fbe798b6031e5bbff97e0933573 /coreutils/df.c
parent670a6626cabc1498f32b35f959591f8621d8447e (diff)
downloadbusybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.gz
busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.bz2
busybox-w32-f0ed376eda5d5c25d270e5100a881fb2d801bee6.zip
remove bb_printf and the like
Diffstat (limited to 'coreutils/df.c')
-rw-r--r--coreutils/df.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index 94ead32eb..c569dae33 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -51,25 +51,26 @@ int df_main(int argc, char **argv)
51#ifdef CONFIG_FEATURE_HUMAN_READABLE 51#ifdef CONFIG_FEATURE_HUMAN_READABLE
52 opt_complementary = "h-km:k-hm:m-hk"; 52 opt_complementary = "h-km:k-hm:m-hk";
53 opt = getopt32(argc, argv, "hmk"); 53 opt = getopt32(argc, argv, "hmk");
54 if(opt & 1) { 54 if (opt & 1) {
55 df_disp_hr = 0; 55 df_disp_hr = 0;
56 disp_units_hdr = " Size"; 56 disp_units_hdr = " Size";
57 } 57 }
58 if(opt & 2) { 58 if (opt & 2) {
59 df_disp_hr = MEGABYTE; 59 df_disp_hr = MEGABYTE;
60 disp_units_hdr = "1M-blocks"; 60 disp_units_hdr = "1M-blocks";
61 } 61 }
62#else 62#else
63 opt = getopt32(argc, argv, "k"); 63 opt = getopt32(argc, argv, "k");
64#endif 64#endif
65 65
66 bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", 66 printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
67 "", disp_units_hdr); 67 "", disp_units_hdr);
68 68
69 mount_table = NULL; 69 mount_table = NULL;
70 argv += optind; 70 argv += optind;
71 if (optind >= argc) { 71 if (optind >= argc) {
72 if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) { 72 mount_table = setmntent(bb_path_mtab_file, "r");
73 if (!mount_table) {
73 bb_perror_msg_and_die(bb_path_mtab_file); 74 bb_perror_msg_and_die(bb_path_mtab_file);
74 } 75 }
75 } 76 }
@@ -79,16 +80,19 @@ int df_main(int argc, char **argv)
79 const char *mount_point; 80 const char *mount_point;
80 81
81 if (mount_table) { 82 if (mount_table) {
82 if (!(mount_entry = getmntent(mount_table))) { 83 mount_entry = getmntent(mount_table);
84 if (!mount_entry) {
83 endmntent(mount_table); 85 endmntent(mount_table);
84 break; 86 break;
85 } 87 }
86 } else { 88 } else {
87 if (!(mount_point = *argv++)) { 89 mount_point = *argv++;
90 if (!mount_point) {
88 break; 91 break;
89 } 92 }
90 if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) { 93 mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
91 bb_error_msg("%s: can't find mount point.", mount_point); 94 if (!mount_entry) {
95 bb_error_msg("%s: can't find mount point", mount_point);
92 SET_ERROR: 96 SET_ERROR:
93 status = EXIT_FAILURE; 97 status = EXIT_FAILURE;
94 continue; 98 continue;
@@ -108,8 +112,8 @@ int df_main(int argc, char **argv)
108 blocks_percent_used = 0; 112 blocks_percent_used = 0;
109 if (blocks_used + s.f_bavail) { 113 if (blocks_used + s.f_bavail) {
110 blocks_percent_used = (((long long) blocks_used) * 100 114 blocks_percent_used = (((long long) blocks_used) * 100
111 + (blocks_used + s.f_bavail)/2 115 + (blocks_used + s.f_bavail)/2
112 ) / (blocks_used + s.f_bavail); 116 ) / (blocks_used + s.f_bavail);
113 } 117 }
114 118
115 if (strcmp(device, "rootfs") == 0) { 119 if (strcmp(device, "rootfs") == 0) {
@@ -117,24 +121,25 @@ int df_main(int argc, char **argv)
117 } else if (strcmp(device, "/dev/root") == 0) { 121 } else if (strcmp(device, "/dev/root") == 0) {
118 /* Adjusts device to be the real root device, 122 /* Adjusts device to be the real root device,
119 * or leaves device alone if it can't find it */ 123 * or leaves device alone if it can't find it */
120 if ((device = find_block_device("/")) == NULL) { 124 device = find_block_device("/");
125 if (!device) {
121 goto SET_ERROR; 126 goto SET_ERROR;
122 } 127 }
123 } 128 }
124 129
125#ifdef CONFIG_FEATURE_HUMAN_READABLE 130#ifdef CONFIG_FEATURE_HUMAN_READABLE
126 bb_printf("%-20s %9s ", device, 131 printf("%-20s %9s ", device,
127 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); 132 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
128 133
129 bb_printf("%9s ", 134 printf("%9s ",
130 make_human_readable_str( (s.f_blocks - s.f_bfree), 135 make_human_readable_str( (s.f_blocks - s.f_bfree),
131 s.f_bsize, df_disp_hr)); 136 s.f_bsize, df_disp_hr));
132 137
133 bb_printf("%9s %3ld%% %s\n", 138 printf("%9s %3ld%% %s\n",
134 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), 139 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
135 blocks_percent_used, mount_point); 140 blocks_percent_used, mount_point);
136#else 141#else
137 bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", 142 printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
138 device, 143 device,
139 kscale(s.f_blocks, s.f_bsize), 144 kscale(s.f_blocks, s.f_bsize),
140 kscale(s.f_blocks-s.f_bfree, s.f_bsize), 145 kscale(s.f_blocks-s.f_bfree, s.f_bsize),
@@ -145,5 +150,5 @@ int df_main(int argc, char **argv)
145 150
146 } while (1); 151 } while (1);
147 152
148 bb_fflush_stdout_and_exit(status); 153 fflush_stdout_and_exit(status);
149} 154}