aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>1999-12-10 07:40:08 +0000
committerJohn Beppu <beppu@lbox.org>1999-12-10 07:40:08 +0000
commit9835541c540a5009c13655f72eb7465c5dbd854b (patch)
tree1b2eaa19e4688873ab2a5b754ae0b2c4b36c301f
parent21818c8a80994e71c3b518e332de0e16d9280275 (diff)
downloadbusybox-w32-9835541c540a5009c13655f72eb7465c5dbd854b.tar.gz
busybox-w32-9835541c540a5009c13655f72eb7465c5dbd854b.tar.bz2
busybox-w32-9835541c540a5009c13655f72eb7465c5dbd854b.zip
Fixed bug when dealing with files specified
on the command line that didn't exist.
-rw-r--r--coreutils/du.c12
-rw-r--r--du.c12
2 files changed, 18 insertions, 6 deletions
diff --git a/coreutils/du.c b/coreutils/du.c
index 79bf0ba86..76ea6d0cb 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -26,6 +26,7 @@
26#include <fcntl.h> 26#include <fcntl.h>
27#include <dirent.h> 27#include <dirent.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <errno.h>
29#if 0 30#if 0
30#include <unistd.h> 31#include <unistd.h>
31#include <sys/stat.h> 32#include <sys/stat.h>
@@ -49,7 +50,10 @@ du(char *filename)
49 struct stat statbuf; 50 struct stat statbuf;
50 size_t sum; 51 size_t sum;
51 52
52 if ((lstat(filename, &statbuf)) != 0) { return 0; } 53 if ((lstat(filename, &statbuf)) != 0) {
54 fprintf(stdout, "du: %s: %s\n", filename, strerror(errno));
55 return 0;
56 }
53 sum = statbuf.st_blocks; 57 sum = statbuf.st_blocks;
54 58
55 if (S_ISDIR(statbuf.st_mode)) { 59 if (S_ISDIR(statbuf.st_mode)) {
@@ -104,12 +108,14 @@ du_main(int argc, char **argv)
104 if (i >= argc) { 108 if (i >= argc) {
105 du("."); 109 du(".");
106 } else { 110 } else {
111 int sum;
107 for ( ; i < argc; i++) { 112 for ( ; i < argc; i++) {
108 printf("%-7d %s\n", du(argv[i]) >> 1, argv[i]); 113 sum = du(argv[i]) >> 1;
114 if (sum) printf("%-7d %s\n", du(argv[i]) >> 1, argv[i]);
109 } 115 }
110 } 116 }
111 117
112 exit(0); 118 exit(0);
113} 119}
114 120
115/* $Id: du.c,v 1.3 1999/12/10 06:45:42 andersen Exp $ */ 121/* $Id: du.c,v 1.4 1999/12/10 07:40:08 beppu Exp $ */
diff --git a/du.c b/du.c
index 79bf0ba86..76ea6d0cb 100644
--- a/du.c
+++ b/du.c
@@ -26,6 +26,7 @@
26#include <fcntl.h> 26#include <fcntl.h>
27#include <dirent.h> 27#include <dirent.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <errno.h>
29#if 0 30#if 0
30#include <unistd.h> 31#include <unistd.h>
31#include <sys/stat.h> 32#include <sys/stat.h>
@@ -49,7 +50,10 @@ du(char *filename)
49 struct stat statbuf; 50 struct stat statbuf;
50 size_t sum; 51 size_t sum;
51 52
52 if ((lstat(filename, &statbuf)) != 0) { return 0; } 53 if ((lstat(filename, &statbuf)) != 0) {
54 fprintf(stdout, "du: %s: %s\n", filename, strerror(errno));
55 return 0;
56 }
53 sum = statbuf.st_blocks; 57 sum = statbuf.st_blocks;
54 58
55 if (S_ISDIR(statbuf.st_mode)) { 59 if (S_ISDIR(statbuf.st_mode)) {
@@ -104,12 +108,14 @@ du_main(int argc, char **argv)
104 if (i >= argc) { 108 if (i >= argc) {
105 du("."); 109 du(".");
106 } else { 110 } else {
111 int sum;
107 for ( ; i < argc; i++) { 112 for ( ; i < argc; i++) {
108 printf("%-7d %s\n", du(argv[i]) >> 1, argv[i]); 113 sum = du(argv[i]) >> 1;
114 if (sum) printf("%-7d %s\n", du(argv[i]) >> 1, argv[i]);
109 } 115 }
110 } 116 }
111 117
112 exit(0); 118 exit(0);
113} 119}
114 120
115/* $Id: du.c,v 1.3 1999/12/10 06:45:42 andersen Exp $ */ 121/* $Id: du.c,v 1.4 1999/12/10 07:40:08 beppu Exp $ */