2 Return a list of mounted filesystems
4 Copyright (C) 1991, 1992, 2011
5 The Free Software Foundation, Inc.
7 This file is part of the Midnight Commander.
9 The Midnight Commander is free software: you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation, either version 3 of the License,
12 or (at your option) any later version.
14 The Midnight Commander is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * \brief Source: list of mounted filesystems
32 #include <sys/types.h>
34 /* This header needs to be included before sys/mount.h on *BSD */
35 #ifdef HAVE_SYS_PARAM_H
36 #include <sys/param.h>
39 #if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
40 #include <sys/mount.h>
41 #include <sys/fs_types.h>
42 #endif /* MOUNTED_GETFSSTAT */
44 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
47 #if defined(MNT_MNTTAB) /* HP-UX. */
48 #define MOUNTED MNT_MNTTAB
50 #if defined(MNTTABNAME) /* Dynix. */
51 #define MOUNTED MNTTABNAME
56 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
57 #include <sys/mount.h>
60 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */
61 #include <sys/statvfs.h>
62 #define statfs statvfs
65 #ifdef MOUNTED_GETMNT /* Ultrix. */
66 #include <sys/mount.h>
67 #include <sys/fs_types.h>
70 #ifdef MOUNTED_FREAD /* SVR2. */
74 #ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
76 #include <sys/fstyp.h>
77 #include <sys/statfs.h>
80 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */
81 #include <sys/mnttab.h>
84 #ifdef MOUNTED_VMOUNT /* AIX. */
89 #ifdef HAVE_SYS_STATFS_H
90 #include <sys/statfs.h>
93 #ifdef HAVE_INFOMOUNT_QNX
98 #ifdef HAVE_SYS_MOUNT_H
99 #include <sys/mount.h>
102 #ifdef HAVE_SYS_VFS_H
106 #ifdef HAVE_SYS_FILSYS_H
107 #include <sys/filsys.h> /* SVR2. */
110 #ifdef HAVE_DUSTAT_H /* AIX PS/2. */
111 #include <sys/dustat.h>
114 #ifdef HAVE_SYS_STATVFS_H /* SVR4. */
115 #include <sys/statvfs.h>
118 #include "lib/global.h"
119 #include "mountlist.h"
121 /*** global variables ****************************************************************************/
123 /*** file scope macro definitions ****************************************************************/
126 /* So special that it's not worth putting this in autoconf. */
127 #undef MOUNTED_FREAD_FSTYP
128 #define MOUNTED_GETMNTTBL
131 #if defined (__QNX__) && !defined(__QNXNTO__) && !defined (HAVE_INFOMOUNT_LIST)
132 #define HAVE_INFOMOUNT_QNX
135 #if defined(HAVE_INFOMOUNT_LIST) || defined(HAVE_INFOMOUNT_QNX)
136 #define HAVE_INFOMOUNT
139 /*** file scope type declarations ****************************************************************/
141 /* A mount table entry. */
144 char *me_devname
; /* Device node pathname, including "/dev/". */
145 char *me_mountdir
; /* Mount point directory pathname. */
146 char *me_type
; /* "nfs", "4.2", etc. */
147 dev_t me_dev
; /* Device number of me_mountdir. */
148 struct mount_entry
*me_next
;
153 fsblkcnt_t fsu_blocks
; /* Total blocks. */
154 fsblkcnt_t fsu_bfree
; /* Free blocks available to superuser. */
155 fsblkcnt_t fsu_bavail
; /* Free blocks available to non-superuser. */
156 fsfilcnt_t fsu_files
; /* Total file nodes. */
157 fsfilcnt_t fsu_ffree
; /* Free file nodes. */
160 /*** file scope variables ************************************************************************/
162 #ifdef HAVE_INFOMOUNT_LIST
163 static struct mount_entry
*mount_list
= NULL
;
164 #endif /* HAVE_INFOMOUNT_LIST */
166 /*** file scope functions ************************************************************************/
167 /* --------------------------------------------------------------------------------------------- */
169 #ifdef HAVE_INFOMOUNT_LIST
171 free_mount_entry (struct mount_entry
*me
)
176 free (me
->me_devname
);
178 free (me
->me_mountdir
);
184 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
186 /* --------------------------------------------------------------------------------------------- */
187 /* Return the value of the hexadecimal number represented by CP.
188 No prefix (like '0x') or suffix (like 'h') is expected to be
192 xatoi (const char *cp
)
199 if (*cp
>= 'a' && *cp
<= 'f')
200 val
= val
* 16 + *cp
- 'a' + 10;
201 else if (*cp
>= 'A' && *cp
<= 'F')
202 val
= val
* 16 + *cp
- 'A' + 10;
203 else if (*cp
>= '0' && *cp
<= '9')
204 val
= val
* 16 + *cp
- '0';
211 #endif /* MOUNTED_GETMNTENT1 */
213 #ifdef MOUNTED_GETMNTINFO
215 /* --------------------------------------------------------------------------------------------- */
217 #ifndef HAVE_STRUCT_STATFS_F_FSTYPENAME
219 fstype_to_string (short t
)
311 #endif /* ! HAVE_STRUCT_STATFS_F_FSTYPENAME */
313 #endif /* MOUNTED_GETMNTINFO */
315 /* --------------------------------------------------------------------------------------------- */
317 #ifdef MOUNTED_VMOUNT /* AIX. */
319 fstype_to_string (int t
)
323 e
= getvfsbytype (t
);
324 if (!e
|| !e
->vfsent_name
)
327 return e
->vfsent_name
;
329 #endif /* MOUNTED_VMOUNT */
331 /* --------------------------------------------------------------------------------------------- */
332 /** Return a list of the currently mounted filesystems, or NULL on error.
333 Add each entry to the tail of the list so that they stay in order.
334 If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
335 the returned list are valid. Otherwise, they might not be.
336 If ALL_FS is zero, do not return entries for filesystems that
337 are automounter (dummy) entries. */
339 static struct mount_entry
*
340 read_filesystem_list (int need_fs_type
, int all_fs
)
342 struct mount_entry
*mlist
;
343 struct mount_entry
*me
;
344 struct mount_entry
*mtail
;
349 /* Start the list off with a dummy entry. */
350 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
354 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
361 fp
= setmntent (MOUNTED
, "r");
365 while ((mnt
= getmntent (fp
)))
367 if (!all_fs
&& (!strcmp (mnt
->mnt_type
, "ignore") || !strcmp (mnt
->mnt_type
, "auto")))
370 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
371 me
->me_devname
= strdup (mnt
->mnt_fsname
);
372 me
->me_mountdir
= strdup (mnt
->mnt_dir
);
373 me
->me_type
= strdup (mnt
->mnt_type
);
374 devopt
= strstr (mnt
->mnt_opts
, "dev=");
377 if (devopt
[4] == '0' && (devopt
[5] == 'x' || devopt
[5] == 'X'))
378 me
->me_dev
= xatoi (devopt
+ 6);
380 me
->me_dev
= xatoi (devopt
+ 4);
383 me
->me_dev
= -1; /* Magic; means not known yet. */
386 /* Add to the linked list. */
391 if (endmntent (fp
) == 0)
395 #endif /* MOUNTED_GETMNTENT1 */
397 #if defined(MOUNTED_GETMNTINFO) || defined(MOUNTED_GETMNTINFO2) /* 4.4BSD and NetBSD >= 3 */
402 entries
= getmntinfo (&fsp
, MNT_NOWAIT
);
405 while (entries
-- > 0)
407 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
408 me
->me_devname
= strdup (fsp
->f_mntfromname
);
409 me
->me_mountdir
= strdup (fsp
->f_mntonname
);
410 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(MOUNTED_GETMNTINFO2)
411 me
->me_type
= strdup (fsp
->f_fstypename
);
413 me
->me_type
= fstype_to_string (fsp
->f_type
);
415 me
->me_dev
= -1; /* Magic; means not known yet. */
418 /* Add to the linked list. */
424 #endif /* MOUNTED_GETMNTINFO || MOUNTED_GETMNTINFO2 */
426 #ifdef MOUNTED_GETMNT /* Ultrix. */
432 while ((val
= getmnt (&offset
, &fsd
, sizeof (fsd
), NOSTAT_MANY
, NULL
)) > 0)
434 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
435 me
->me_devname
= strdup (fsd
.fd_req
.devname
);
436 me
->me_mountdir
= strdup (fsd
.fd_req
.path
);
437 me
->me_type
= gt_names
[fsd
.fd_req
.fstype
];
438 me
->me_dev
= fsd
.fd_req
.dev
;
441 /* Add to the linked list. */
448 #endif /* MOUNTED_GETMNT */
450 #ifdef MOUNTED_GETFSSTAT /* __alpha running OSF_1 */
452 int numsys
, counter
, bufsize
;
453 struct statfs
*stats
;
455 numsys
= getfsstat ((struct statfs
*) 0, 0L, MNT_WAIT
);
459 bufsize
= (1 + numsys
) * sizeof (struct statfs
);
460 stats
= (struct statfs
*) malloc (bufsize
);
461 numsys
= getfsstat (stats
, bufsize
, MNT_WAIT
);
468 for (counter
= 0; counter
< numsys
; counter
++)
470 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
471 me
->me_devname
= strdup (stats
[counter
].f_mntfromname
);
472 me
->me_mountdir
= strdup (stats
[counter
].f_mntonname
);
473 me
->me_type
= mnt_names
[stats
[counter
].f_type
];
474 me
->me_dev
= -1; /* Magic; means not known yet. */
477 /* Add to the linked list. */
484 #endif /* MOUNTED_GETFSSTAT */
486 #if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */
489 char *table
= "/etc/mnttab";
492 fp
= fopen (table
, "r");
496 while (fread (&mnt
, sizeof mnt
, 1, fp
) > 0)
498 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
499 #ifdef GETFSTYP /* SVR3. */
500 me
->me_devname
= strdup (mnt
.mt_dev
);
502 me
->me_devname
= malloc (strlen (mnt
.mt_dev
) + 6);
503 strcpy (me
->me_devname
, "/dev/");
504 strcpy (me
->me_devname
+ 5, mnt
.mt_dev
);
506 me
->me_mountdir
= strdup (mnt
.mt_filsys
);
507 me
->me_dev
= -1; /* Magic; means not known yet. */
509 #ifdef GETFSTYP /* SVR3. */
513 char typebuf
[FSTYPSZ
];
515 if (statfs (me
->me_mountdir
, &fsd
, sizeof fsd
, 0) != -1
516 && sysfs (GETFSTYP
, fsd
.f_fstyp
, typebuf
) != -1)
517 me
->me_type
= strdup (typebuf
);
522 /* Add to the linked list. */
527 if (fclose (fp
) == EOF
)
530 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP */
532 #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
534 struct mntent
**mnttbl
= getmnttbl (), **ent
;
535 for (ent
= mnttbl
; *ent
; ent
++)
537 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
538 me
->me_devname
= strdup ((*ent
)->mt_resource
);
539 me
->me_mountdir
= strdup ((*ent
)->mt_directory
);
540 me
->me_type
= strdup ((*ent
)->mt_fstype
);
541 me
->me_dev
= -1; /* Magic; means not known yet. */
544 /* Add to the linked list. */
550 #endif /* MOUNTED_GETMNTTBL */
552 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */
555 const char *table
= MNTTAB
;
559 fp
= fopen (table
, "r");
563 while ((ret
= getmntent (fp
, &mnt
)) == 0)
565 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
566 me
->me_devname
= strdup (mnt
.mnt_special
);
567 me
->me_mountdir
= strdup (mnt
.mnt_mountp
);
568 me
->me_type
= strdup (mnt
.mnt_fstype
);
569 me
->me_dev
= -1; /* Magic; means not known yet. */
571 /* Add to the linked list. */
578 if (fclose (fp
) == EOF
)
581 #endif /* MOUNTED_GETMNTENT2 */
583 #ifdef MOUNTED_VMOUNT /* AIX. */
586 char *entries
, *thisent
;
589 /* Ask how many bytes to allocate for the mounted filesystem info. */
590 mntctl (MCTL_QUERY
, sizeof bufsize
, (struct vmount
*) &bufsize
);
591 entries
= malloc (bufsize
);
593 /* Get the list of mounted filesystems. */
594 mntctl (MCTL_QUERY
, bufsize
, (struct vmount
*) entries
);
596 for (thisent
= entries
; thisent
< entries
+ bufsize
; thisent
+= vmp
->vmt_length
)
598 vmp
= (struct vmount
*) thisent
;
599 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
600 if (vmp
->vmt_flags
& MNT_REMOTE
)
604 /* Prepend the remote pathname. */
605 host
= thisent
+ vmp
->vmt_data
[VMT_HOSTNAME
].vmt_off
;
606 path
= thisent
+ vmp
->vmt_data
[VMT_OBJECT
].vmt_off
;
607 me
->me_devname
= malloc (strlen (host
) + strlen (path
) + 2);
608 strcpy (me
->me_devname
, host
);
609 strcat (me
->me_devname
, ":");
610 strcat (me
->me_devname
, path
);
614 me
->me_devname
= strdup (thisent
+ vmp
->vmt_data
[VMT_OBJECT
].vmt_off
);
616 me
->me_mountdir
= strdup (thisent
+ vmp
->vmt_data
[VMT_STUB
].vmt_off
);
617 me
->me_type
= strdup (fstype_to_string (vmp
->vmt_gfstype
));
618 me
->me_dev
= -1; /* vmt_fsid might be the info we want. */
621 /* Add to the linked list. */
627 #endif /* MOUNTED_VMOUNT */
629 /* Free the dummy head. */
631 mlist
= mlist
->me_next
;
635 #endif /* HAVE_INFOMOUNT_LIST */
637 /* --------------------------------------------------------------------------------------------- */
639 #ifdef HAVE_INFOMOUNT_QNX
641 ** QNX has no [gs]etmnt*(), [gs]etfs*(), or /etc/mnttab, but can do
642 ** this via the following code.
643 ** Note that, as this is based on CWD, it only fills one mount_entry
644 ** structure. See my_statfs() in utilunix.c for the "other side" of
648 static struct mount_entry
*
649 read_filesystem_list (int need_fs_type
, int all_fs
)
651 struct _disk_entry de
;
654 char *tp
, dev
[_POSIX_NAME_MAX
], dir
[_POSIX_PATH_MAX
];
656 static struct mount_entry
*me
= NULL
;
661 free (me
->me_devname
);
663 free (me
->me_mountdir
);
668 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
670 if (!getcwd (dir
, _POSIX_PATH_MAX
))
673 fd
= open (dir
, O_RDONLY
);
677 i
= disk_get_entry (fd
, &de
);
684 switch (de
.disk_type
)
711 if (fsys_get_mount_dev (dir
, &dev
) == -1)
714 if (fsys_get_mount_pt (dev
, &dir
) == -1)
717 me
->me_devname
= strdup (dev
);
718 me
->me_mountdir
= strdup (dir
);
719 me
->me_type
= strdup (tp
);
720 me
->me_dev
= de
.disk_type
;
724 "disk_get_entry():\n\tdisk_type=%d (%s)\n\tdriver_name='%-*.*s'\n\tdisk_drv=%d\n",
725 de
.disk_type
, tp
, _DRIVER_NAME_LEN
, _DRIVER_NAME_LEN
, de
.driver_name
, de
.disk_drv
);
726 fprintf (stderr
, "fsys_get_mount_dev():\n\tdevice='%s'\n", dev
);
727 fprintf (stderr
, "fsys_get_mount_pt():\n\tmount point='%s'\n", dir
);
732 #endif /* HAVE_INFOMOUNT_QNX */
734 #ifdef HAVE_INFOMOUNT
735 /** Return the number of TOSIZE-byte blocks used by
736 BLOCKS FROMSIZE-byte blocks, rounding away from zero.
737 TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
740 fs_adjust_blocks (fsblkcnt_t blocks
, int fromsize
, int tosize
)
747 if (fromsize
== tosize
) /* E.g., from 512 to 512. */
749 else if (fromsize
> tosize
) /* E.g., from 2048 to 512. */
750 return blocks
* (fromsize
/ tosize
);
751 else /* E.g., from 256 to 512. */
752 return blocks
/ (tosize
/ fromsize
);
755 /* --------------------------------------------------------------------------------------------- */
756 #if defined(_AIX) && defined(_I386)
757 /* AIX PS/2 does not supply statfs. */
759 aix_statfs (char *path
, struct statfs
*fsb
)
764 if (stat (path
, &stats
))
766 if (dustat (stats
.st_dev
, 0, &fsd
, sizeof (fsd
)))
769 fsb
->f_bsize
= fsd
.du_bsize
;
770 fsb
->f_blocks
= fsd
.du_fsize
- fsd
.du_isize
;
771 fsb
->f_bfree
= fsd
.du_tfree
;
772 fsb
->f_bavail
= fsd
.du_tfree
;
773 fsb
->f_files
= (fsd
.du_isize
- 2) * fsd
.du_inopb
;
774 fsb
->f_ffree
= fsd
.du_tinode
;
775 fsb
->f_fsid
.val
[0] = fsd
.du_site
;
776 fsb
->f_fsid
.val
[1] = fsd
.du_pckno
;
780 #define statfs(path,fsb) aix_statfs(path,fsb)
781 #endif /* _AIX && _I386 */
783 /* Fill in the fields of FSP with information about space usage for
784 the filesystem on which PATH resides.
785 Return 0 if successful, -1 if not. */
787 /* --------------------------------------------------------------------------------------------- */
789 get_fs_usage (char *path
, struct fs_usage
*fsp
)
791 #ifdef STAT_STATFS3_OSF1
794 if (statfs (path
, &fsd
, sizeof (struct statfs
)) != 0)
796 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_fsize, 512)
797 #endif /* STAT_STATFS3_OSF1 */
799 #ifdef STAT_STATFS2_FS_DATA /* Ultrix. */
802 if (statfs (path
, &fsd
) != 1)
804 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), 1024, 512)
805 fsp
->fsu_blocks
= CONVERT_BLOCKS (fsd
.fd_req
.btot
);
806 fsp
->fsu_bfree
= CONVERT_BLOCKS (fsd
.fd_req
.bfree
);
807 fsp
->fsu_bavail
= CONVERT_BLOCKS (fsd
.fd_req
.bfreen
);
808 fsp
->fsu_files
= fsd
.fd_req
.gtot
;
809 fsp
->fsu_ffree
= fsd
.fd_req
.gfree
;
812 #ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */
815 if (statfs (path
, &fsd
) < 0)
817 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512)
820 #ifdef STAT_STATFS2_FSIZE /* 4.4BSD. */
823 if (statfs (path
, &fsd
) < 0)
825 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_fsize, 512)
828 #ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX. */
831 if (statfs (path
, &fsd
, sizeof fsd
, 0) < 0)
833 /* Empirically, the block counts on most SVR3 and SVR3-derived
834 systems seem to always be in terms of 512-byte blocks,
835 no matter what value f_bsize has. */
837 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512)
839 #define CONVERT_BLOCKS(b) (b)
840 #ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */
841 #ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
842 #define f_bavail f_bfree
848 #ifdef STAT_STATVFS /* SVR4. */
851 if (statvfs (path
, &fsd
) < 0)
853 /* f_frsize isn't guaranteed to be supported. */
854 #define CONVERT_BLOCKS(b) \
855 fs_adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
858 #if defined(CONVERT_BLOCKS) && !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) /* !Ultrix && !SVR2. */
859 fsp
->fsu_blocks
= CONVERT_BLOCKS (fsd
.f_blocks
);
860 fsp
->fsu_bfree
= CONVERT_BLOCKS (fsd
.f_bfree
);
861 fsp
->fsu_bavail
= CONVERT_BLOCKS (fsd
.f_bavail
);
862 fsp
->fsu_files
= fsd
.f_files
;
863 fsp
->fsu_ffree
= fsd
.f_ffree
;
869 #endif /* HAVE_INFOMOUNT */
871 /* --------------------------------------------------------------------------------------------- */
872 /*** public functions ****************************************************************************/
873 /* --------------------------------------------------------------------------------------------- */
876 free_my_statfs (void)
878 #ifdef HAVE_INFOMOUNT_LIST
881 struct mount_entry
*next
= mount_list
->me_next
;
882 free_mount_entry (mount_list
);
886 #endif /* HAVE_INFOMOUNT_LIST */
889 /* --------------------------------------------------------------------------------------------- */
892 init_my_statfs (void)
894 #ifdef HAVE_INFOMOUNT_LIST
896 mount_list
= read_filesystem_list (1, 1);
897 #endif /* HAVE_INFOMOUNT_LIST */
900 /* --------------------------------------------------------------------------------------------- */
903 my_statfs (struct my_statfs
*myfs_stats
, const char *path
)
905 #ifdef HAVE_INFOMOUNT_LIST
907 struct mount_entry
*entry
= NULL
;
908 struct mount_entry
*temp
= mount_list
;
909 struct fs_usage fs_use
;
913 i
= strlen (temp
->me_mountdir
);
914 if (i
> len
&& (strncmp (path
, temp
->me_mountdir
, i
) == 0))
915 if (!entry
|| (path
[i
] == PATH_SEP
|| path
[i
] == '\0'))
920 temp
= temp
->me_next
;
925 memset (&fs_use
, 0, sizeof (struct fs_usage
));
926 get_fs_usage (entry
->me_mountdir
, &fs_use
);
928 myfs_stats
->type
= entry
->me_dev
;
929 myfs_stats
->typename
= entry
->me_type
;
930 myfs_stats
->mpoint
= entry
->me_mountdir
;
931 myfs_stats
->device
= entry
->me_devname
;
932 myfs_stats
->avail
= (uintmax_t) (getuid () ? fs_use
.fsu_bavail
: fs_use
.fsu_bfree
) / 2;
933 myfs_stats
->total
= (uintmax_t) fs_use
.fsu_blocks
/ 2;
934 myfs_stats
->nfree
= (uintmax_t) fs_use
.fsu_ffree
;
935 myfs_stats
->nodes
= (uintmax_t) fs_use
.fsu_files
;
938 #endif /* HAVE_INFOMOUNT_LIST */
940 #ifdef HAVE_INFOMOUNT_QNX
942 ** This is the "other side" of the hack to read_filesystem_list() in
944 ** It's not the most efficient approach, but consumes less memory. It
945 ** also accomodates QNX's ability to mount filesystems on the fly.
947 struct mount_entry
*entry
;
948 struct fs_usage fs_use
;
950 entry
= read_filesystem_list (0, 0);
953 get_fs_usage (entry
->me_mountdir
, &fs_use
);
955 myfs_stats
->type
= entry
->me_dev
;
956 myfs_stats
->typename
= entry
->me_type
;
957 myfs_stats
->mpoint
= entry
->me_mountdir
;
958 myfs_stats
->device
= entry
->me_devname
;
960 myfs_stats
->avail
= (uintmax_t) fs_use
.fsu_bfree
/ 2;
961 myfs_stats
->total
= (uintmax_t) fs_use
.fsu_blocks
/ 2;
962 myfs_stats
->nfree
= (uintmax_t) fs_use
.fsu_ffree
;
963 myfs_stats
->nodes
= (uintmax_t) fs_use
.fsu_files
;
966 #endif /* HAVE_INFOMOUNT_QNX */
968 myfs_stats
->type
= 0;
969 myfs_stats
->mpoint
= "unknown";
970 myfs_stats
->device
= "unknown";
971 myfs_stats
->avail
= 0;
972 myfs_stats
->total
= 0;
973 myfs_stats
->nfree
= 0;
974 myfs_stats
->nodes
= 0;
978 /* --------------------------------------------------------------------------------------------- */