View | Details | Raw Unified | Return to bug 19635
Collapse All | Expand All

(-)/usr/src/bin/df/df.1 (-1 / +3 lines)
Lines 44-50 Link Here
44
.Fl b | h | H | k |
44
.Fl b | h | H | k |
45
.Fl m | P
45
.Fl m | P
46
.Oc
46
.Oc
47
.Op Fl ain
47
.Op Fl acin
48
.Op Fl t Ar type
48
.Op Fl t Ar type
49
.Op Ar file | Ar filesystem ...
49
.Op Ar file | Ar filesystem ...
50
.Sh DESCRIPTION
50
.Sh DESCRIPTION
Lines 71-76 Link Here
71
this overrides the
71
this overrides the
72
.Ev BLOCKSIZE
72
.Ev BLOCKSIZE
73
specification from the environment.
73
specification from the environment.
74
.It Fl c
75
Display a grand total.
74
.It Fl g
76
.It Fl g
75
Use 1073741824-byte (1-Gbyte) blocks rather than the default.  Note that
77
Use 1073741824-byte (1-Gbyte) blocks rather than the default.  Note that
76
this overrides the
78
this overrides the
(-)/usr/src/bin/df/df.c (-7 / +41 lines)
Lines 103-113 Link Here
103
void	  prthuman __P((struct statfs *, long));
103
void	  prthuman __P((struct statfs *, long));
104
void	  prthumanval __P((double));
104
void	  prthumanval __P((double));
105
void	  prtstat __P((struct statfs *, int));
105
void	  prtstat __P((struct statfs *, int));
106
void	  addstat __P((struct statfs *, struct statfs *));
106
int	  ufs_df __P((char *, int));
107
int	  ufs_df __P((char *, int));
107
unit_t	  unit_adjust __P((double *));
108
unit_t	  unit_adjust __P((double *));
108
void	  usage __P((void));
109
void	  usage __P((void));
109
110
110
int	aflag = 0, hflag, iflag, nflag;
111
int	aflag = 0, cflag = 0, hflag, iflag, nflag;
111
struct	ufs_args mdev;
112
struct	ufs_args mdev;
112
113
113
int
114
int
Lines 116-132 Link Here
116
	char *argv[];
117
	char *argv[];
117
{
118
{
118
	struct stat stbuf;
119
	struct stat stbuf;
119
	struct statfs statfsbuf, *mntbuf;
120
	struct statfs statfsbuf, *mntbuf, totalbuf = { 0 };
120
	long mntsize;
121
	long mntsize;
121
	int ch, err, i, maxwidth, rv, width;
122
	int ch, err, i, maxwidth, rv, width;
122
	char *mntpt, *mntpath, **vfslist;
123
	char *mntpt, *mntpath, **vfslist;
123
124
125
	totalbuf.f_bsize = DEV_BSIZE;
126
	strncpy (totalbuf.f_mntfromname, "total", MNAMELEN);
124
	vfslist = NULL;
127
	vfslist = NULL;
125
	while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
128
	while ((ch = getopt(argc, argv, "abcgHhikmnPt:")) != -1)
126
		switch (ch) {
129
		switch (ch) {
127
		case 'a':
130
		case 'a':
128
			aflag = 1;
131
			aflag = 1;
129
			break;
132
			break;
133
		case 'c':
134
			cflag = 1;
135
			break;
130
		case 'b':
136
		case 'b':
131
				/* FALLTHROUGH */
137
				/* FALLTHROUGH */
132
		case 'P':
138
		case 'P':
Lines 191-199 Link Here
191
			}
197
			}
192
		}
198
		}
193
		for (i = 0; i < mntsize; i++) {
199
		for (i = 0; i < mntsize; i++) {
194
			if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
200
			if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) {
195
				prtstat(&mntbuf[i], maxwidth);
201
				prtstat(&mntbuf[i], maxwidth);
202
				if (cflag)
203
					addstat(&totalbuf, &mntbuf[i]);
204
			}
196
		}
205
		}
206
		if (cflag)
207
			prtstat(&totalbuf, maxwidth);
197
		exit(rv);
208
		exit(rv);
198
	}
209
	}
199
210
Lines 256-262 Link Here
256
		if (argc == 1)
267
		if (argc == 1)
257
			maxwidth = strlen(statfsbuf.f_mntfromname) + 1;
268
			maxwidth = strlen(statfsbuf.f_mntfromname) + 1;
258
		prtstat(&statfsbuf, maxwidth);
269
		prtstat(&statfsbuf, maxwidth);
270
		if (cflag)
271
			addstat(&totalbuf, &statfsbuf);
259
	}
272
	}
273
	if (cflag)
274
		prtstat(&totalbuf, maxwidth);
260
	return (rv);
275
	return (rv);
261
}
276
}
262
277
Lines 380-385 Link Here
380
	static int headerlen, timesthrough;
395
	static int headerlen, timesthrough;
381
	static char *header;
396
	static char *header;
382
	long used, availblks, inodes;
397
	long used, availblks, inodes;
398
	int total;
383
399
384
	if (maxwidth < 11)
400
	if (maxwidth < 11)
385
		maxwidth = 11;
401
		maxwidth = 11;
Lines 411-424 Link Here
411
	}
427
	}
412
	(void)printf(" %5.0f%%",
428
	(void)printf(" %5.0f%%",
413
	    availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
429
	    availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
430
	total = !*sfsp->f_mntonname &&
431
	    !strncmp(sfsp->f_mntfromname, "total", MNAMELEN);
414
	if (iflag) {
432
	if (iflag) {
415
		inodes = sfsp->f_files;
433
		inodes = sfsp->f_files;
416
		used = inodes - sfsp->f_ffree;
434
		used = inodes - sfsp->f_ffree;
417
		(void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree,
435
		(void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree,
418
		   inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
436
		   inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
419
	} else
437
	} else if (!total)
420
		(void)printf("  ");
438
		(void)printf("  ");
421
	(void)printf("  %s\n", sfsp->f_mntonname);
439
	if (!total)
440
		(void)printf("  %s", sfsp->f_mntonname);
441
	(void)printf("\n");
442
}
443
444
void
445
addstat(totalfsp, statfsp)
446
	struct statfs *totalfsp, *statfsp;
447
{
448
	totalfsp->f_blocks += (statfsp->f_blocks * statfsp->f_bsize) /
449
	    totalfsp->f_bsize;
450
	totalfsp->f_bfree += (statfsp->f_bfree * statfsp->f_bsize) /
451
	    totalfsp->f_bsize;
452
	totalfsp->f_bavail += (statfsp->f_bavail * statfsp->f_bsize) /
453
	    totalfsp->f_bsize;
454
	totalfsp->f_files += statfsp->f_files;
455
	totalfsp->f_ffree += statfsp->f_ffree;
422
}
456
}
423
457
424
/*
458
/*
Lines 506-511 Link Here
506
{
540
{
507
541
508
	(void)fprintf(stderr,
542
	(void)fprintf(stderr,
509
	    "usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file | filesystem ...]\n");
543
	    "usage: df [-b | -H | -h | -k | -m | -P] [-acin] [-t type] [file | filesystem ...]\n");
510
	exit(EX_USAGE);
544
	exit(EX_USAGE);
511
}
545
}

Return to bug 19635