From 341d4ca5473e77c703c16eb7f7c7a15f5c416ed5 Mon Sep 17 00:00:00 2001 From: Markus Duft Date: Thu, 20 Jan 2011 09:19:24 +0100 Subject: [PATCH] mountlist: add support for Interix * lib/mountlist.c (read_file_system_list) [MOUNTED_INTERIX_STATVFS]: Apply statvfs to all entries of /dev/fs. * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Check for statvfs, and if found, AC_DEFINE MOUNTED_INTERIX_STATVFS. --- ChangeLog | 8 ++++++++ lib/mountlist.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ m4/ls-mntd-fs.m4 | 17 +++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9c125c9eb..b12269661 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-14 Markus Duft + + mountlist: add support for Interix + * lib/mountlist.c (read_file_system_list) [MOUNTED_INTERIX_STATVFS]: + Apply statvfs to all entries of /dev/fs. + * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Check for statvfs, + and if found, AC_DEFINE MOUNTED_INTERIX_STATVFS. + 2011-01-20 Jim Meyering maint.mk: improve the public-submodule-commit rule diff --git a/lib/mountlist.c b/lib/mountlist.c index afe813c19..397de5770 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -112,6 +112,11 @@ # include #endif +#ifdef MOUNTED_INTERIX_STATVFS /* Interix. */ +# include +# include +#endif + #ifdef DOLPHIN /* So special that it's not worth putting this in autoconf. */ # undef MOUNTED_FREAD_FSTYP @@ -879,6 +884,45 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_VMOUNT. */ +#ifdef MOUNTED_INTERIX_STATVFS + { + DIR *dirp = opendir ("/dev/fs"); + char node[9 + NAME_MAX]; + + if (!dirp) + goto free_then_fail; + + while (1) + { + struct statvfs dev; + struct dirent entry; + struct dirent *result; + + if (readdir_r (dirp, &entry, &result) || result == NULL) + break; + + strcpy (node, "/dev/fs/"); + strcat (node, entry.d_name); + + if (statvfs (node, &dev) == 0) + { + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (dev.f_mntfromname); + me->me_mountdir = xstrdup (dev.f_mntonname); + me->me_type = xstrdup (dev.f_fstypename); + me->me_type_malloced = 1; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; + } + } + } +#endif /* MOUNTED_INTERIX_STATVFS */ + *mtail = NULL; return mount_list; diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4 index 050069998..72beaed9a 100644 --- a/m4/ls-mntd-fs.m4 +++ b/m4/ls-mntd-fs.m4 @@ -326,6 +326,23 @@ if test -z "$ac_list_mounted_fs"; then fi if test -z "$ac_list_mounted_fs"; then + # Interix / BSD alike statvfs + # the code is really interix specific, so make sure, we're on it. + case "$host" in + *-interix*) + AC_CHECK_FUNCS([statvfs]) + if test $ac_cv_func_statvfs = yes; then + ac_list_mounted_fs=found + AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1], + [Define if we are on interix, and ought to use statvfs plus + some special knowledge on where mounted filesystems can be + found. (Interix)]) + fi + ;; + esac +fi + +if test -z "$ac_list_mounted_fs"; then AC_MSG_ERROR([could not determine how to read list of mounted file systems]) # FIXME -- no need to abort building the whole package # Can't build mountlist.c or anything that needs its functions -- 2.11.0