1 /* mountlist.c -- return a list of mounted filesystems
2 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 * \brief Source: list of mounted filesystems
27 #include <sys/types.h>
29 /* This header needs to be included before sys/mount.h on *BSD */
30 #ifdef HAVE_SYS_PARAM_H
31 #include <sys/param.h>
34 #if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
35 #include <sys/mount.h>
36 #include <sys/fs_types.h>
37 #endif /* MOUNTED_GETFSSTAT */
39 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
42 #if defined(MNT_MNTTAB) /* HP-UX. */
43 #define MOUNTED MNT_MNTTAB
45 #if defined(MNTTABNAME) /* Dynix. */
46 #define MOUNTED MNTTABNAME
51 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
52 #include <sys/mount.h>
55 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */
56 #include <sys/statvfs.h>
57 #define statfs statvfs
60 #ifdef MOUNTED_GETMNT /* Ultrix. */
61 #include <sys/mount.h>
62 #include <sys/fs_types.h>
65 #ifdef MOUNTED_FREAD /* SVR2. */
69 #ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
71 #include <sys/fstyp.h>
72 #include <sys/statfs.h>
75 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */
76 #include <sys/mnttab.h>
79 #ifdef MOUNTED_VMOUNT /* AIX. */
84 #ifdef HAVE_SYS_STATFS_H
85 #include <sys/statfs.h>
88 #ifdef HAVE_INFOMOUNT_QNX
93 #ifdef HAVE_SYS_MOUNT_H
94 #include <sys/mount.h>
101 #ifdef HAVE_SYS_FILSYS_H
102 #include <sys/filsys.h> /* SVR2. */
105 #ifdef HAVE_DUSTAT_H /* AIX PS/2. */
106 #include <sys/dustat.h>
109 #ifdef HAVE_SYS_STATVFS_H /* SVR4. */
110 #include <sys/statvfs.h>
113 #include "lib/global.h"
114 #include "mountlist.h"
116 /*** global variables ****************************************************************************/
118 /*** file scope macro definitions ****************************************************************/
121 /* So special that it's not worth putting this in autoconf. */
122 #undef MOUNTED_FREAD_FSTYP
123 #define MOUNTED_GETMNTTBL
126 #if defined (__QNX__) && !defined(__QNXNTO__) && !defined (HAVE_INFOMOUNT_LIST)
127 #define HAVE_INFOMOUNT_QNX
130 #if defined(HAVE_INFOMOUNT_LIST) || defined(HAVE_INFOMOUNT_QNX)
131 #define HAVE_INFOMOUNT
134 /*** file scope type declarations ****************************************************************/
136 /* A mount table entry. */
139 char *me_devname
; /* Device node pathname, including "/dev/". */
140 char *me_mountdir
; /* Mount point directory pathname. */
141 char *me_type
; /* "nfs", "4.2", etc. */
142 dev_t me_dev
; /* Device number of me_mountdir. */
143 struct mount_entry
*me_next
;
148 fsblkcnt_t fsu_blocks
; /* Total blocks. */
149 fsblkcnt_t fsu_bfree
; /* Free blocks available to superuser. */
150 fsblkcnt_t fsu_bavail
; /* Free blocks available to non-superuser. */
151 fsfilcnt_t fsu_files
; /* Total file nodes. */
152 fsfilcnt_t fsu_ffree
; /* Free file nodes. */
155 /*** file scope variables ************************************************************************/
157 static int get_fs_usage (char *path
, struct fs_usage
*fsp
);
159 #ifdef HAVE_INFOMOUNT_LIST
160 static struct mount_entry
*mount_list
= NULL
;
161 #endif /* HAVE_INFOMOUNT_LIST */
163 /*** file scope functions ************************************************************************/
164 /* --------------------------------------------------------------------------------------------- */
166 #ifdef HAVE_INFOMOUNT_LIST
168 free_mount_entry (struct mount_entry
*me
)
173 free (me
->me_devname
);
175 free (me
->me_mountdir
);
181 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
183 /* --------------------------------------------------------------------------------------------- */
184 /* Return the value of the hexadecimal number represented by CP.
185 No prefix (like '0x') or suffix (like 'h') is expected to be
189 xatoi (const char *cp
)
196 if (*cp
>= 'a' && *cp
<= 'f')
197 val
= val
* 16 + *cp
- 'a' + 10;
198 else if (*cp
>= 'A' && *cp
<= 'F')
199 val
= val
* 16 + *cp
- 'A' + 10;
200 else if (*cp
>= '0' && *cp
<= '9')
201 val
= val
* 16 + *cp
- '0';
208 #endif /* MOUNTED_GETMNTENT1 */
210 #ifdef MOUNTED_GETMNTINFO
212 /* --------------------------------------------------------------------------------------------- */
214 #ifndef HAVE_STRUCT_STATFS_F_FSTYPENAME
216 fstype_to_string (short t
)
308 #endif /* ! HAVE_STRUCT_STATFS_F_FSTYPENAME */
310 #endif /* MOUNTED_GETMNTINFO */
312 /* --------------------------------------------------------------------------------------------- */
314 #ifdef MOUNTED_VMOUNT /* AIX. */
316 fstype_to_string (int t
)
320 e
= getvfsbytype (t
);
321 if (!e
|| !e
->vfsent_name
)
324 return e
->vfsent_name
;
326 #endif /* MOUNTED_VMOUNT */
328 /* --------------------------------------------------------------------------------------------- */
329 /** Return a list of the currently mounted filesystems, or NULL on error.
330 Add each entry to the tail of the list so that they stay in order.
331 If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
332 the returned list are valid. Otherwise, they might not be.
333 If ALL_FS is zero, do not return entries for filesystems that
334 are automounter (dummy) entries. */
336 static struct mount_entry
*
337 read_filesystem_list (int need_fs_type
, int all_fs
)
339 struct mount_entry
*mlist
;
340 struct mount_entry
*me
;
341 struct mount_entry
*mtail
;
346 /* Start the list off with a dummy entry. */
347 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
351 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
358 fp
= setmntent (MOUNTED
, "r");
362 while ((mnt
= getmntent (fp
)))
364 if (!all_fs
&& (!strcmp (mnt
->mnt_type
, "ignore") || !strcmp (mnt
->mnt_type
, "auto")))
367 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
368 me
->me_devname
= strdup (mnt
->mnt_fsname
);
369 me
->me_mountdir
= strdup (mnt
->mnt_dir
);
370 me
->me_type
= strdup (mnt
->mnt_type
);
371 devopt
= strstr (mnt
->mnt_opts
, "dev=");
374 if (devopt
[4] == '0' && (devopt
[5] == 'x' || devopt
[5] == 'X'))
375 me
->me_dev
= xatoi (devopt
+ 6);
377 me
->me_dev
= xatoi (devopt
+ 4);
380 me
->me_dev
= -1; /* Magic; means not known yet. */
383 /* Add to the linked list. */
388 if (endmntent (fp
) == 0)
392 #endif /* MOUNTED_GETMNTENT1 */
394 #if defined(MOUNTED_GETMNTINFO) || defined(MOUNTED_GETMNTINFO2) /* 4.4BSD and NetBSD >= 3 */
399 entries
= getmntinfo (&fsp
, MNT_NOWAIT
);
402 while (entries
-- > 0)
404 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
405 me
->me_devname
= strdup (fsp
->f_mntfromname
);
406 me
->me_mountdir
= strdup (fsp
->f_mntonname
);
407 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(MOUNTED_GETMNTINFO2)
408 me
->me_type
= strdup (fsp
->f_fstypename
);
410 me
->me_type
= fstype_to_string (fsp
->f_type
);
412 me
->me_dev
= -1; /* Magic; means not known yet. */
415 /* Add to the linked list. */
421 #endif /* MOUNTED_GETMNTINFO || MOUNTED_GETMNTINFO2 */
423 #ifdef MOUNTED_GETMNT /* Ultrix. */
429 while ((val
= getmnt (&offset
, &fsd
, sizeof (fsd
), NOSTAT_MANY
, NULL
)) > 0)
431 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
432 me
->me_devname
= strdup (fsd
.fd_req
.devname
);
433 me
->me_mountdir
= strdup (fsd
.fd_req
.path
);
434 me
->me_type
= gt_names
[fsd
.fd_req
.fstype
];
435 me
->me_dev
= fsd
.fd_req
.dev
;
438 /* Add to the linked list. */
445 #endif /* MOUNTED_GETMNT */
447 #ifdef MOUNTED_GETFSSTAT /* __alpha running OSF_1 */
449 int numsys
, counter
, bufsize
;
450 struct statfs
*stats
;
452 numsys
= getfsstat ((struct statfs
*) 0, 0L, MNT_WAIT
);
456 bufsize
= (1 + numsys
) * sizeof (struct statfs
);
457 stats
= (struct statfs
*) malloc (bufsize
);
458 numsys
= getfsstat (stats
, bufsize
, MNT_WAIT
);
465 for (counter
= 0; counter
< numsys
; counter
++)
467 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
468 me
->me_devname
= strdup (stats
[counter
].f_mntfromname
);
469 me
->me_mountdir
= strdup (stats
[counter
].f_mntonname
);
470 me
->me_type
= mnt_names
[stats
[counter
].f_type
];
471 me
->me_dev
= -1; /* Magic; means not known yet. */
474 /* Add to the linked list. */
481 #endif /* MOUNTED_GETFSSTAT */
483 #if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */
486 char *table
= "/etc/mnttab";
489 fp
= fopen (table
, "r");
493 while (fread (&mnt
, sizeof mnt
, 1, fp
) > 0)
495 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
496 #ifdef GETFSTYP /* SVR3. */
497 me
->me_devname
= strdup (mnt
.mt_dev
);
499 me
->me_devname
= malloc (strlen (mnt
.mt_dev
) + 6);
500 strcpy (me
->me_devname
, "/dev/");
501 strcpy (me
->me_devname
+ 5, mnt
.mt_dev
);
503 me
->me_mountdir
= strdup (mnt
.mt_filsys
);
504 me
->me_dev
= -1; /* Magic; means not known yet. */
506 #ifdef GETFSTYP /* SVR3. */
510 char typebuf
[FSTYPSZ
];
512 if (statfs (me
->me_mountdir
, &fsd
, sizeof fsd
, 0) != -1
513 && sysfs (GETFSTYP
, fsd
.f_fstyp
, typebuf
) != -1)
514 me
->me_type
= strdup (typebuf
);
519 /* Add to the linked list. */
524 if (fclose (fp
) == EOF
)
527 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP */
529 #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
531 struct mntent
**mnttbl
= getmnttbl (), **ent
;
532 for (ent
= mnttbl
; *ent
; ent
++)
534 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
535 me
->me_devname
= strdup ((*ent
)->mt_resource
);
536 me
->me_mountdir
= strdup ((*ent
)->mt_directory
);
537 me
->me_type
= strdup ((*ent
)->mt_fstype
);
538 me
->me_dev
= -1; /* Magic; means not known yet. */
541 /* Add to the linked list. */
547 #endif /* MOUNTED_GETMNTTBL */
549 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */
552 const char *table
= MNTTAB
;
556 fp
= fopen (table
, "r");
560 while ((ret
= getmntent (fp
, &mnt
)) == 0)
562 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
563 me
->me_devname
= strdup (mnt
.mnt_special
);
564 me
->me_mountdir
= strdup (mnt
.mnt_mountp
);
565 me
->me_type
= strdup (mnt
.mnt_fstype
);
566 me
->me_dev
= -1; /* Magic; means not known yet. */
568 /* Add to the linked list. */
575 if (fclose (fp
) == EOF
)
578 #endif /* MOUNTED_GETMNTENT2 */
580 #ifdef MOUNTED_VMOUNT /* AIX. */
583 char *entries
, *thisent
;
586 /* Ask how many bytes to allocate for the mounted filesystem info. */
587 mntctl (MCTL_QUERY
, sizeof bufsize
, (struct vmount
*) &bufsize
);
588 entries
= malloc (bufsize
);
590 /* Get the list of mounted filesystems. */
591 mntctl (MCTL_QUERY
, bufsize
, (struct vmount
*) entries
);
593 for (thisent
= entries
; thisent
< entries
+ bufsize
; thisent
+= vmp
->vmt_length
)
595 vmp
= (struct vmount
*) thisent
;
596 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
597 if (vmp
->vmt_flags
& MNT_REMOTE
)
601 /* Prepend the remote pathname. */
602 host
= thisent
+ vmp
->vmt_data
[VMT_HOSTNAME
].vmt_off
;
603 path
= thisent
+ vmp
->vmt_data
[VMT_OBJECT
].vmt_off
;
604 me
->me_devname
= malloc (strlen (host
) + strlen (path
) + 2);
605 strcpy (me
->me_devname
, host
);
606 strcat (me
->me_devname
, ":");
607 strcat (me
->me_devname
, path
);
611 me
->me_devname
= strdup (thisent
+ vmp
->vmt_data
[VMT_OBJECT
].vmt_off
);
613 me
->me_mountdir
= strdup (thisent
+ vmp
->vmt_data
[VMT_STUB
].vmt_off
);
614 me
->me_type
= strdup (fstype_to_string (vmp
->vmt_gfstype
));
615 me
->me_dev
= -1; /* vmt_fsid might be the info we want. */
618 /* Add to the linked list. */
624 #endif /* MOUNTED_VMOUNT */
626 /* Free the dummy head. */
628 mlist
= mlist
->me_next
;
632 #endif /* HAVE_INFOMOUNT_LIST */
634 /* --------------------------------------------------------------------------------------------- */
636 #ifdef HAVE_INFOMOUNT_QNX
638 ** QNX has no [gs]etmnt*(), [gs]etfs*(), or /etc/mnttab, but can do
639 ** this via the following code.
640 ** Note that, as this is based on CWD, it only fills one mount_entry
641 ** structure. See my_statfs() in utilunix.c for the "other side" of
645 static struct mount_entry
*
646 read_filesystem_list (int need_fs_type
, int all_fs
)
648 struct _disk_entry de
;
651 char *tp
, dev
[_POSIX_NAME_MAX
], dir
[_POSIX_PATH_MAX
];
653 static struct mount_entry
*me
= NULL
;
658 free (me
->me_devname
);
660 free (me
->me_mountdir
);
665 me
= (struct mount_entry
*) malloc (sizeof (struct mount_entry
));
667 if (!getcwd (dir
, _POSIX_PATH_MAX
))
670 fd
= open (dir
, O_RDONLY
);
674 i
= disk_get_entry (fd
, &de
);
681 switch (de
.disk_type
)
708 if (fsys_get_mount_dev (dir
, &dev
) == -1)
711 if (fsys_get_mount_pt (dev
, &dir
) == -1)
714 me
->me_devname
= strdup (dev
);
715 me
->me_mountdir
= strdup (dir
);
716 me
->me_type
= strdup (tp
);
717 me
->me_dev
= de
.disk_type
;
721 "disk_get_entry():\n\tdisk_type=%d (%s)\n\tdriver_name='%-*.*s'\n\tdisk_drv=%d\n",
722 de
.disk_type
, tp
, _DRIVER_NAME_LEN
, _DRIVER_NAME_LEN
, de
.driver_name
, de
.disk_drv
);
723 fprintf (stderr
, "fsys_get_mount_dev():\n\tdevice='%s'\n", dev
);
724 fprintf (stderr
, "fsys_get_mount_pt():\n\tmount point='%s'\n", dir
);
729 #endif /* HAVE_INFOMOUNT_QNX */
731 #ifdef HAVE_INFOMOUNT
732 /** Return the number of TOSIZE-byte blocks used by
733 BLOCKS FROMSIZE-byte blocks, rounding away from zero.
734 TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
737 fs_adjust_blocks (fsblkcnt_t blocks
, int fromsize
, int tosize
)
744 if (fromsize
== tosize
) /* E.g., from 512 to 512. */
746 else if (fromsize
> tosize
) /* E.g., from 2048 to 512. */
747 return blocks
* (fromsize
/ tosize
);
748 else /* E.g., from 256 to 512. */
749 return blocks
/ (tosize
/ fromsize
);
752 /* --------------------------------------------------------------------------------------------- */
753 #if defined(_AIX) && defined(_I386)
754 /* AIX PS/2 does not supply statfs. */
756 aix_statfs (char *path
, struct statfs
*fsb
)
761 if (stat (path
, &stats
))
763 if (dustat (stats
.st_dev
, 0, &fsd
, sizeof (fsd
)))
766 fsb
->f_bsize
= fsd
.du_bsize
;
767 fsb
->f_blocks
= fsd
.du_fsize
- fsd
.du_isize
;
768 fsb
->f_bfree
= fsd
.du_tfree
;
769 fsb
->f_bavail
= fsd
.du_tfree
;
770 fsb
->f_files
= (fsd
.du_isize
- 2) * fsd
.du_inopb
;
771 fsb
->f_ffree
= fsd
.du_tinode
;
772 fsb
->f_fsid
.val
[0] = fsd
.du_site
;
773 fsb
->f_fsid
.val
[1] = fsd
.du_pckno
;
777 #define statfs(path,fsb) aix_statfs(path,fsb)
778 #endif /* _AIX && _I386 */
780 /* Fill in the fields of FSP with information about space usage for
781 the filesystem on which PATH resides.
782 Return 0 if successful, -1 if not. */
784 /* --------------------------------------------------------------------------------------------- */
786 get_fs_usage (char *path
, struct fs_usage
*fsp
)
788 #ifdef STAT_STATFS3_OSF1
791 if (statfs (path
, &fsd
, sizeof (struct statfs
)) != 0)
793 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_fsize, 512)
794 #endif /* STAT_STATFS3_OSF1 */
796 #ifdef STAT_STATFS2_FS_DATA /* Ultrix. */
799 if (statfs (path
, &fsd
) != 1)
801 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), 1024, 512)
802 fsp
->fsu_blocks
= CONVERT_BLOCKS (fsd
.fd_req
.btot
);
803 fsp
->fsu_bfree
= CONVERT_BLOCKS (fsd
.fd_req
.bfree
);
804 fsp
->fsu_bavail
= CONVERT_BLOCKS (fsd
.fd_req
.bfreen
);
805 fsp
->fsu_files
= fsd
.fd_req
.gtot
;
806 fsp
->fsu_ffree
= fsd
.fd_req
.gfree
;
809 #ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */
812 if (statfs (path
, &fsd
) < 0)
814 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512)
817 #ifdef STAT_STATFS2_FSIZE /* 4.4BSD. */
820 if (statfs (path
, &fsd
) < 0)
822 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_fsize, 512)
825 #ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX. */
828 if (statfs (path
, &fsd
, sizeof fsd
, 0) < 0)
830 /* Empirically, the block counts on most SVR3 and SVR3-derived
831 systems seem to always be in terms of 512-byte blocks,
832 no matter what value f_bsize has. */
834 #define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512)
836 #define CONVERT_BLOCKS(b) (b)
837 #ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */
838 #ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
839 #define f_bavail f_bfree
845 #ifdef STAT_STATVFS /* SVR4. */
848 if (statvfs (path
, &fsd
) < 0)
850 /* f_frsize isn't guaranteed to be supported. */
851 #define CONVERT_BLOCKS(b) \
852 fs_adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
855 #if defined(CONVERT_BLOCKS) && !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) /* !Ultrix && !SVR2. */
856 fsp
->fsu_blocks
= CONVERT_BLOCKS (fsd
.f_blocks
);
857 fsp
->fsu_bfree
= CONVERT_BLOCKS (fsd
.f_bfree
);
858 fsp
->fsu_bavail
= CONVERT_BLOCKS (fsd
.f_bavail
);
859 fsp
->fsu_files
= fsd
.f_files
;
860 fsp
->fsu_ffree
= fsd
.f_ffree
;
866 #endif /* HAVE_INFOMOUNT */
868 /* --------------------------------------------------------------------------------------------- */
869 /*** public functions ****************************************************************************/
870 /* --------------------------------------------------------------------------------------------- */
873 free_my_statfs (void)
875 #ifdef HAVE_INFOMOUNT_LIST
878 struct mount_entry
*next
= mount_list
->me_next
;
879 free_mount_entry (mount_list
);
883 #endif /* HAVE_INFOMOUNT_LIST */
886 /* --------------------------------------------------------------------------------------------- */
889 init_my_statfs (void)
891 #ifdef HAVE_INFOMOUNT_LIST
893 mount_list
= read_filesystem_list (1, 1);
894 #endif /* HAVE_INFOMOUNT_LIST */
897 /* --------------------------------------------------------------------------------------------- */
900 my_statfs (struct my_statfs
*myfs_stats
, const char *path
)
902 #ifdef HAVE_INFOMOUNT_LIST
904 struct mount_entry
*entry
= NULL
;
905 struct mount_entry
*temp
= mount_list
;
906 struct fs_usage fs_use
;
910 i
= strlen (temp
->me_mountdir
);
911 if (i
> len
&& (strncmp (path
, temp
->me_mountdir
, i
) == 0))
912 if (!entry
|| (path
[i
] == PATH_SEP
|| path
[i
] == '\0'))
917 temp
= temp
->me_next
;
922 memset (&fs_use
, 0, sizeof (struct fs_usage
));
923 get_fs_usage (entry
->me_mountdir
, &fs_use
);
925 myfs_stats
->type
= entry
->me_dev
;
926 myfs_stats
->typename
= entry
->me_type
;
927 myfs_stats
->mpoint
= entry
->me_mountdir
;
928 myfs_stats
->device
= entry
->me_devname
;
929 myfs_stats
->avail
= getuid ()? fs_use
.fsu_bavail
/ 2 : fs_use
.fsu_bfree
/ 2;
930 myfs_stats
->total
= fs_use
.fsu_blocks
/ 2;
931 myfs_stats
->nfree
= fs_use
.fsu_ffree
;
932 myfs_stats
->nodes
= fs_use
.fsu_files
;
935 #endif /* HAVE_INFOMOUNT_LIST */
937 #ifdef HAVE_INFOMOUNT_QNX
939 ** This is the "other side" of the hack to read_filesystem_list() in
941 ** It's not the most efficient approach, but consumes less memory. It
942 ** also accomodates QNX's ability to mount filesystems on the fly.
944 struct mount_entry
*entry
;
945 struct fs_usage fs_use
;
947 entry
= read_filesystem_list (0, 0);
950 get_fs_usage (entry
->me_mountdir
, &fs_use
);
952 myfs_stats
->type
= entry
->me_dev
;
953 myfs_stats
->typename
= entry
->me_type
;
954 myfs_stats
->mpoint
= entry
->me_mountdir
;
955 myfs_stats
->device
= entry
->me_devname
;
957 myfs_stats
->avail
= fs_use
.fsu_bfree
/ 2;
958 myfs_stats
->total
= fs_use
.fsu_blocks
/ 2;
959 myfs_stats
->nfree
= fs_use
.fsu_ffree
;
960 myfs_stats
->nodes
= fs_use
.fsu_files
;
963 #endif /* HAVE_INFOMOUNT_QNX */
965 myfs_stats
->type
= 0;
966 myfs_stats
->mpoint
= "unknown";
967 myfs_stats
->device
= "unknown";
968 myfs_stats
->avail
= 0;
969 myfs_stats
->total
= 0;
970 myfs_stats
->nfree
= 0;
971 myfs_stats
->nodes
= 0;
975 /* --------------------------------------------------------------------------------------------- */