From 8c6e7c103fc2ec1c80149b0d391b7c89e13d11cf Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 25 Feb 2009 16:37:35 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20570073=20=E2=80=93=20Add=20support=20for?= =?UTF-8?q?=20reading=20filesystems=20on=20Interix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2009-02-25 Alexander Larsson Bug 570073 – Add support for reading filesystems on Interix * gunixmounts.c (_g_get_unix_mounts): Support Interix. Patch from Fabian Groffen svn path=/trunk/; revision=7911 --- gio/ChangeLog | 7 +++++ gio/gunixmounts.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/gio/ChangeLog b/gio/ChangeLog index f15099e76..3e78d0112 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,10 @@ +2009-02-25 Alexander Larsson + + Bug 570073 – Add support for reading filesystems on Interix + + * gunixmounts.c (_g_get_unix_mounts): + Support Interix. Patch from Fabian Groffen + 2009-02-25 Paolo Borelli Bug 570069 – wrong preprocessor directive in gio/glocalfileinfo.c diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index f5e33d9cf..48dc7c570 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -38,6 +38,9 @@ #ifdef HAVE_POLL_H #include #endif +#if HAVE_SYS_STATVFS_H +#include +#endif #include #include #include @@ -45,6 +48,7 @@ #include #include #include +#include #include "gunixmounts.h" #include "gfile.h" @@ -597,6 +601,61 @@ _g_get_unix_mounts (void) return g_list_reverse (return_list); } +#elif defined(__INTERIX) + +static char * +get_mtab_monitor_file (void) +{ + return NULL; +} + +static GList * +_g_get_unix_mounts (void) +{ + DIR *dirp; + GList* return_list = NULL; + char filename[9 + NAME_MAX]; + + dirp = opendir ("/dev/fs"); + if (!dirp) + { + g_warning ("unable to read /dev/fs!"); + return NULL; + } + + while (1) + { + struct statvfs statbuf; + struct dirent entry; + struct dirent* result; + + if (readdir_r (dirp, &entry, &result) || result == NULL) + break; + + strcpy (filename, "/dev/fs/"); + strcat (filename, entry.d_name); + + if (statvfs (filename, &statbuf) == 0) + { + GUnixMountEntry* mount_entry = g_new0(GUnixMountEntry, 1); + + mount_entry->mount_path = g_strdup (statbuf.f_mntonname); + mount_entry->device_path = g_strdup (statbuf.f_mntfromname); + mount_entry->filesystem_type = g_strdup (statbuf.f_fstypename); + + if (statbuf.f_flag & ST_RDONLY) + mount_entry->is_read_only = TRUE; + + return_list = g_list_prepend(return_list, mount_entry); + } + } + + return_list = g_list_reverse (return_list); + + closedir (dirp); + + return return_list; +} #else #error No _g_get_unix_mounts() implementation for system #endif @@ -975,6 +1034,12 @@ _g_get_unix_mount_points (void) return g_list_reverse (return_list); } +#elif defined(__INTERIX) +static GList * +_g_get_unix_mount_points (void) +{ + return _g_get_unix_mounts (); +} #else #error No g_get_mount_table() implementation for system #endif