[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interix list of mounted file systems.
From: |
Markus Duft |
Subject: |
Re: Interix list of mounted file systems. |
Date: |
Thu, 20 Jan 2011 15:43:07 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101216 Lightning/1.0b3pre Thunderbird/3.1.7 |
On 01/20/2011 09:53 AM, Jim Meyering wrote:
[snip]
>
> There was no need to rebase.
> However, there was no ChangeLog entry, and the style of your added
> function did not match the existing code (we require a space before
> most open parentheses, and declare pointers like char *p, not "char* p"),
> so my pre-apply clean-up and review took more time than usual.
>
> I wrote the ChangeLog entry and fixed the code formatting.
> Oh, your patch added trailing blanks, too. Removed.
uh - thanks for the formatting, and sorry for the mis-formatted code.
>
> On the semantics of the patch, I don't like using NAME_MAX,
> char node[9 + NAME_MAX];
> (some systems don't define it at all)
> but since this code is compiled only on Interix, I didn't bother
> to change it.
>
> This commit has your name of course, but I've changed enough
> that I'll wait for an ACK before pushing.
> Below I've included one more patch to clean up some more
> code formatting nits in that same file.
thanks a lot :)
markus
>
> From a481c562988f66f1614206c2f82779aa7835afb8 Mon Sep 17 00:00:00 2001
> From: Markus Duft <address@hidden>
> Date: Thu, 20 Jan 2011 09:19:24 +0100
> Subject: [PATCH 1/2] 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(+), 0 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 85e510e..22c944b 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,11 @@
> +2011-01-14 Markus Duft <address@hidden>
> +
> + 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-14 Jim Meyering <address@hidden>
>
> bootstrap: avoid failure when there is no .gitmodules file
> diff --git a/lib/mountlist.c b/lib/mountlist.c
> index afe813c..397de57 100644
> --- a/lib/mountlist.c
> +++ b/lib/mountlist.c
> @@ -112,6 +112,11 @@
> # include <sys/vfs.h>
> #endif
>
> +#ifdef MOUNTED_INTERIX_STATVFS /* Interix. */
> +# include <sys/statvfs.h>
> +# include <dirent.h>
> +#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 0500699..72beaed 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
> --
> 1.7.3.5
>
>
> From 984767e93b5de369d53d6ba55bab2794727a2bab Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Thu, 20 Jan 2011 09:35:37 +0100
> Subject: [PATCH 2/2] mountlist: clean up code formatting
>
> * lib/mountlist.c (read_file_system_list): Split a long line,
> correct bracing style, use NULL in place of "(struct statfs *)0",
> don't parenthesize return value, add spaces around "=" and after
> ";-in-for-stmt".
> ---
> ChangeLog | 8 ++++++++
> lib/mountlist.c | 42 ++++++++++++++++++++++--------------------
> 2 files changed, 30 insertions(+), 20 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 22c944b..6c0f4b2 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,11 @@
> +2011-01-20 Jim Meyering <address@hidden>
> +
> + mountlist: clean up code formatting
> + * lib/mountlist.c (read_file_system_list): Split a long line,
> + correct bracing style, use NULL in place of "(struct statfs *)0",
> + don't parenthesize return value, add spaces around "=" and after
> + ";-in-for-stmt".
> +
> 2011-01-14 Markus Duft <address@hidden>
>
> mountlist: add support for Interix
> diff --git a/lib/mountlist.c b/lib/mountlist.c
> index 397de57..23437bc 100644
> --- a/lib/mountlist.c
> +++ b/lib/mountlist.c
> @@ -384,19 +384,20 @@ read_file_system_list (bool need_fs_type)
>
> if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
> return NULL;
> - for (p = mntlist; p; p = p->next) {
> - mnt = p->ment;
> - me = xmalloc (sizeof *me);
> - me->me_devname = xstrdup (mnt->mnt_fsname);
> - me->me_mountdir = xstrdup (mnt->mnt_dir);
> - me->me_type = xstrdup (mnt->mnt_type);
> - 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 = -1;
> - *mtail = me;
> - mtail = &me->me_next;
> - }
> + for (p = mntlist; p; p = p->next)
> + {
> + mnt = p->ment;
> + me = xmalloc (sizeof *me);
> + me->me_devname = xstrdup (mnt->mnt_fsname);
> + me->me_mountdir = xstrdup (mnt->mnt_dir);
> + me->me_type = xstrdup (mnt->mnt_type);
> + 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 = -1;
> + *mtail = me;
> + mtail = &me->me_next;
> + }
> freemntlist (mntlist);
> }
> #endif
> @@ -594,7 +595,8 @@ read_file_system_list (bool need_fs_type)
> break;
>
> me = xmalloc (sizeof *me);
> - me->me_devname = xstrdup (fi.device_name[0] != '\0' ?
> fi.device_name : fi.fsh_name);
> + me->me_devname = xstrdup (fi.device_name[0] != '\0'
> + ? fi.device_name : fi.fsh_name);
> me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
> me->me_type = xstrdup (fi.fsh_name);
> me->me_type_malloced = 1;
> @@ -624,9 +626,9 @@ read_file_system_list (bool need_fs_type)
> size_t bufsize;
> struct statfs *stats;
>
> - numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT);
> + numsys = getfsstat (NULL, 0L, MNT_NOWAIT);
> if (numsys < 0)
> - return (NULL);
> + return NULL;
> if (SIZE_MAX / sizeof *stats <= numsys)
> xalloc_die ();
>
> @@ -637,7 +639,7 @@ read_file_system_list (bool need_fs_type)
> if (numsys < 0)
> {
> free (stats);
> - return (NULL);
> + return NULL;
> }
>
> for (counter = 0; counter < numsys; counter++)
> @@ -723,11 +725,11 @@ read_file_system_list (bool need_fs_type)
> #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */
> {
> struct mntent **mnttbl = getmnttbl (), **ent;
> - for (ent=mnttbl;*ent;ent++)
> + for (ent = mnttbl; *ent; ent++)
> {
> me = xmalloc (sizeof *me);
> - me->me_devname = xstrdup ( (*ent)->mt_resource);
> - me->me_mountdir = xstrdup ( (*ent)->mt_directory);
> + me->me_devname = xstrdup ((*ent)->mt_resource);
> + me->me_mountdir = xstrdup ((*ent)->mt_directory);
> me->me_type = xstrdup ((*ent)->mt_fstype);
> me->me_type_malloced = 1;
> me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
> --
> 1.7.3.5