Fixed the permission denied with the -i option on lstat().
authorFrancois Fleuret <francois@fleuret.org>
Wed, 18 Aug 2010 16:22:53 +0000 (18:22 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Wed, 18 Aug 2010 16:22:53 +0000 (18:22 +0200)
dus.c

diff --git a/dus.c b/dus.c
index 7cdf03e..9d1850c 100644 (file)
--- a/dus.c
+++ b/dus.c
@@ -104,10 +104,14 @@ size_sum_t entry_size(const char *name) {
   result = 0;
 
   if(lstat(name, &dummy) != 0) {
-    fprintf(stderr,
-            "dus: Can not stat %s: %s\n",
-            name, strerror(errno));
-    exit(EXIT_FAILURE);
+    if(!(errno == EACCES && ignore_protected_files)) {
+      fprintf(stderr,
+              "dus: Can not stat %s: %s\n",
+              name, strerror(errno));
+      exit(EXIT_FAILURE);
+    } else {
+      return 0;
+    }
   }
 
   if(S_ISLNK(dummy.st_mode)) {