Fix indentation in du(1)
This commit is contained in:
parent
9e321b69d2
commit
a6e5696cbd
18
du.c
18
du.c
@ -109,12 +109,16 @@ du(const char *path)
|
||||
eprintf("stat: %s:", path);
|
||||
n = 512 * st.st_blocks / blksize;
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
goto done;
|
||||
|
||||
dp = opendir(path);
|
||||
if (!dp) {
|
||||
fprintf(stderr, "opendir: %s: %s\n", path,
|
||||
strerror(errno));
|
||||
} else {
|
||||
goto done;
|
||||
}
|
||||
|
||||
cwd = push(path);
|
||||
while ((dent = readdir(dp))) {
|
||||
if (strcmp(dent->d_name, ".") == 0 ||
|
||||
@ -124,23 +128,23 @@ du(const char *path)
|
||||
eprintf("stat: %s:", dent->d_name);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
n += du(dent->d_name);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
m = 512 * st.st_blocks / blksize;
|
||||
n += m;
|
||||
if (aflag && !sflag) {
|
||||
if (S_ISLNK(st.st_mode))
|
||||
snprintf(file, sizeof(file), "%s/%s", cwd, dent->d_name);
|
||||
snprintf(file, sizeof(file), "%s/%s",
|
||||
cwd, dent->d_name);
|
||||
else
|
||||
realpath(dent->d_name, file);
|
||||
print(m, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
pop(cwd);
|
||||
closedir(dp);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (!sflag)
|
||||
print(n, realpath(path, file));
|
||||
return n;
|
||||
|
Loading…
Reference in New Issue
Block a user