From 7918563eae46561a407555ee17ffa0561e796b4a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 21 Oct 2023 16:02:07 +0300 Subject: [PATCH] du --- coreutils/du.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/coreutils/du.c b/coreutils/du.c index 84db165..49c529d 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -10,7 +10,6 @@ unsigned int h_flag; unsigned int s_flag; unsigned int b_flag; unsigned int m_flag; -unsigned int L_flag; void print(long size, const char *filename) { /* Kb */ @@ -25,7 +24,7 @@ void print(long size, const char *filename) { } long du(const char *path, int recurs_flag) { - long sum; + long sum = 0; struct stat sb; if (lstat(path, &sb) != 0) { @@ -59,12 +58,13 @@ long du(const char *path, int recurs_flag) { closedir(dp); - if (s_flag) - if (!recurs_flag) { - print(sum, path); + if (!s_flag && recurs_flag) { + print(sum, path); + return sum; } - else + /* Silent mode */ + else if (!recurs_flag) print(sum, path); } @@ -98,11 +98,8 @@ int main(const int argc, const char **argv) { m_flag = 1; } - else if (!strcmp(argv[i], "-L")) - L_flag = 1; - else if (!strcmp(argv[i], "--help")) { - printf("du [-h (Sizes in human readable format (e.g., 1K 243M 2G))] [-s (Display only a total for each argument)] [-b (Apparent size)] [-L (Follow all symlinks)] [-m (Size in megabyte)] [file file2...]\n"); + printf("du [-h (Sizes in human readable format (e.g., 1K 243M 2G))] [-s (Display only a total for each argument)] [-b (Apparent size)] [-m (Size in megabyte)] [file file2...]\n"); return 0; } }