diff options
author | Ron Yorston <rmy@pobox.com> | 2014-01-05 13:28:51 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-01-05 13:28:51 +0000 |
commit | 5e8fad1617439c6dacfa04e677f4664b0377e340 (patch) | |
tree | 3d9dfd9898f6fcdb46db681fe18584d08592e1ee | |
parent | d9d53743c9407bb5032f4cf1da1582feebdf7c2e (diff) | |
download | busybox-w32-5e8fad1617439c6dacfa04e677f4664b0377e340.tar.gz busybox-w32-5e8fad1617439c6dacfa04e677f4664b0377e340.tar.bz2 busybox-w32-5e8fad1617439c6dacfa04e677f4664b0377e340.zip |
Use the preprocessor to fake st_blocks
-rw-r--r-- | coreutils/du.c | 8 | ||||
-rw-r--r-- | coreutils/ls.c | 5 | ||||
-rw-r--r-- | coreutils/stat.c | 4 | ||||
-rw-r--r-- | include/mingw.h | 7 | ||||
-rw-r--r-- | util-linux/swaponoff.c | 2 |
5 files changed, 8 insertions, 18 deletions
diff --git a/coreutils/du.c b/coreutils/du.c index 05f114cc5..9c6ff8800 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -131,11 +131,7 @@ static unsigned long long du(const char *filename) | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | #if !ENABLE_PLATFORM_MINGW32 | ||
135 | sum = statbuf.st_blocks; | 134 | sum = statbuf.st_blocks; |
136 | #else | ||
137 | sum = (statbuf.st_size+511)/512; | ||
138 | #endif | ||
139 | 135 | ||
140 | if (S_ISLNK(statbuf.st_mode)) { | 136 | if (S_ISLNK(statbuf.st_mode)) { |
141 | if (G.slink_depth > G.du_depth) { /* -H or -L */ | 137 | if (G.slink_depth > G.du_depth) { /* -H or -L */ |
@@ -144,11 +140,7 @@ static unsigned long long du(const char *filename) | |||
144 | G.status = EXIT_FAILURE; | 140 | G.status = EXIT_FAILURE; |
145 | return 0; | 141 | return 0; |
146 | } | 142 | } |
147 | #if !ENABLE_PLATFORM_MINGW32 | ||
148 | sum = statbuf.st_blocks; | 143 | sum = statbuf.st_blocks; |
149 | #else | ||
150 | sum = (statbuf.st_size+511)/512; | ||
151 | #endif | ||
152 | if (G.slink_depth == 1) { | 144 | if (G.slink_depth == 1) { |
153 | /* Convert -H to -L */ | 145 | /* Convert -H to -L */ |
154 | G.slink_depth = INT_MAX; | 146 | G.slink_depth = INT_MAX; |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 2c5fda96a..166473d4d 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -754,12 +754,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f | |||
754 | cur->dn_ctime = statbuf.st_ctime ; | 754 | cur->dn_ctime = statbuf.st_ctime ; |
755 | #endif | 755 | #endif |
756 | cur->dn_ino = statbuf.st_ino ; | 756 | cur->dn_ino = statbuf.st_ino ; |
757 | #if !ENABLE_PLATFORM_MINGW32 | ||
758 | cur->dn_blocks = statbuf.st_blocks; | 757 | cur->dn_blocks = statbuf.st_blocks; |
759 | #else | ||
760 | /* MinGW does not have st_blocks */ | ||
761 | cur->dn_blocks = 0; | ||
762 | #endif | ||
763 | cur->dn_nlink = statbuf.st_nlink ; | 758 | cur->dn_nlink = statbuf.st_nlink ; |
764 | cur->dn_uid = statbuf.st_uid ; | 759 | cur->dn_uid = statbuf.st_uid ; |
765 | cur->dn_gid = statbuf.st_gid ; | 760 | cur->dn_gid = statbuf.st_gid ; |
diff --git a/coreutils/stat.c b/coreutils/stat.c index 0d13fdf65..6cee2ce23 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
@@ -343,11 +343,7 @@ static void FAST_FUNC print_stat(char *pformat, const char m, | |||
343 | printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE | 343 | printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE |
344 | } else if (m == 'b') { | 344 | } else if (m == 'b') { |
345 | strcat(pformat, "llu"); | 345 | strcat(pformat, "llu"); |
346 | #if !ENABLE_PLATFORM_MINGW32 | ||
347 | printf(pformat, (unsigned long long) statbuf->st_blocks); | 346 | printf(pformat, (unsigned long long) statbuf->st_blocks); |
348 | #else | ||
349 | printf(pformat, (unsigned long long) ((statbuf->st_size+511)/512)); | ||
350 | #endif | ||
351 | } else if (m == 'o') { | 347 | } else if (m == 'o') { |
352 | strcat(pformat, "lu"); | 348 | strcat(pformat, "lu"); |
353 | #if !ENABLE_PLATFORM_MINGW32 | 349 | #if !ENABLE_PLATFORM_MINGW32 |
diff --git a/include/mingw.h b/include/mingw.h index c4748735d..e8c55f646 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -248,6 +248,13 @@ int mingw_fstat(int fd, struct stat *buf); | |||
248 | #define lstat mingw_lstat | 248 | #define lstat mingw_lstat |
249 | #define _stati64(x,y) mingw_stat(x,y) | 249 | #define _stati64(x,y) mingw_stat(x,y) |
250 | 250 | ||
251 | /* The Windows stat structure doesn't have the st_blocks member. This | ||
252 | * macro calculates st_blocks from st_size. It would be better if we | ||
253 | * could put brackets around it but most references to st_blocks in BusyBox | ||
254 | * are pretty simple and work without brackets. | ||
255 | */ | ||
256 | #define st_blocks st_size+511>>9 | ||
257 | |||
251 | /* | 258 | /* |
252 | * sys/sysmacros.h | 259 | * sys/sysmacros.h |
253 | */ | 260 | */ |
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 3f223343e..94565f855 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
@@ -60,7 +60,7 @@ static int swap_enable_disable(char *device) | |||
60 | #if ENABLE_DESKTOP | 60 | #if ENABLE_DESKTOP |
61 | /* test for holes */ | 61 | /* test for holes */ |
62 | if (S_ISREG(st.st_mode)) | 62 | if (S_ISREG(st.st_mode)) |
63 | if (st.st_blocks * (off_t)512 < st.st_size) | 63 | if ((st.st_blocks) * (off_t)512 < st.st_size) |
64 | bb_error_msg("warning: swap file has holes"); | 64 | bb_error_msg("warning: swap file has holes"); |
65 | #endif | 65 | #endif |
66 | 66 | ||