static char *sccsid
= "@(#)du.c 4.11 (Berkeley) %G%";
char path
[BUFSIZ
], name
[BUFSIZ
];
char *index(), *rindex(), *strcpy(), *sprintf();
#define kb(n) (howmany(dbtob(n), 1024))
if (argc
&& !strcmp(*argv
, "-s")) {
if (argc
&& !strcmp(*argv
, "-a")) {
fprintf(stderr
, "No more processes.\n");
if (argc
== 1 || pid
== 0) {
(void) strcpy(path
, *argv
);
(void) strcpy(name
, *argv
);
if (np
= rindex(name
, '/')) {
if (chdir(*name
? name
: "/") < 0) {
perror(*name
? name
: "/");
blocks
= descend(path
, *np
? np
: ".");
printf("%ld\t%s\n", kb(blocks
), path
);
register struct direct
*dp
;
ebase0
= ebase
= index(base
, 0);
if (ebase
> base
&& ebase
[-1] == '/')
if (lstat(name
, &stb
) < 0) {
if (stb
.st_nlink
> 1 && (stb
.st_mode
&S_IFMT
) != S_IFDIR
) {
for (i
= 0; i
<= mlx
; i
++)
if (ml
[i
].ino
== stb
.st_ino
&& ml
[i
].dev
== stb
.st_dev
)
ml
[mlx
].dev
= stb
.st_dev
;
ml
[mlx
].ino
= stb
.st_ino
;
if ((stb
.st_mode
&S_IFMT
) != S_IFDIR
) {
printf("%ld\t%s\n", kb(blocks
), base
);
while (dp
= readdir(dirp
)) {
if (!strcmp(dp
->d_name
, ".") || !strcmp(dp
->d_name
, ".."))
(void) sprintf(ebase
, "/%s", dp
->d_name
);
blocks
+= descend(base
, ebase
+1);
printf("%ld\t%s\n", kb(blocks
), base
);
(void) sprintf(index(base
, 0), "/..");