From faff5709c69e1f02da5da33f516217e0120da29c Mon Sep 17 00:00:00 2001 From: Aleksey Cheusov Date: Sun, 21 Nov 2010 10:11:57 +0300 Subject: [PATCH] Ticket #2425: fixup read_filesystem_list() for NetBSD >=3. Signed-off-by: Andrew Borodin --- src/mountlist.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/mountlist.c b/src/mountlist.c index e1b8c323f..af4a6cd88 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -54,6 +54,7 @@ #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ #include +#define statfs statvfs #endif #ifdef MOUNTED_GETMNT /* Ultrix. */ @@ -371,7 +372,7 @@ read_filesystem_list (int need_fs_type, int all_fs) #endif /* MOUNTED */ #endif /* MOUNTED_GETMNTENT1 */ -#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ +#if defined(MOUNTED_GETMNTINFO) || defined(MOUNTED_GETMNTINFO2) /* 4.4BSD and NetBSD >= 3 */ { struct statfs *fsp; int entries; @@ -384,7 +385,7 @@ read_filesystem_list (int need_fs_type, int all_fs) me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); me->me_devname = strdup (fsp->f_mntfromname); me->me_mountdir = strdup (fsp->f_mntonname); -#ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME +#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(MOUNTED_GETMNTINFO2) me->me_type = strdup (fsp->f_fstypename); #else me->me_type = fstype_to_string (fsp->f_type); @@ -398,30 +399,7 @@ read_filesystem_list (int need_fs_type, int all_fs) fsp++; } } -#endif /* MOUNTED_GETMNTINFO */ - -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ - { - struct statvfs *fsp; - int entries; - - entries = getmntinfo (&fsp, MNT_NOWAIT); - if (entries < 0) - return NULL; - for (; entries-- > 0; fsp++) - { - me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); - me->me_devname = strdup (fsp->f_mntfromname); - me->me_mountdir = strdup (fsp->f_mntonname); - me->me_type = strdup (fsp->f_fstypename); - me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */ - - /* Add to the linked list. */ - mtail->me_next = me; - mtail = me; - } - } -#endif /* MOUNTED_GETMNTINFO2 */ +#endif /* MOUNTED_GETMNTINFO || MOUNTED_GETMNTINFO2 */ #ifdef MOUNTED_GETMNT /* Ultrix. */ {