[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: |
Tue, 08 Nov 2005 15:32:10 +0100 |
Sam Johnston <address@hidden> wrote:
> Evening all,
>
> I'm having some trouble getting coreutils running under Interix
> (Microsoft's POSIX subsystem aka Services for Unix which is to be
> included in Windows 2003 Server R2, Vista, etc.). First I tell it
> about the new release (5.2 instead of 3.x or 4.x):
...
> Then I tell it to continue even if it can't work out what file systems
> are mounted:
>
> coreutils-5.93$ diff configure.orig configure
> 31364c31364,31365
> < { (exit 1); exit 1; }; }
> ---
>> # { (exit 1); exit 1; }; }
>> }
You might have better luck with the following patch.
It's based on work that is awaiting copyright assignment.
Since there is currently no code to define MOUNTED_INTERIX,
you can just add
#define MOUNTED_INTERIX 1
somewhere near the top of that file. or compile mountlist.o
with AM_CFLAGS=-DMOUNTED_INTERIX.
Index: mountlist.c
===================================================================
RCS file: /fetish/cu/lib/mountlist.c,v
retrieving revision 1.55
diff -u -p -r1.55 mountlist.c
--- mountlist.c 22 Sep 2005 06:05:39 -0000 1.55
+++ mountlist.c 8 Nov 2005 14:24:28 -0000
@@ -35,7 +35,9 @@ char *strstr ();
#include <errno.h>
-#include <fcntl.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
#include <unistd.h>
@@ -91,6 +93,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
@@ -417,6 +424,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