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') {
308 cp
= strdup(argv
[i
]);
313 fprintf(stderr
, gettext(
314 "df: memory allocation failure\n"));
316 for (j
= 0; j
< i
; j
++)
323 if (stat64(cp
, &argstat
[i
]) < 0) {
326 * Mark as no longer interesting.
339 * Construct the list of mounted file systems.
344 * Iterate through the argument list, reporting on each one.
346 for (i
= 0; i
< argc
; i
++) {
351 * Skip if we've already determined that we can't
358 * If the argument names a device, report on the file
359 * system associated with the device rather than on
360 * the one containing the device's directory entry
363 if ((isblk
= (argstat
[i
].st_mode
&S_IFMT
) == S_IFBLK
) ||
364 (argstat
[i
].st_mode
& S_IFMT
) == S_IFCHR
) {
365 if (isblk
&& strcmp(mpath(cp
), "") != 0) {
369 dfreemnt(mp
->mnt_mountp
, mp
);
379 * Get this argument's corresponding mount table
382 mlp
= findmntent(cp
, &argstat
[i
], mntl
);
387 (void) fprintf(stderr
,
388 gettext("Could not find mount point for %s\n"),
393 dfreemnt(mlp
->mntl_mnt
->mnt_mountp
, mlp
->mntl_mnt
);
407 (void) printf(gettext("VFStype name - ufs\n"));
412 * Following string is used as a table header.
413 * Translated items should start at the same
414 * columns as the original items.
416 (void) printf(gettext(
417 "Filesystem ifree\n"));
421 * Following string is used as a table header.
422 * Translated items should start at the same
423 * columns as the original items.
425 (void) printf(gettext(
426 "Filesystem iused ifree %%iused Mounted on\n"));
432 * Following string is used as a table header.
433 * Translated items should start at the same
434 * columns as the original items.
436 (void) printf(gettext(
437 "Filesystem f_type f_fsize f_bfree f_bavail f_files f_ffree "
438 "f_fsid f_flag f_fstr\n"));
443 * Following string is used as a table header.
444 * Translated items should start at the same
445 * columns as the original items.
447 (void) printf(gettext(
448 "Filesystem avail\n"));
452 * Following string is used as a table header.
453 * Translated items should start at the same
454 * columns as the original items.
456 (void) printf(gettext(
457 "Filesystem kbytes used avail capacity Mounted on\n"));
463 * Report on a block or character special device. Assumed not to be
464 * mounted. N.B. checks for a valid UFS superblock.
469 fsblkcnt64_t totalblks
, availblks
, avail
, free
, used
;
472 fi
= open64(file
, 0);
474 (void) fprintf(stderr
, "df: ");
478 if (bread(file
, fi
, SBLOCK
, (char *)&sblock
, SBSIZE
) == 0) {
482 if ((sblock
.fs_magic
!= FS_MAGIC
) &&
483 (sblock
.fs_magic
!= MTB_UFS_MAGIC
)) {
484 (void) fprintf(stderr
, gettext(
485 "df: %s: not a ufs file system\n"),
490 if (sblock
.fs_magic
== FS_MAGIC
&&
491 (sblock
.fs_version
!= UFS_EFISTYLE4NONEFI_VERSION_2
&&
492 sblock
.fs_version
!= UFS_VERSION_MIN
)) {
493 (void) fprintf(stderr
, gettext(
494 "df: %s: unrecognized version of UFS: %d\n"),
495 file
, sblock
.fs_version
);
499 if (sblock
.fs_magic
== MTB_UFS_MAGIC
&&
500 (sblock
.fs_version
> MTB_UFS_VERSION_1
||
501 sblock
.fs_version
< MTB_UFS_VERSION_MIN
)) {
502 (void) fprintf(stderr
, gettext(
503 "df: %s: unrecognized version of UFS: %d\n"),
504 file
, sblock
.fs_version
);
508 (void) printf("%-20.20s", file
);
511 (void) printf("%8ld", sblock
.fs_cstotal
.cs_nifree
);
514 (fsfilcnt64_t
)sblock
.fs_ncg
*
515 (fsfilcnt64_t
)sblock
.fs_ipg
,
516 (fsfilcnt64_t
)sblock
.fs_cstotal
.cs_nifree
);
519 totalblks
= (fsblkcnt64_t
)sblock
.fs_dsize
;
521 (fsblkcnt64_t
)sblock
.fs_cstotal
.cs_nbfree
*
522 (fsblkcnt64_t
)sblock
.fs_frag
+
523 (fsblkcnt64_t
)sblock
.fs_cstotal
.cs_nffree
;
524 used
= totalblks
- free
;
525 availblks
= totalblks
/ (fsblkcnt64_t
)100 *
526 ((fsblkcnt64_t
)100 - (fsblkcnt64_t
)sblock
.fs_minfree
);
527 avail
= availblks
> used
? availblks
- used
: (fsblkcnt64_t
)0;
529 (void) printf("%8lld\n", dbtok(avail
,
530 (fsblkcnt64_t
)sblock
.fs_fsize
));
532 (void) printf(" %7lld %7lld %7lld",
533 dbtok(totalblks
, (fsblkcnt64_t
)sblock
.fs_fsize
),
534 dbtok(used
, (fsblkcnt64_t
)sblock
.fs_fsize
),
535 dbtok(avail
, (fsblkcnt64_t
)sblock
.fs_fsize
));
536 (void) printf("%6.0f%%",
537 availblks
== 0 ? 0.0 :
538 (double)used
/ (double)availblks
* 100.0);
542 t_totalblks
+= dbtok(totalblks
,
543 (fsblkcnt64_t
)sblock
.fs_fsize
);
544 t_used
+= dbtok(used
, (fsblkcnt64_t
)sblock
.fs_fsize
);
545 t_avail
+= dbtok(avail
, (fsblkcnt64_t
)sblock
.fs_fsize
);
549 if ((!bflag
) && (!eflag
))
550 (void) printf(" %s\n", mpath(file
));
557 dfreemnt(char *file
, struct mnttab
*mnt
)
561 if (statvfs64(file
, &fs
) < 0 &&
562 chroot_stat(file
, statvfs64
, (char *)&fs
, &file
) < 0) {
563 (void) fprintf(stderr
, "df: ");
568 if (!aflag
&& fs
.f_blocks
== 0) {
571 if (!isatty(fileno(stdout
))) {
572 (void) printf("%s", mnt
->mnt_special
);
574 if (strlen(mnt
->mnt_special
) > (size_t)20) {
575 (void) printf("%s\n", mnt
->mnt_special
);
578 (void) printf("%-20.20s", mnt
->mnt_special
);
583 (void) printf("%8lld", fs
.f_ffree
);
585 show_inode_usage(fs
.f_files
, fs
.f_ffree
);
591 fsblkcnt64_t totalblks
, avail
, free
, used
, reserved
;
593 totalblks
= fs
.f_blocks
;
595 used
= totalblks
- free
;
597 reserved
= free
- avail
;
598 if ((long long)avail
< 0)
601 (void) printf("%8lld\n", dbtok(avail
,
602 (fsblkcnt64_t
)fs
.f_frsize
));
604 (void) printf(" %7lld %7lld %7lld",
606 (fsblkcnt64_t
)fs
.f_frsize
),
607 dbtok(used
, (fsblkcnt64_t
)fs
.f_frsize
),
608 dbtok(avail
, (fsblkcnt64_t
)fs
.f_frsize
));
609 totalblks
-= reserved
;
610 (void) printf("%6.0f%%",
611 totalblks
== 0 ? 0.0 :
612 (double)used
/ (double)totalblks
* 100.0);
615 t_totalblks
+= dbtok(totalblks
+ reserved
,
616 (fsblkcnt64_t
)fs
.f_bsize
);
617 t_reserved
+= reserved
;
618 t_used
+= dbtok(used
,
619 (fsblkcnt64_t
)fs
.f_frsize
);
620 t_avail
+= dbtok(avail
,
621 (fsblkcnt64_t
)fs
.f_frsize
);
627 if ((!bflag
) && (!eflag
) && (!gflag
))
628 (void) printf(" %s\n", mnt
->mnt_mountp
);
634 show_inode_usage(fsfilcnt64_t total
, fsfilcnt64_t free
)
636 fsfilcnt64_t used
= total
- free
;
637 int missing_info
= ((long long)total
== (long long)-1 ||
638 (long long)free
== (long long)-1);
641 (void) printf("%8s", "*");
643 (void) printf("%8lld", used
);
644 if ((long long)free
== (long long)-1)
645 (void) printf("%8s", "*");
647 (void) printf(" %7lld", free
);
649 (void) printf("%6s ", "*");
651 (void) printf("%6.0f%% ", (double)used
/ (double)total
* 100.0);
655 * Return the suffix of path obtained by stripping off the prefix
656 * that is the value of the CHROOT environment variable. If this
657 * value isn't obtainable or if it's not a prefix of path, return NULL.
660 zap_chroot(char *path
)
662 return (pathsuffix(path
, chrootpath
));
666 * Stat/statfs a file after stripping off leading directory to which we are
667 * chroot'd. Used to find the TFS mount that applies to the current
668 * activated NSE environment.
671 chroot_stat(char *dir
, int (*statfunc
)(), char *statp
, char **dirp
)
673 if ((dir
= zap_chroot(dir
)) == NULL
)
677 return (*statfunc
)(dir
, statp
);
681 * Given a name like /dev/dsk/c1d0s2, returns the mounted path, like /usr.
688 struct stat64 device_stat
, mount_stat
;
691 mnttab
= fopen(MNTTAB
, "r");
692 if (mnttab
== NULL
) {
696 while ((getmntent(mnttab
, &mnt
)) == 0) {
697 if (strcmp(mnt
.mnt_fstype
, MNTTYPE_UFS
) != 0) {
700 if (strcmp(file
, mnt
.mnt_special
) == 0) {
701 if (stat64(mnt
.mnt_mountp
, &mount_stat
) != 0)
703 if (stat64(mnt
.mnt_special
, &device_stat
) != 0)
706 if (device_stat
.st_rdev
== mount_stat
.st_dev
) {
707 mname
= mnt
.mnt_mountp
;
717 * Given a special device, return mnttab entry
718 * Returns 0 on success
722 mdev(char *spec
, struct mnttab
**mntbp
)
727 if ((mntp
= fopen(MNTTAB
, "r")) == 0) {
728 (void) fprintf(stderr
, "df: ");
733 while (getmntent(mntp
, &mnt
) == 0) {
734 if (strcmp(spec
, mnt
.mnt_special
) == 0) {
736 *mntbp
= mntdup(&mnt
);
741 (void) fprintf(stderr
, "df : couldn't find mnttab entry for %s", spec
);
746 * Find the entry in mlist that corresponds to the file named by path
747 * (i.e., that names a mount table entry for the file system in which
748 * path lies). The pstat argument must point to stat information for
751 * Return the entry or NULL if there's no match.
753 * As it becomes necessary to obtain stat information about previously
754 * unexamined mlist entries, gather the information and cache it with the
757 * The routine's strategy is to convert path into its canonical, symlink-free
758 * representation canon (which will require accessing the file systems on the
759 * branch from the root to path and thus may cause the routine to hang if any
760 * of them are inaccessible) and to use it to search for a mount point whose
761 * name is a substring of canon and whose corresponding device matches that of
762 * canon. This technique avoids accessing unnecessary file system resources
763 * and thus prevents the program from hanging on inaccessible resources unless
764 * those resources are necessary for accessing path.
766 static struct mntlist
*
767 findmntent(char *path
, struct stat64
*pstat
, struct mntlist
*mlist
)
769 static char cwd
[MAXPATHLEN
];
770 char canon
[MAXPATHLEN
];
771 char scratch
[MAXPATHLEN
];
775 * If path is relative and we haven't already determined the current
776 * working directory, do so now. Calculating the working directory
777 * here lets us do the work once, instead of (potentially) repeatedly
780 if (*path
!= '/' && cwd
[0] == '\0') {
781 if (getcwd(cwd
, MAXPATHLEN
) == NULL
) {
788 * Find an absolute pathname in the native file system name space that
789 * corresponds to path, stuffing it into canon.
791 * If CHROOT is set in the environment, assume that chroot($CHROOT)
792 * (or an equivalent series of calls) was executed and convert the
793 * path to the equivalent name in the native file system's name space.
794 * Doing so allows direct comparison with the names in mtab entires,
795 * which are assumed to be recorded relative to the native name space.
797 if (abspath(cwd
, path
, scratch
) < 0)
799 if (strcmp(scratch
, "/") == 0 && chrootpath
!= NULL
) {
801 * Force canon to be in canonical form; if the result from
802 * abspath was "/" and chrootpath isn't the null string, we
803 * must strip off a trailing slash.
807 (void) sprintf(canon
, "%s%s", chrootpath
? chrootpath
: "", scratch
);
810 for (mlp
= mlist
; mlp
; mlp
= mlp
->mntl_next
) {
811 struct mnttab
*mnt
= mlp
->mntl_mnt
;
814 * Ignore uninteresting mounts.
816 if (strcmp(mnt
->mnt_fstype
, typestr
) != 0)
820 * The mount entry covers some prefix of the file.
821 * See whether it's the entry for the file system
822 * containing the file by comparing device ids.
824 if (mlp
->mntl_dev
== NODEV
) {
827 if (stat64(mnt
->mnt_mountp
, &fs_sb
) < 0 &&
828 chroot_stat(mnt
->mnt_mountp
, stat64
, (char *)&fs_sb
,
829 (char **)NULL
) < 0) {
832 mlp
->mntl_dev
= fs_sb
.st_dev
;
835 if (pstat
->st_dev
== mlp
->mntl_dev
)
843 * Convert the path given in raw to canonical, absolute, symlink-free
844 * form, storing the result in the buffer named by canon, which must be
845 * at least MAXPATHLEN bytes long. "wd" contains the current working
846 * directory; accepting this value as an argument lets our caller cache
847 * the value, so that realpath (called from this routine) doesn't have
848 * to recalculate it each time it's given a relative pathname.
850 * Return 0 on success, -1 on failure.
853 abspath(char *wd
, char *raw
, char *canon
)
855 char absbuf
[MAXPATHLEN
];
858 * Preliminary sanity check.
860 if (wd
== NULL
|| raw
== NULL
|| canon
== NULL
)
864 * If the path is relative, convert it to absolute form,
865 * using wd if it's been supplied.
868 char *limit
= absbuf
+ sizeof (absbuf
);
871 /* Fill in working directory. */
872 if (strlcpy(absbuf
, wd
, sizeof (absbuf
)) >= sizeof (absbuf
))
875 /* Add separating slash. */
876 d
= absbuf
+ strlen(absbuf
);
880 /* Glue on the relative part of the path. */
881 while (d
< limit
&& (*d
++ = *raw
++))
888 * Call realpath to canonicalize and resolve symlinks.
890 return (realpath(raw
, canon
) == NULL
? -1 : 0);
894 * Return a pointer to the trailing suffix of full that follows the prefix
895 * given by pref. If pref isn't a prefix of full, return NULL. Apply
896 * pathname semantics to the prefix test, so that pref must match at a
897 * component boundary.
900 pathsuffix(char *full
, char *pref
)
904 if (full
== NULL
|| pref
== NULL
)
907 preflen
= strlen(pref
);
908 if (strncmp(pref
, full
, preflen
) != 0)
912 * pref is a substring of full. To be a subpath, it cannot cover a
913 * partial component of full. The last clause of the test handles the
914 * special case of the root.
916 if (full
[preflen
] != '\0' && full
[preflen
] != '/' && preflen
> 1)
919 if (preflen
== 1 && full
[0] == '/')
922 return (full
+ preflen
);
926 * Return zero iff the path named by sub is a leading subpath
927 * of the path named by full.
929 * Treat null paths as matching nothing.
932 subpath(char *full
, char *sub
)
934 return (pathsuffix(full
, sub
) == NULL
);
940 bread(char *file
, int fi
, daddr_t bno
, char *buf
, int cnt
)
944 (void) llseek(fi
, (offset_t
)bno
* DEV_BSIZE
, 0);
945 if ((n
= read(fi
, buf
, cnt
)) < 0) {
946 /* probably a dismounted disk if errno == EIO */
948 (void) fprintf(stderr
, gettext("df: read error on "));
950 (void) fprintf(stderr
, "bno = %ld\n", bno
);
952 (void) fprintf(stderr
, gettext(
953 "df: premature EOF on %s\n"), file
);
954 (void) fprintf(stderr
,
955 "bno = %ld expected = %d count = %d\n", bno
, cnt
, n
);
963 xmalloc(unsigned int size
)
968 if ((ret
= (char *)malloc(size
)) == NULL
) {
969 (void) fprintf(stderr
, gettext("umount: ran out of memory!\n"));
976 mntdup(struct mnttab
*mnt
)
980 new = (struct mnttab
*)xmalloc(sizeof (*new));
983 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_special
) + 1));
984 (void) strcpy(new->mnt_special
, mnt
->mnt_special
);
987 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_mountp
) + 1));
988 (void) strcpy(new->mnt_mountp
, mnt
->mnt_mountp
);
991 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_fstype
) + 1));
992 (void) strcpy(new->mnt_fstype
, mnt
->mnt_fstype
);
994 if (mnt
->mnt_mntopts
!= NULL
) {
996 (char *)xmalloc((unsigned)(strlen(mnt
->mnt_mntopts
) + 1));
997 (void) strcpy(new->mnt_mntopts
, mnt
->mnt_mntopts
);
999 new->mnt_mntopts
= NULL
;
1003 new->mnt_freq
= mnt
->mnt_freq
;
1004 new->mnt_passno
= mnt
->mnt_passno
;
1014 (void) fprintf(stderr
, gettext(
1015 "ufs usage: df [generic options] [-o i] [directory | special]\n"));
1023 struct mntlist
*mntl
;
1024 struct mntlist
*mntst
= NULL
;
1025 struct extmnttab mnt
;
1027 if ((mounted
= fopen(MNTTAB
, "r")) == NULL
) {
1028 (void) fprintf(stderr
, "df : ");
1032 resetmnttab(mounted
);
1033 while (getextmntent(mounted
, &mnt
, sizeof (struct extmnttab
)) == 0) {
1034 mntl
= (struct mntlist
*)xmalloc(sizeof (*mntl
));
1035 mntl
->mntl_mnt
= mntdup((struct mnttab
*)(&mnt
));
1036 mntl
->mntl_next
= mntst
;
1037 mntl
->mntl_devvalid
= 1;
1038 mntl
->mntl_dev
= makedev(mnt
.mnt_major
, mnt
.mnt_minor
);
1041 (void) fclose(mounted
);
1046 print_statvfs(struct statvfs64
*fs
)
1050 for (i
= 0; i
< FSTYPSZ
; i
++)
1051 (void) printf("%c", fs
->f_basetype
[i
]);
1052 (void) printf(" %7d %7lld %7lld",
1056 (void) printf(" %7lld %7lld %7d",
1060 (void) printf(" 0x%x ",
1062 for (i
= 0; i
< 14; i
++)
1064 (fs
->f_fstr
[i
] == '\0') ? ' ' : fs
->f_fstr
[i
]);
1073 * Following string is used as a table header.
1074 * Translated items should start at the same
1075 * columns as the original items.
1077 (void) printf(gettext("Totals %8lld %7lld %7lld"),
1078 t_totalblks
, t_used
, t_avail
);
1079 (void) printf("%6.0f%%\n",
1080 (t_totalblks
- t_reserved
) == (fsblkcnt64_t
)0 ?
1082 (double)t_used
/ (double)(t_totalblks
- t_reserved
) * 100.0);
1090 * Following string is used as a table header.
1091 * Translated items should start at the same
1092 * columns as the original items.
1094 (void) printf(gettext("Totals %8d %7d%6.0f%%\n"),
1097 t_inodes
== 0 ? 0.0 : (double)t_iused
/ (double)t_inodes
* 100.0);