[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: configure breakage under Interix
From: |
Jim Meyering |
Subject: |
Re: configure breakage under Interix |
Date: |
Wed, 08 Feb 2006 11:10:46 +0100 |
Paul Eggert <address@hidden> wrote:
> Jerker Bäck <address@hidden> writes:
>
>> <http://lists.gnu.org/archive/html/bug-coreutils/2004-03/msg00097.html>
>> <http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00077.html>
>>
>> Is there a solution for this yet?
>
> Some of the problems described in those links have been fixed, in
> coreutils CVS. However, as far as I know we haven't gotten copyright
> assignment for the remaining fixes so we can't incorporate them.
> Also, as far as I know none of the coreutils developers has access to
> Interix, so you can't expect progress from our end.
Last I heard, the following patch, mostly from Darren Starr, does the
job as long as you manually define MOUNTED_INTERIX (eventually, it'll
be defined via m4/ls-mntd-fs.m4). The change is checked in to cvs on
the single-file interix-mountlist branch, so you can reproduce it with
this command:
cvs diff -rHEAD -rinterix-mountlist lib/mountlist.
As for the required copyright assignment, let's ask Darren, Cc'd.
I sent him the assignment form a couple of months ago, but paperwork
exchanges can take a long time.
Index: lib/mountlist.c
===================================================================
RCS file: /fetish/cu/lib/mountlist.c,v
retrieving revision 1.57
retrieving revision 1.52.2.2
diff -u -p -r1.57 -r1.52.2.2
--- lib/mountlist.c 26 Nov 2005 07:52:11 -0000 1.57
+++ lib/mountlist.c 17 Jan 2006 18:49:09 -0000 1.52.2.2
@@ -92,6 +92,11 @@ char *strstr ();
# include <dirent.h>
#endif
+#ifdef MOUNTED_INTERIX /* Windows with Interix / Microsoft Services
For UNIX */
+# include <dirent.h>
+# include <sys/statvfs.h>
+#endif
+
#ifdef MOUNTED_FREAD /* SVR2. */
# include <mnttab.h>
#endif
@@ -369,7 +374,7 @@ read_file_system_list (bool need_fs_type
#ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
{
struct mntent *mnt;
- char *table = MOUNTED;
+ char const *table = MOUNTED;
FILE *fp;
fp = setmntent (table, "r");
@@ -453,6 +458,95 @@ read_file_system_list (bool need_fs_type
}
#endif /* MOUNTED_GETMNT. */
+#if defined MOUNTED_INTERIX
+ /* Windows with Interix / Microsoft Services For UNIX */
+ {
+ /* Unlike Cygwin which attempts to implement as many of the UNIX
+ API's as possible Interix implements a great deal and then depends
+ on developers to port the rest. On Interix, the POSIX implementation
+ prefers to deny that UNIX style file systems exist and therefore
+ does not implement the mount tables for the system.
+
+ This implementation simply scans the mounted file system directory
+ and then reads the statvfs data for each entry to construct the
+ mount list.
+
+ The implementation also chooses to use the reentrant implementation
+ of readdir_r in order to favor a threading friendly system. */
+
+ int statvfs_errno = 0;
+ int fail;
+
+ DIR *dirp = opendir ("/dev/fs");
+ if (dirp == NULL)
+ {
+ fail = 1;
+ }
+ else
+ {
+ char file_name[9 + NAME_MAX]; /* 8 for /dev/fs/ + 1 for NUL */
+ int saved_errno;
+
+ while (1)
+ {
+ struct statvfs stat_buf;
+ struct dirent entry;
+ struct dirent *result;
+
+ fail = readdir_r (dirp, &entry, &result);
+
+ if (fail || result == NULL)
+ break;
+
+ strcpy (file_name, "/dev/fs/");
+ strcat (file_name, entry.d_name);
+
+ fail = statvfs (file_name, &stat_buf);
+ if (fail == 0)
+ {
+ char const *Magic_mount_from_name
+ = "/Device/LanmanRedirector/;",
+ me = xmalloc (sizeof *me);
+ me->me_devname = xstrdup (stat_buf.f_mntfromname);
+ me->me_mountdir = xstrdup (stat_buf.f_mntonname);
+ me->me_type = xstrdup (stat_buf.f_fstypename);
+ me->me_type_malloced = 1;
+ me->me_dummy = 0;
+ me->me_dev = stat_buf.f_fsid;
+ me->me_remote
+ = strncmp (stat_buf.f_mntfromname, Magic_mount_from_name,
+ strlen (Magic_mount_from_name)) == 0;
+
+ /* Add to the linked list. */
+ *mtail = me;
+ mtail = &me->me_next;
+ }
+ else
+ {
+ statvfs_errno = errno;
+ }
+ }
+
+ saved_errno = errno;
+ closedir (dirp);
+ errno = saved_errno;
+ }
+
+ if (!fail && statvfs_errno)
+ {
+ /* In the unlikely event that opendir and each readdir
+ succeed, but all statvfs calls fail, ensure that we
+ fail with a valid errno value. */
+ fail = 1;
+ errno = statvfs_errno;
+ }
+
+ if (fail)
+ goto free_then_fail;
+
+ }
+#endif
+
#if defined MOUNTED_FS_STAT_DEV /* BeOS */
{
/* The next_dev() and fs_stat_dev() system calls give the list of