Merge pull request #2543 from ermshiperete/Xamarin-31021
authorAlex Rønne Petersen <alex@alexrp.com>
Tue, 15 Mar 2016 11:41:02 +0000 (12:41 +0100)
committerAlex Rønne Petersen <alex@alexrp.com>
Tue, 15 Mar 2016 11:41:02 +0000 (12:41 +0100)
Don't ignore drives with type "aufs" or "overlay" (Xamarin-31021)

1  2 
mono/io-layer/io.c

diff --combined mono/io-layer/io.c
index bac7e8749989225afd4371dc853b4ee6a64d3303,75cdbfb7670bdeaeabf47c8d3cb6e45413218eba..b751134d7045aa6a2cae4e3fc3ba186fedbd66c1
@@@ -240,7 -240,7 +240,7 @@@ static void io_ops_init (void
   * This is is a best effort kind of thing. It assumes a reasonable sane set
   * of permissions by the underlying OS.
   *
 - * We assume that basic unix permission bits are authoritative. Which might not
 + * We generally assume that basic unix permission bits are authoritative. Which might not
   * be the case under systems with extended permissions systems (posix ACLs, SELinux, OSX/iOS sandboxing, etc)
   *
   * The choice of access as the fallback is due to the expected lower overhead compared to trying to open the file.
  static gboolean
  is_file_writable (struct stat *st, const char *path)
  {
 +#if __APPLE__
 +      // OS X Finder "locked" or `ls -lO` "uchg".
 +      // This only covers one of several cases where an OS X file could be unwritable through special flags.
 +      if (st->st_flags & (UF_IMMUTABLE|SF_IMMUTABLE))
 +              return 0;
 +#endif
 +
        /* Is it globally writable? */
        if (st->st_mode & S_IWOTH)
                return 1;
@@@ -1037,11 -1030,8 +1037,11 @@@ static void console_close (gpointer han
  
        g_free (console_handle->filename);
  
 -      if (fd > 2)
 +      if (fd > 2) {
 +              if (console_handle->share_info)
 +                      _wapi_handle_share_release (console_handle->share_info);
                close (fd);
 +      }
  }
  
  static WapiFileType console_getfiletype(void)
@@@ -1162,9 -1152,6 +1162,9 @@@ static void pipe_close (gpointer handle
  
        /* No filename with pipe handles */
  
 +      if (pipe_handle->share_info)
 +              _wapi_handle_share_release (pipe_handle->share_info);
 +
        close (fd);
  }
  
@@@ -1224,7 -1211,7 +1224,7 @@@ static gboolean pipe_read (gpointer han
                }
        }
        
 -      MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe", __func__, ret);
 +      MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe %p", __func__, ret, handle);
  
        if(bytesread!=NULL) {
                *bytesread=ret;
@@@ -1636,10 -1623,6 +1636,10 @@@ gpointer CreateFile(const gunichar2 *na
  #endif
        if (S_ISFIFO (statbuf.st_mode)) {
                handle_type = WAPI_HANDLE_PIPE;
 +              /* maintain invariant that pipes have no filename */
 +              file_handle.filename = NULL;
 +              g_free (filename);
 +              filename = NULL;
        } else if (S_ISCHR (statbuf.st_mode)) {
                handle_type = WAPI_HANDLE_CONSOLE;
        } else {
@@@ -3733,9 -3716,14 +3733,14 @@@ add_drive_string (guint32 len, gunichar
  
        if (state->fsname_index == 1 && state->fsname [0] == '/')
                ignore_entry = FALSE;
-       else if (state->fsname_index == 0 || memcmp ("none", state->fsname, state->fsname_index) == 0)
+       else if (memcmp ("overlay", state->fsname, state->fsname_index) == 0 ||
+               memcmp ("aufs", state->fstype, state->fstype_index) == 0) {
+               /* Don't ignore overlayfs and aufs - these might be used on Docker
+                * (https://bugzilla.xamarin.com/show_bug.cgi?id=31021) */
+               ignore_entry = FALSE;
+       } else if (state->fsname_index == 0 || memcmp ("none", state->fsname, state->fsname_index) == 0) {
                ignore_entry = TRUE;
-       else if (state->fstype_index >= 5 && memcmp ("fuse.", state->fstype, 5) == 0) {
+       else if (state->fstype_index >= 5 && memcmp ("fuse.", state->fstype, 5) == 0) {
                /* Ignore GNOME's gvfs */
                if (state->fstype_index == 21 && memcmp ("fuse.gvfs-fuse-daemon", state->fstype, state->fstype_index) == 0)
                        ignore_entry = TRUE;