4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
45 #include <sys/param.h>
46 #include <sys/types.h>
47 #include <sys/mntent.h>
48 #include <sys/fs/ufs_fs.h>
52 #include <sys/statvfs.h>
53 #include <sys/mnttab.h>
54 #include <sys/mkdev.h>
61 extern char *getenv();
62 extern char *getcwd();
63 extern char *realpath();
67 * Raw name to block device name translation function.
68 * This comes from libadm.
70 extern char *getfullblkname();
72 static void usage(), pheader();
73 static char *mpath(char *);
74 static char *zap_chroot(char *);
75 static char *pathsuffix(char *, char *);
76 static char *xmalloc(unsigned int);
77 static int chroot_stat(char *, int (*)(), char *, char **);
78 static int bread(char *, int, daddr_t
, char *, int);
79 static int subpath(char *, char *);
80 static int abspath(char *, char *, char *);
81 static void show_inode_usage();
82 static void dfreedev(char *);
83 static void dfreemnt(char *, struct mnttab
*);
84 static void print_totals();
85 static void print_itotals();
86 static void print_statvfs(struct statvfs64
*);
87 static int mdev(char *, struct mnttab
**);
88 static struct mntlist
*mkmntlist();
89 static struct mnttab
*mntdup(struct mnttab
*mnt
);
90 static struct mntlist
*findmntent(char *, struct stat64
*, struct mntlist
*);
92 #define bcopy(f, t, n) memcpy(t, f, n)
93 #define bzero(s, n) memset(s, 0, n)
94 #define bcmp(s, d, n) memcmp(s, d, n)
96 #define index(s, r) strchr(s, r)
97 #define rindex(s, r) strrchr(s, r)
100 ((b) < (fsblkcnt64_t)1024 ? \
101 (x) / ((fsblkcnt64_t)1024 / (b)) : (x) * ((b) / (fsblkcnt64_t)1024))
103 int aflag
= 0; /* even the uninteresting ones */
104 int bflag
= 0; /* print only number of kilobytes free */
105 int eflag
= 0; /* print only number of file entries free */
106 int gflag
= 0; /* print entire statvfs structure */
107 int hflag
= 0; /* don't print header */
108 int iflag
= 0; /* information for inodes */
109 int nflag
= 0; /* print VFStype name */
110 int tflag
= 0; /* print totals */
113 char *typestr
= "ufs";
114 fsblkcnt64_t t_totalblks
, t_avail
, t_free
, t_used
, t_reserved
;
115 int t_inodes
, t_iused
, t_ifree
;
118 * cached information recording previous chroot history.
120 static char *chrootpath
;
129 #define sblock sb.iu_fs
132 * This structure is used to chain mntent structures into a list
133 * and to cache stat information for each member of the list.
136 struct mnttab
*mntl_mnt
;
137 struct mntlist
*mntl_next
;
151 main(int argc
, char *argv
[])
155 char *suboptions
, *value
;
157 (void) setlocale(LC_ALL
, "");
158 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
159 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
161 (void) textdomain(TEXT_DOMAIN
);
163 while ((opt
= getopt(argc
, argv
, "beghkno:t")) != EOF
) {
166 case 'b': /* print only number of kilobytes free */
171 eflag
++; /* print only number of file entries free */
192 * ufs specific options.
195 while (*suboptions
!= '\0') {
196 switch (getsubopt(&suboptions
,
199 case I_FLAG
: /* information for inodes */
209 case 't': /* print totals */
213 case 'V': /* Print command line */
218 (void) fprintf(stdout
, "df -F ufs ");
219 for (opt_count
= 1; opt_count
< argc
;
221 opt_text
= argv
[opt_count
];
223 (void) fprintf(stdout
, " %s ",
226 (void) fprintf(stdout
, "\n");
236 if (gflag
&& iflag
) {
237 printf(gettext("df: '-g' and '-o i' are mutually exclusive\n"));
244 * Cache CHROOT information for later use; assume that $CHROOT matches
245 * the cumulative arguments given to chroot calls.
247 chrootpath
= getenv("CHROOT");
248 if (chrootpath
!= NULL
&& strcmp(chrootpath
, "/") == 0)
251 if (argc
<= optind
) {
253 * Take this path when "/usr/lib/fs/ufs/df" is specified, and
254 * there are no mountpoints specified.
255 * E.g., these command lines take us down this path
256 * /usr/lib/fs/ufs/df -o i
261 if ((mtabp
= fopen(MNTTAB
, "r")) == NULL
) {
262 (void) fprintf(stderr
, "df: ");
267 while (getmntent(mtabp
, &mnt
) == 0) {
268 if (strcmp(typestr
, mnt
.mnt_fstype
) != 0) {
271 dfreemnt(mnt
.mnt_mountp
, &mnt
);
278 (void) fclose(mtabp
);
281 struct mntlist
*mntl
;
282 struct stat64
*argstat
;
286 /* Arguments are processed till optind, adjust the pointers */
291 * Obtain stat64 information for each argument before
292 * constructing the list of mounted file systems. This
293 * ordering forces the automounter to establish any
294 * mounts required to access the arguments, so that the
295 * corresponding mount table entries will exist when
298 argstat
= (struct stat64
*)xmalloc(argc
* sizeof (*argstat
));
299 devnames
= (char **)xmalloc(argc
* sizeof (char *));
300 for (i
= 0; i
< argc
; i
++) {
303 * Given a raw device name, get the block device name
305 cp
= getfullblkname(argv
[i
]);
306 if (cp
== NULL
|| *cp
== '\0') {
309 cp
= strdup(argv
[i
]);
314 fprintf(stderr
, gettext(
315 "df: memory allocation failure\n"));
317 for (j
= 0; j
< i
; j
++)
324 if (stat64(cp
, &argstat
[i
]) < 0) {
327 * Mark as no longer interesting.
340 * Construct the list of mounted file systems.
345 * Iterate through the argument list, reporting on each one.
347 for (i
= 0; i
< argc
; i
++) {
352 * Skip if we've already determined that we can't
359 * If the argument names a device, report on the file
360 * system associated with the device rather than on
361 * the one containing the device's directory entry
364 if ((isblk
= (argstat
[i
].st_mode
&S_IFMT
) == S_IFBLK
) ||
365 (argstat
[i
].st_mode
& S_IFMT
) == S_IFCHR
) {
366 if (isblk
&& strcmp(mpath(cp
), "") != 0) {
370 dfreemnt(mp
->mnt_mountp
, mp
);
380 * Get this argument's corresponding mount table
383 mlp
= findmntent(cp
, &argstat
[i
], mntl
);
388 (void) fprintf(stderr
,
389 gettext("Could not find mount point for %s\n"),
394 dfreemnt(mlp
->mntl_mnt
->mnt_mountp
, mlp
->mntl_mnt
);
408 (void) printf(gettext("VFStype name - ufs\n"));
413 * Following string is used as a table header.
414 * Translated items should start at the same
415 * columns as the original items.
417 (void) printf(gettext(
418 "Filesystem ifree\n"));
422 * Following string is used as a table header.
423 * Translated items should start at the same
424 * columns as the original items.
426 (void) printf(gettext(
427 "Filesystem iused ifree %%iused Mounted on\n"));
433 * Following string is used as a table header.
434 * Translated items should start at the same
435 * columns as the original items.
437 (void) printf(gettext(
438 "Filesystem f_type f_fsize f_bfree f_bavail f_files f_ffree "
439 "f_fsid f_flag f_fstr\n"));
444 * Following string is used as a table header.
445 * Translated items should start at the same
446 * columns as the original items.
448 (void) printf(gettext(
449 "Filesystem avail\n"));
453 * Following string is used as a table header.
454 * Translated items should start at the same
455 * columns as the original items.
457 (void) printf(gettext(
458 "Filesystem kbytes used avail capacity Mounted on\n"));
464 * Report on a block or character special device. Assumed not to be
465 * mounted. N.B. checks for a valid UFS superblock.
470 fsblkcnt64_t totalblks
, availblks
, avail
, free
, used
;
473 fi
= open64(file
, 0);
475 (void) fprintf(stderr
, "df: ");
479 if (bread(file
, fi
, SBLOCK
, (char *)&sblock
, SBSIZE
) == 0) {
483 if ((sblock
.fs_magic
!= FS_MAGIC
) &&
484 (sblock
.fs_magic
!= MTB_UFS_MAGIC
)) {
485 (void) fprintf(stderr
, gettext(
486 "df: %s: not a ufs file system\n"),
491 if (sblock
.fs_magic
== FS_MAGIC
&&
492 (sblock
.fs_version
!= UFS_EFISTYLE4NONEFI_VERSION_2
&&
493 sblock
.fs_version
!= UFS_VERSION_MIN
)) {
494 (void) fprintf(stderr
, gettext(
495 "df: %s: unrecognized version of UFS: %d\n"),
496 file
, sblock
.fs_version
);
500 if (sblock
.fs_magic
== MTB_UFS_MAGIC
&&
501 (sblock
.fs_version
> MTB_UFS_VERSION_1
||
502 sblock
.fs_version
< MTB_UFS_VERSION_MIN
)) {
503 (void) fprintf(stderr
, gettext(
504 "df: %s: unrecognized version of UFS: %d\n"),
505 file
, sblock
.fs_version
);
509 (void) printf("%-20.20s", file
);
512 (void) printf("%8ld", sblock
.fs_cstotal
.cs_nifree
);
515 (fsfilcnt64_t
)sblock
.fs_ncg
*
516 (fsfilcnt64_t
)sblock
.fs_ipg
,
517 (fsfilcnt64_t
)sblock
.fs_cstotal
.cs_nifree
);
520 totalblks
= (fsblkcnt64_t
)sblock
.fs_dsize
;
522 (fsblkcnt64_t
)sblock
.fs_cstotal
.cs_nbfree
*
523 (fsblkcnt64_t
)sblock
.fs_frag
+
524 (fsblkcnt64_t
)sblock
.fs_cstotal
.cs_nffree
;
525 used
= totalblks
- free
;
526 availblks
= totalblks
/ (fsblkcnt64_t
)100 *
527 ((fsblkcnt64_t
)100 - (fsblkcnt64_t
)sblock
.fs_minfree
);
528 avail
= availblks
> used
? availblks
- used
: (fsblkcnt64_t
)0;
530 (void) printf("%8lld\n", dbtok(avail
,
531 (fsblkcnt64_t
)sblock
.fs_fsize
));
533 (void) printf(" %7lld %7lld %7lld",
534 dbtok(totalblks
, (fsblkcnt64_t
)sblock
.fs_fsize
),
535 dbtok(used
, (fsblkcnt64_t
)sblock
.fs_fsize
),
536 dbtok(avail
, (fsblkcnt64_t
)sblock
.fs_fsize
));
537 (void) printf("%6.0f%%",
538 availblks
== 0 ? 0.0 :
539 (double)used
/ (double)availblks
* 100.0);
543 t_totalblks
+= dbtok(totalblks
,
544 (fsblkcnt64_t
)sblock
.fs_fsize
);
545 t_used
+= dbtok(used
, (fsblkcnt64_t
)sblock
.fs_fsize
);
546 t_avail
+= dbtok(avail
, (fsblkcnt64_t
)sblock
.fs_fsize
);
550 if ((!bflag
) && (!eflag
))
551 (void) printf(" %s\n", mpath(file
));
558 dfreemnt(char *file
, struct mnttab
*mnt
)
562 if (statvfs64(file
, &fs
) < 0 &&
563 chroot_stat(file
, statvfs64
, (char *)&fs
, &file
) < 0) {
564 (void) fprintf(stderr
, "df: ");
569 if (!aflag
&& fs
.f_blocks
== 0) {
572 if (!isatty(fileno(stdout
))) {
573 (void) printf("%s", mnt
->mnt_special
);
575 if (strlen(mnt
->mnt_special
) > (size_t)20) {
576 (void) printf("%s\n", mnt
->mnt_special
);
579 (void) printf("%-20.20s", mnt
->mnt_special
);
584 (void) printf("%8lld", fs
.f_ffree
);
586 show_inode_usage(fs
.f_files
, fs
.f_ffree
);
592 fsblkcnt64_t totalblks
, avail
, free
, used
, reserved
;
594 totalblks
= fs
.f_blocks
;
596 used
= totalblks
- free
;
598 reserved
= free
- avail
;
599 if ((long long)avail
< 0)
602 (void) printf("%8lld\n", dbtok(avail
,
603 (fsblkcnt64_t
)fs
.f_frsize
));
605 (void) printf(" %7lld %7lld %7lld",
607 (fsblkcnt64_t
)fs
.f_frsize
),
608 dbtok(used
, (fsblkcnt64_t
)fs
.f_frsize
),
609 dbtok(avail
, (fsblkcnt64_t
)fs
.f_frsize
));
610 totalblks
-= reserved
;
611 (void) printf("%6.0f%%",
612 totalblks
== 0 ? 0.0 :
613 (double)used
/ (double)totalblks
* 100.0);
616 t_totalblks
+= dbtok(totalblks
+ reserved
,
617 (fsblkcnt64_t
)fs
.f_bsize
);
618 t_reserved
+= reserved
;
619 t_used
+= dbtok(used
,
620 (fsblkcnt64_t
)fs
.f_frsize
);
621 t_avail
+= dbtok(avail
,
622 (fsblkcnt64_t
)fs
.f_frsize
);
628 if ((!bflag
) && (!eflag
) && (!gflag
))
629 (void) printf(" %s\n", mnt
->mnt_mountp
);
635 show_inode_usage(fsfilcnt64_t total
, fsfilcnt64_t free
)
637 fsfilcnt64_t used
= total
- free
;
638 int missing_info
= ((long long)total
== (long long)-1 ||
639 (long long)free
== (long long)-1);
642 (void) printf("%8s", "*");
644 (void) printf("%8lld", used
);
645 if ((long long)free
== (long long)-1)
646 (void) printf("%8s", "*");
648 (void) printf(" %7lld", free
);
650 (void) printf("%6s ", "*");
652 (void) printf("%6.0f%% ", (double)used
/ (double)total
* 100.0);
656 * Return the suffix of path obtained by stripping off the prefix
657 * that is the value of the CHROOT environment variable. If this
658 * value isn't obtainable or if it's not a prefix of path, return NULL.
661 zap_chroot(char *path
)
663 return (pathsuffix(path
, chrootpath
));
667 * Stat/statfs a file after stripping off leading directory to which we are
668 * chroot'd. Used to find the TFS mount that applies to the current
669 * activated NSE environment.
672 chroot_stat(char *dir
, int (*statfunc
)(), char *statp
, char **dirp
)
674 if ((dir
= zap_chroot(dir
)) == NULL
)
678 return (*statfunc
)(dir
, statp
);
682 * Given a name like /dev/dsk/c1d0s2, returns the mounted path, like /usr.
689 struct stat64 device_stat
, mount_stat
;
692 mnttab
= fopen(MNTTAB
, "r");
693 if (mnttab
== NULL
) {
697 while ((getmntent(mnttab
, &mnt
)) == 0) {
698 if (strcmp(mnt
.mnt_fstype
, MNTTYPE_UFS
) != 0) {
701 if (strcmp(file
, mnt
.mnt_special
) == 0) {
702 if (stat64(mnt
.mnt_mountp
, &mount_stat
) != 0)
704 if (stat64(mnt
.mnt_special
, &device_stat
) != 0)
707 if (device_stat
.st_rdev
== mount_stat
.st_dev
) {
708 mname
= mnt
.mnt_mountp
;
718 * Given a special device, return mnttab entry
719 * Returns 0 on success
723 mdev(char *spec
, struct mnttab
**mntbp
)
728 if ((mntp
= fopen(MNTTAB
, "r")) == 0) {
729 (void) fprintf(stderr
, "df: ");
734 while (getmntent(mntp
, &mnt
) == 0) {
735 if (strcmp(spec
, mnt
.mnt_special
) == 0) {
737 *mntbp
= mntdup(&mnt
);
742 (void) fprintf(stderr
, "df : couldn't find mnttab entry for %s", spec
);
747 * Find the entry in mlist that corresponds to the file named by path
748 * (i.e., that names a mount table entry for the file system in which
749 * path lies). The pstat argument must point to stat information for
752 * Return the entry or NULL if there's no match.
754 * As it becomes necessary to obtain stat information about previously
755 * unexamined mlist entries, gather the information and cache it with the
758 * The routine's strategy is to convert path into its canonical, symlink-free
759 * representation canon (which will require accessing the file systems on the
760 * branch from the root to path and thus may cause the routine to hang if any
761 * of them are inaccessible) and to use it to search for a mount point whose
762 * name is a substring of canon and whose corresponding device matches that of
763 * canon. This technique avoids accessing unnecessary file system resources
764 * and thus prevents the program from hanging on inaccessible resources unless
765 * those resources are necessary for accessing path.
767 static struct mntlist
*
768 findmntent(char *path
, struct stat64
*pstat
, struct mntlist
*mlist
)
770 static char cwd
[MAXPATHLEN
];
771 char canon
[MAXPATHLEN
];
772 char scratch
[MAXPATHLEN
];
776 * If path is relative and we haven't already determined the current
777 * working directory, do so now. Calculating the working directory
778 * here lets us do the work once, instead of (potentially) repeatedly
781 if (*path
!= '/' && cwd
[0] == '\0') {
782 if (getcwd(cwd
, MAXPATHLEN
) == NULL
) {
789 * Find an absolute pathname in the native file system name space that
790 * corresponds to path, stuffing it into canon.
792 * If CHROOT is set in the environment, assume that chroot($CHROOT)
793 * (or an equivalent series of calls) was executed and convert the
794 * path to the equivalent name in the native file system's name space.
795 * Doing so allows direct comparison with the names in mtab entires,
796 * which are assumed to be recorded relative to the native name space.
798 if (abspath(cwd
, path
, scratch
) < 0)
800 if (strcmp(scratch
, "/") == 0 && chrootpath
!= NULL
) {
802 * Force canon to be in canonical form; if the result from
803 * abspath was "/" and chrootpath isn't the null string, we
804 * must strip off a trailing slash.
808 (void) sprintf(canon
, "%s%s", chrootpath
? chrootpath
: "", scratch
);
811 for (mlp
= mlist
; mlp
; mlp
= mlp
->mntl_next
) {
812 struct mnttab
*mnt
= mlp
->mntl_mnt
;
815 * Ignore uninteresting mounts.
817 if (strcmp(mnt
->mnt_fstype
, typestr
) != 0)
821 * The mount entry covers some prefix of the file.
822 * See whether it's the entry for the file system
823 * containing the file by comparing device ids.
825 if (mlp
->mntl_dev
== NODEV
) {
828 if (stat64(mnt
->mnt_mountp
, &fs_sb
) < 0 &&
829 chroot_stat(mnt
->mnt_mountp
, stat64
, (char *)&fs_sb
,
830 (char **)NULL
) < 0) {
833 mlp
->mntl_dev
= fs_sb
.st_dev
;
836 if (pstat
->st_dev
== mlp
->mntl_dev
)
844 * Convert the path given in raw to canonical, absolute, symlink-free
845 * form, storing the result in the buffer named by canon, which must be
846 * at least MAXPATHLEN bytes long. "wd" contains the current working
847 * directory; accepting this value as an argument lets our caller cache
848 * the value, so that realpath (called from this routine) doesn't have
849 * to recalculate it each time it's given a relative pathname.
851 * Return 0 on success, -1 on failure.
854 abspath(char *wd
, char *raw
, char *canon
)
856 char absbuf
[MAXPATHLEN
];
859 * Preliminary sanity check.
861 if (wd
== NULL
|| raw
== NULL
|| canon
== NULL
)
865 * If the path is relative, convert it to absolute form,
866 * using wd if it's been supplied.
869 char *limit
= absbuf
+ sizeof (absbuf
);
872 /* Fill in working directory. */
873 if (strlcpy(absbuf
, wd
, sizeof (absbuf
)) >= sizeof (absbuf
))
876 /* Add separating slash. */
877 d
= absbuf
+ strlen(absbuf
);
881 /* Glue on the relative part of the path. */
882 while (d
< limit
&& (*d
++ = *raw
++))
889 * Call realpath to canonicalize and resolve symlinks.
891 return (realpath(raw
, canon
) == NULL
? -1 : 0);
895 * Return a pointer to the trailing suffix of full that follows the prefix
896 * given by pref. If pref isn't a prefix of full, return NULL. Apply
897 * pathname semantics to the prefix test, so that pref must match at a
898 * component boundary.
901 pathsuffix(char *full
, char *pref
)
905 if (full
== NULL
|| pref
== NULL
)
908 preflen
= strlen(pref
);
909 if (strncmp(pref
, full
, preflen
) != 0)
913 * pref is a substring of full. To be a subpath, it cannot cover a
914 * partial component of full. The last clause of the test handles the
915 * special case of the root.
917 if (full
[preflen
] != '\0' && full
[preflen
] != '/' && preflen
> 1)
920 if (preflen
== 1 && full
[0] == '/')
923 return (full
+ preflen
);
927 * Return zero iff the path named by sub is a leading subpath
928 * of the path named by full.
930 * Treat null paths as matching nothing.
933 subpath(char *full
, char *sub
)
935 return (pathsuffix(full
, sub
) == NULL
);
941 bread(char *file
, int fi
, daddr_t bno
, char *buf
, int cnt
)
945 (void) llseek(fi
, (offset_t
)bno
* DEV_BSIZE
, 0);
946 if ((n
= read(fi
, buf
, cnt
)) < 0) {
947 /* probably a dismounted disk if errno == EIO */
949 (void) fprintf(stderr
, gettext("df: read error on "));
951 (void) fprintf(stderr
, "bno = %ld\n", bno
);
953 (void) fprintf(stderr
, gettext(
954 "df: premature EOF on %s\n"), file
);
955 (void) fprintf(stderr
,
956 "bno = %ld expected = %d count = %d\n", bno
, cnt
, n
);
964 xmalloc(unsigned int size
)
969 if ((ret
= (char *)malloc(size
)) == NULL
) {
970 (void) fprintf(stderr
, gettext("umount: ran out of memory!\n"));
977 mntdup(struct mnttab
*mnt
)
981 new = (struct mnttab
*)xmalloc(sizeof (*new));
984 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_special
) + 1));
985 (void) strcpy(new->mnt_special
, mnt
->mnt_special
);
988 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_mountp
) + 1));
989 (void) strcpy(new->mnt_mountp
, mnt
->mnt_mountp
);
992 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_fstype
) + 1));
993 (void) strcpy(new->mnt_fstype
, mnt
->mnt_fstype
);
995 if (mnt
->mnt_mntopts
!= NULL
) {
997 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_mntopts
) + 1));
998 (void) strcpy(new->mnt_mntopts
, mnt
->mnt_mntopts
);
1000 new->mnt_mntopts
= NULL
;
1004 new->mnt_freq
= mnt
->mnt_freq
;
1005 new->mnt_passno
= mnt
->mnt_passno
;
1015 (void) fprintf(stderr
, gettext(
1016 "ufs usage: df [generic options] [-o i] [directory | special]\n"));
1024 struct mntlist
*mntl
;
1025 struct mntlist
*mntst
= NULL
;
1026 struct extmnttab mnt
;
1028 if ((mounted
= fopen(MNTTAB
, "r")) == NULL
) {
1029 (void) fprintf(stderr
, "df : ");
1033 resetmnttab(mounted
);
1034 while (getextmntent(mounted
, &mnt
, sizeof (struct extmnttab
)) == NULL
) {
1035 mntl
= (struct mntlist
*)xmalloc(sizeof (*mntl
));
1036 mntl
->mntl_mnt
= mntdup((struct mnttab
*)(&mnt
));
1037 mntl
->mntl_next
= mntst
;
1038 mntl
->mntl_devvalid
= 1;
1039 mntl
->mntl_dev
= makedev(mnt
.mnt_major
, mnt
.mnt_minor
);
1042 (void) fclose(mounted
);
1047 print_statvfs(struct statvfs64
*fs
)
1051 for (i
= 0; i
< FSTYPSZ
; i
++)
1052 (void) printf("%c", fs
->f_basetype
[i
]);
1053 (void) printf(" %7d %7lld %7lld",
1057 (void) printf(" %7lld %7lld %7d",
1061 (void) printf(" 0x%x ",
1063 for (i
= 0; i
< 14; i
++)
1065 (fs
->f_fstr
[i
] == '\0') ? ' ' : fs
->f_fstr
[i
]);
1074 * Following string is used as a table header.
1075 * Translated items should start at the same
1076 * columns as the original items.
1078 (void) printf(gettext("Totals %8lld %7lld %7lld"),
1079 t_totalblks
, t_used
, t_avail
);
1080 (void) printf("%6.0f%%\n",
1081 (t_totalblks
- t_reserved
) == (fsblkcnt64_t
)0 ?
1083 (double)t_used
/ (double)(t_totalblks
- t_reserved
) * 100.0);
1091 * Following string is used as a table header.
1092 * Translated items should start at the same
1093 * columns as the original items.
1095 (void) printf(gettext("Totals %8d %7d%6.0f%%\n"),
1098 t_inodes
== 0 ? 0.0 : (double)t_iused
/ (double)t_inodes
* 100.0);