* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static const char copyright[] =
+__used static const char copyright[] =
"@(#) Copyright (c) 1980, 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#if 0
static char sccsid[] = "@(#)df.c 8.9 (Berkeley) 5/8/95";
#else
-static const char rcsid[] =
+__used static const char rcsid[] =
"$FreeBSD: src/bin/df/df.c,v 1.23.2.9 2002/07/01 00:14:24 iedowse Exp $";
#endif
#endif /* not lint */
int bread(off_t, void *, int);
int checkvfsname(const char *, char **);
char *getmntpt(char *);
-int longwidth(long long);
+int int64width(int64_t);
char *makenetvfslist(void);
char **makevfslist(const char *);
void prthuman(struct statfs *, uint64_t);
struct stat stbuf;
struct statfs statfsbuf, *mntbuf;
struct maxwidths maxwidths;
- const char *fstype;
char *mntpt, **vfslist;
long mntsize;
int ch, i, rv, tflag = 0, kludge_tflag = 0;
*not* expect a string after -t (we provide -T in both cases
to cover the old use of -t) */
options = "abgHhiklmnPtT:";
+ iflag = 1;
}
- fstype = "hfs";
-
vfslist = NULL;
while ((ch = getopt(argc, argv, options)) != -1)
switch (ch) {
/* -k overrides -P */
putenv("BLOCKSIZE=512");
}
+ iflag = 0;
} else {
putenv("BLOCKSIZE=512");
}
errx(1, "-l and -%c are mutually exclusive.", ch);
}
tflag++;
- fstype = optarg;
vfslist = makevfslist(optarg);
break;
case '?':
This makes the Lexmark printer installer happy (PR-3918471) */
if (tflag == 0 && kludge_tflag && *argv && stat(*argv, &stbuf) < 0
&& errno == ENOENT) {
- tflag = 1;
- fstype = *argv++;
- vfslist = makevfslist(fstype);
+ vfslist = makevfslist(*argv++);
}
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
char * avail_str;
if (++timesthrough == 1) {
- mwp->mntfrom = imax(mwp->mntfrom, strlen("Filesystem"));
+ mwp->mntfrom = imax(mwp->mntfrom, (int)strlen("Filesystem"));
if (hflag) {
header = " Size";
- mwp->total = mwp->used = mwp->avail = strlen(header);
+ mwp->total = mwp->used = mwp->avail = (int)strlen(header);
} else {
header = getbsize(&headerlen, &blocksize);
mwp->total = imax(mwp->total, headerlen);
}
- mwp->used = imax(mwp->used, strlen("Used"));
+ mwp->used = imax(mwp->used, (int)strlen("Used"));
if (COMPAT_MODE("bin/df", "unix2003") && !hflag) {
avail_str = "Available";
} else {
avail_str = "Avail";
}
- mwp->avail = imax(mwp->avail, strlen(avail_str));
+ mwp->avail = imax(mwp->avail, (int)strlen(avail_str));
(void)printf("%-*s %*s %*s %*s Capacity", mwp->mntfrom,
"Filesystem", mwp->total, header, mwp->used, "Used",
mwp->avail, avail_str);
if (iflag) {
- mwp->iused = imax(mwp->iused, strlen(" iused"));
- mwp->ifree = imax(mwp->ifree, strlen("ifree"));
+ mwp->iused = imax(mwp->iused, (int)strlen(" iused"));
+ mwp->ifree = imax(mwp->ifree, (int)strlen("ifree"));
(void)printf(" %*s %*s %%iused", mwp->iused - 2,
"iused", mwp->ifree, "ifree");
}
if (hflag) {
prthuman(sfsp, used);
} else {
- (void)printf(" %*lld %*lld %*lld", mwp->total,
+ (void)printf(" %*jd %*jd %*jd", mwp->total,
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize, sfsp->f_mntonname),
mwp->used, fsbtoblk(used, sfsp->f_bsize, blocksize, sfsp->f_mntonname),
mwp->avail, fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize, sfsp->f_mntonname));
if (iflag) {
inodes = sfsp->f_files;
used = inodes - sfsp->f_ffree;
- (void)printf(" %*llu %*lu %4.0f%% ", mwp->iused, used,
- mwp->ifree, (unsigned long)sfsp->f_ffree, inodes == 0 ? 100.0 :
+ (void)printf(" %*llu %*llu %4.0f%% ", mwp->iused, used,
+ mwp->ifree, sfsp->f_ffree, inodes == 0 ? 100.0 :
(double)used / (double)inodes * 100.0);
} else
(void)printf(" ");
if (blocksize == 0)
getbsize(&dummy, &blocksize);
- mwp->mntfrom = imax(mwp->mntfrom, strlen(sfsp->f_mntfromname));
- mwp->total = imax(mwp->total, longwidth(fsbtoblk(sfsp->f_blocks,
+ mwp->mntfrom = imax(mwp->mntfrom, (int)strlen(sfsp->f_mntfromname));
+ mwp->total = imax(mwp->total, int64width(fsbtoblk(sfsp->f_blocks,
sfsp->f_bsize, blocksize, sfsp->f_mntonname)));
if (sfsp->f_blocks >= sfsp->f_bfree)
- mwp->used = imax(mwp->used, longwidth(fsbtoblk(sfsp->f_blocks -
+ mwp->used = imax(mwp->used, int64width(fsbtoblk(sfsp->f_blocks -
sfsp->f_bfree, sfsp->f_bsize, blocksize, sfsp->f_mntonname)));
- mwp->avail = imax(mwp->avail, longwidth(fsbtoblk(sfsp->f_bavail,
+ mwp->avail = imax(mwp->avail, int64width(fsbtoblk(sfsp->f_bavail,
sfsp->f_bsize, blocksize, sfsp->f_mntonname)));
- mwp->iused = imax(mwp->iused, longwidth((unsigned)(sfsp->f_files - sfsp->f_ffree)));
- mwp->ifree = imax(mwp->ifree, longwidth((unsigned)(sfsp->f_ffree)));
+ mwp->iused = imax(mwp->iused, int64width(sfsp->f_files - sfsp->f_ffree));
+ mwp->ifree = imax(mwp->ifree, int64width(sfsp->f_ffree));
}
/* Return the width in characters of the specified long. */
int
-longwidth(long long val)
+int64width(int64_t val)
{
int len;
mib[0] = CTL_VFS; mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM;
miblen=sizeof(maxvfsconf);
- if (sysctl(mib, (unsigned int)(sizeof(mib) / sizeof(mib[0])),
+ if (sysctl(mib, 3,
&maxvfsconf, &miblen, NULL, 0)) {
- warnx("sysctl failed");
+ warn("sysctl failed");
return (NULL);
}
if (!(vfc.vfc_flags & MNT_LOCAL)) {
listptr[cnt++] = strdup(vfc.vfc_name);
if (listptr[cnt-1] == NULL) {
+ free(listptr);
warnx("malloc failed");
return (NULL);
}