SCCS-vsn: usr.bin/du/du.c 5.20
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)du.c 5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)du.c 5.20 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
+#include <err.h>
+#include <errno.h>
-void err __P((const char *, ...));
char *getbsize __P((char *, int *, long *));
int linkchk __P((FTSENT *));
void usage __P((void));
char *getbsize __P((char *, int *, long *));
int linkchk __P((FTSENT *));
void usage __P((void));
main(argc, argv)
int argc;
char *argv[];
main(argc, argv)
int argc;
char *argv[];
blocksize /= 512;
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
blocksize /= 512;
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
- err("%s", strerror(errno));
while (p = fts_read(fts))
switch(p->fts_info) {
while (p = fts_read(fts))
switch(p->fts_info) {
case FTS_DNR:
case FTS_ERR:
case FTS_NS:
case FTS_DNR:
case FTS_ERR:
case FTS_NS:
- (void)fprintf(stderr,
- "du: %s: %s\n", p->fts_path, strerror(errno));
+ warn("%s", p->fts_path);
break;
default:
if (p->fts_statp->st_nlink > 1 && linkchk(p))
break;
default:
if (p->fts_statp->st_nlink > 1 && linkchk(p))
p->fts_parent->fts_number += p->fts_statp->st_blocks;
}
if (errno)
p->fts_parent->fts_number += p->fts_statp->st_blocks;
}
if (errno)
- err("%s", strerror(errno));
if (nfiles == maxfiles && (files = realloc((char *)files,
(u_int)(sizeof(ID) * (maxfiles += 128)))) == NULL)
if (nfiles == maxfiles && (files = realloc((char *)files,
(u_int)(sizeof(ID) * (maxfiles += 128)))) == NULL)
- err("%s", strerror(errno));
files[nfiles].inode = ino;
files[nfiles].dev = dev;
++nfiles;
files[nfiles].inode = ino;
files[nfiles].dev = dev;
++nfiles;
(void)fprintf(stderr, "usage: du [-a | -s] [-Hhx] [file ...]\n");
exit(1);
}
(void)fprintf(stderr, "usage: du [-a | -s] [-Hhx] [file ...]\n");
exit(1);
}
-
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-void
-#if __STDC__
-err(const char *fmt, ...)
-#else
-err(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- (void)fprintf(stderr, "du: ");
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- (void)fprintf(stderr, "\n");
- exit(1);
- /* NOTREACHED */
-}