57 lines
1.0 KiB
Plaintext
57 lines
1.0 KiB
Plaintext
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <sys/stat.h>
|
|
|
|
unsigned int h_flag;
|
|
unsigned int s_flag;
|
|
unsigned int b_flag;
|
|
unsigned int m_flag;
|
|
unsigned int L_flag;
|
|
|
|
int du(const char *path) {
|
|
struct stat sb;
|
|
if (lstat(path, &sb)) {
|
|
fprintf(stderr, "du: lstat() %s\n", strerror(errno));
|
|
return 0;
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main(const int argc, const char **argv) {
|
|
|
|
int i;
|
|
for (i = 1; i < argc; i++) {
|
|
if (argv[i][0] != '-')
|
|
break;
|
|
|
|
else if (!strcmp(argv[i], "-h"))
|
|
h_flag = 1;
|
|
|
|
else if (!strcmp(argv[i], "-s"))
|
|
s_flag = 1;
|
|
|
|
else if (!strcmp(argv[i], "-b"))
|
|
b_flag = 1;
|
|
|
|
else if (!strcmp(argv[i], "-m"))
|
|
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");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
for (; i < argc; i++)
|
|
du(argv[i]);
|
|
|
|
return 0;
|
|
}
|