diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index e7a494c22cc8c..bd636b92e284e 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -236,7 +236,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(HOST_WIN32 1) set(EXE_SUFFIX ".exe") set(DISABLE_CRASH_REPORTING 1) - set(DISABLE_PORTABILITY 1) set(HOST_NO_SYMLINKS 1) set(MONO_KEYWORD_THREAD "__declspec (thread)") set(MONO_ZERO_LEN_ARRAY 1) diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 8e0c462a53ef3..6e6fc568b8b3b 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -71,9 +71,6 @@ /* Define to the home page for this package. */ #cmakedefine PACKAGE_URL 1 -/* Disables the IO portability layer */ -#cmakedefine DISABLE_PORTABILITY 1 - /* This platform does not support symlinks */ #cmakedefine HOST_NO_SYMLINKS 1 diff --git a/src/mono/cmake/options.cmake b/src/mono/cmake/options.cmake index fa5a2fee8797f..7e90a628d8bbf 100644 --- a/src/mono/cmake/options.cmake +++ b/src/mono/cmake/options.cmake @@ -2,7 +2,6 @@ # Configure options # -option (DISABLE_PORTABILITY "Disables the IO portability layer") option (DISABLE_AOT "Disable AOT Compiler") option (DISABLE_PROFILER "Disable default profiler support") option (DISABLE_DECIMAL "Disable System.Decimal support") diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 0fd603fd47ac8..7ad49306d26d1 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -298,7 +298,7 @@ <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages - <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,portability,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,qcalls$(_MonoMinimal)"/> + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,qcalls$(_MonoMinimal)"/> <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> <_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/> @@ -351,7 +351,7 @@ - <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,portability,logging,shared_perfcounters" /> + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,logging,shared_perfcounters" /> <_MonoCMakeArgs Include="-DENABLE_VISIBILITY_HIDDEN=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> <_MonoCMakeArgs Include="-DENABLE_SIGALTSTACK=0"/> @@ -381,7 +381,7 @@ <_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="-DANDROID_ABI=armeabi-v7a" /> <_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DANDROID_ABI=x86" /> <_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DANDROID_ABI=x86_64" /> - <_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,portability,logging" /> + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,logging" /> <_MonoCMakeArgs Include="-DENABLE_SIGALTSTACK=1"/> <_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/> diff --git a/src/mono/mono/metadata/appdomain.c b/src/mono/mono/metadata/appdomain.c index 09d8c4527e3e1..0c8bd4bf68050 100644 --- a/src/mono/mono/metadata/appdomain.c +++ b/src/mono/mono/metadata/appdomain.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -250,8 +249,6 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT error_init (error); - mono_portability_helpers_init (); - mono_gc_base_init (); mono_monitor_init (); mono_marshal_init (); @@ -620,15 +617,7 @@ try_load_from (MonoAssembly **assembly, *assembly = NULL; fullpath = g_build_filename (path1, path2, path3, path4, (const char*)NULL); - if (IS_PORTABILITY_SET) { - gchar *new_fullpath = mono_portability_find_file (fullpath, TRUE); - if (new_fullpath) { - g_free (fullpath); - fullpath = new_fullpath; - found = TRUE; - } - } else - found = g_file_test (fullpath, G_FILE_TEST_IS_REGULAR); + found = g_file_test (fullpath, G_FILE_TEST_IS_REGULAR); if (found) { *assembly = mono_assembly_request_open (fullpath, req, NULL); diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 8a52e63bc856d..d30fc22d275e7 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mono/mono/metadata/file-mmap-posix.c b/src/mono/mono/metadata/file-mmap-posix.c index 02468483001fa..5d8c2b88ee101 100644 --- a/src/mono/mono/metadata/file-mmap-posix.c +++ b/src/mono/mono/metadata/file-mmap-posix.c @@ -278,7 +278,7 @@ open_file_map (const char *c_path, int input_fd, int mode, gint64 *capacity, int } MONO_ENTER_GC_SAFE; - if (c_path) //FIXME use io portability? + if (c_path) fd = open (c_path, file_mode_to_unix (mode) | access_mode_to_unix (access), DEFAULT_FILEMODE); else fd = dup (input_fd); diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index b4f4d07502be5..3156da7f2dd9f 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -91,7 +91,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mono/mono/metadata/image.c b/src/mono/mono/metadata/image.c index 3bd2a6306add3..6a5fd151dce69 100644 --- a/src/mono/mono/metadata/image.c +++ b/src/mono/mono/metadata/image.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -1374,18 +1373,8 @@ mono_image_storage_open (const char *fname) MonoFileMap *filed; if ((filed = mono_file_map_open (fname)) == NULL){ - if (IS_PORTABILITY_SET) { - gchar *ffname = mono_portability_find_file (fname, TRUE); - if (ffname) { - filed = mono_file_map_open (ffname); - g_free (ffname); - } - } - - if (filed == NULL) { - g_free (key); - return NULL; - } + g_free (key); + return NULL; } MonoImageStorage *storage = g_new0 (MonoImageStorage, 1); diff --git a/src/mono/mono/metadata/w32file-unix.c b/src/mono/mono/metadata/w32file-unix.c index f60af5e8c00c2..e11bfb335dac5 100644 --- a/src/mono/mono/metadata/w32file-unix.c +++ b/src/mono/mono/metadata/w32file-unix.c @@ -47,7 +47,6 @@ #include "w32error.h" #include "fdhandle.h" #include "utils/mono-error-internals.h" -#include "utils/mono-io-portability.h" #include "utils/mono-logger-internals.h" #include "utils/mono-os-mutex.h" #include "utils/mono-threads.h" @@ -235,39 +234,10 @@ static gint _wapi_open (const gchar *pathname, gint flags, mode_t mode) { gint fd; - gchar *located_filename; - - if (flags & O_CREAT) { - located_filename = mono_portability_find_file (pathname, FALSE); - if (located_filename == NULL) { - MONO_ENTER_GC_SAFE; - fd = open (pathname, flags, mode); - MONO_EXIT_GC_SAFE; - } else { - MONO_ENTER_GC_SAFE; - fd = open (located_filename, flags, mode); - MONO_EXIT_GC_SAFE; - g_free (located_filename); - } - } else { - MONO_ENTER_GC_SAFE; - fd = open (pathname, flags, mode); - MONO_EXIT_GC_SAFE; - if (fd == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) { - gint saved_errno = errno; - located_filename = mono_portability_find_file (pathname, TRUE); - - if (located_filename == NULL) { - mono_set_errno (saved_errno); - return -1; - } - - MONO_ENTER_GC_SAFE; - fd = open (located_filename, flags, mode); - MONO_EXIT_GC_SAFE; - g_free (located_filename); - } - } + + MONO_ENTER_GC_SAFE; + fd = open (pathname, flags, mode); + MONO_EXIT_GC_SAFE; return(fd); } @@ -280,20 +250,6 @@ _wapi_access (const gchar *pathname, gint mode) MONO_ENTER_GC_SAFE; ret = access (pathname, mode); MONO_EXIT_GC_SAFE; - if (ret == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) { - gint saved_errno = errno; - gchar *located_filename = mono_portability_find_file (pathname, TRUE); - - if (located_filename == NULL) { - mono_set_errno (saved_errno); - return -1; - } - - MONO_ENTER_GC_SAFE; - ret = access (located_filename, mode); - MONO_EXIT_GC_SAFE; - g_free (located_filename); - } return ret; } @@ -306,20 +262,6 @@ _wapi_unlink (const gchar *pathname) MONO_ENTER_GC_SAFE; ret = unlink (pathname); MONO_EXIT_GC_SAFE; - if (ret == -1 && (errno == ENOENT || errno == ENOTDIR || errno == EISDIR) && IS_PORTABILITY_SET) { - gint saved_errno = errno; - gchar *located_filename = mono_portability_find_file (pathname, TRUE); - - if (located_filename == NULL) { - mono_set_errno (saved_errno); - return -1; - } - - MONO_ENTER_GC_SAFE; - ret = unlink (located_filename); - MONO_EXIT_GC_SAFE; - g_free (located_filename); - } return ret; } @@ -329,16 +271,6 @@ _wapi_dirname (const gchar *filename) { gchar *new_filename = g_strdup (filename), *ret; - if (IS_PORTABILITY_SET) - g_strdelimit (new_filename, '\\', '/'); - - if (IS_PORTABILITY_DRIVE && g_ascii_isalpha (new_filename[0]) && (new_filename[1] == ':')) { - gint len = strlen (new_filename); - - g_memmove (new_filename, new_filename + 2, len - 2); - new_filename[len - 2] = '\0'; - } - ret = g_path_get_dirname (new_filename); g_free (new_filename); diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index dde7ba5781c45..f1fde63f9a5b7 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -54,8 +54,6 @@ set(utils_common_sources mono-state.c mono-internal-hash.c mono-internal-hash.h - mono-io-portability.c - mono-io-portability.h monobitset.c mono-filemap.c mono-math-c.c diff --git a/src/mono/mono/utils/mono-io-portability.c b/src/mono/mono/utils/mono-io-portability.c deleted file mode 100644 index 616c73b49a4f4..0000000000000 --- a/src/mono/mono/utils/mono-io-portability.c +++ /dev/null @@ -1,354 +0,0 @@ -/** - * \file - */ - -#include "config.h" - -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include -#include - -#ifndef DISABLE_PORTABILITY - -#include - -int mono_io_portability_helpers = PORTABILITY_UNKNOWN; - -static gchar *mono_portability_find_file_internal (const gchar *pathname, gboolean last_exists); - -void mono_portability_helpers_init (void) -{ - gchar *env; - - if (mono_io_portability_helpers != PORTABILITY_UNKNOWN) - return; - - mono_io_portability_helpers = PORTABILITY_NONE; - - env = g_getenv ("MONO_IOMAP"); - if (env != NULL) { - /* parse the environment setting and set up some vars - * here - */ - gchar **options = g_strsplit (env, ":", 0); - int i; - - if (options == NULL) { - /* This shouldn't happen */ - return; - } - - for (i = 0; options[i] != NULL; i++) { -#ifdef DEBUG - g_message ("%s: Setting option [%s]", __func__, - options[i]); -#endif - if (!strncasecmp (options[i], "drive", 5)) { - mono_io_portability_helpers |= PORTABILITY_DRIVE; - } else if (!strncasecmp (options[i], "case", 4)) { - mono_io_portability_helpers |= PORTABILITY_CASE; - } else if (!strncasecmp (options[i], "all", 3)) { - mono_io_portability_helpers |= (PORTABILITY_DRIVE | PORTABILITY_CASE); - } - } - g_free (env); - } -} - -/* Returns newly allocated string, or NULL on failure */ -static gchar *find_in_dir (DIR *current, const gchar *name) -{ - struct dirent *entry; - -#ifdef DEBUG - g_message ("%s: looking for [%s]\n", __func__, name); -#endif - - while((entry = readdir (current)) != NULL) { -#ifdef DEBUGX - g_message ("%s: found [%s]\n", __func__, entry->d_name); -#endif - - if (!g_ascii_strcasecmp (name, entry->d_name)) { - char *ret; - -#ifdef DEBUG - g_message ("%s: matched [%s] to [%s]\n", __func__, - entry->d_name, name); -#endif - - ret = g_strdup (entry->d_name); - closedir (current); - return ret; - } - } - -#ifdef DEBUG - g_message ("%s: returning NULL\n", __func__); -#endif - - closedir (current); - - return(NULL); -} - -gchar *mono_portability_find_file (const gchar *pathname, gboolean last_exists) -{ - gchar *ret; - - if (!pathname || !pathname [0]) - return NULL; - ret = mono_portability_find_file_internal (pathname, last_exists); - - return ret; -} - -/* Returns newly-allocated string or NULL on failure */ -static gchar *mono_portability_find_file_internal (const gchar *pathname, gboolean last_exists) -{ - gchar *new_pathname, **components, **new_components; - int num_components = 0, component = 0; - DIR *scanning = NULL; - size_t len; - - if (IS_PORTABILITY_NONE) { - return(NULL); - } - - new_pathname = g_strdup (pathname); - -#ifdef DEBUG - g_message ("%s: Finding [%s] last_exists: %s\n", __func__, pathname, - last_exists?"TRUE":"FALSE"); -#endif - - if (last_exists && - access (new_pathname, F_OK) == 0) { -#ifdef DEBUG - g_message ("%s: Found it without doing anything\n", __func__); -#endif - return(new_pathname); - } - - /* First turn '\' into '/' and strip any drive letters */ - g_strdelimit (new_pathname, '\\', '/'); - -#ifdef DEBUG - g_message ("%s: Fixed slashes, now have [%s]\n", __func__, - new_pathname); -#endif - - if (IS_PORTABILITY_DRIVE && - g_ascii_isalpha (new_pathname[0]) && - (new_pathname[1] == ':')) { - int len = strlen (new_pathname); - - g_memmove (new_pathname, new_pathname+2, len - 2); - new_pathname[len - 2] = '\0'; -#ifdef DEBUG - g_message ("%s: Stripped drive letter, now looking for [%s]\n", - __func__, new_pathname); -#endif - } - - len = strlen (new_pathname); - if (len > 1 && new_pathname [len - 1] == '/') { - new_pathname [len - 1] = 0; -#ifdef DEBUG - g_message ("%s: requested name had a trailing /, rewritten to '%s'\n", - __func__, new_pathname); -#endif - } - - if (last_exists && - access (new_pathname, F_OK) == 0) { -#ifdef DEBUG - g_message ("%s: Found it\n", __func__); -#endif - - return(new_pathname); - } - - /* OK, have to work harder. Take each path component in turn - * and do a case-insensitive directory scan for it - */ - - if (!(IS_PORTABILITY_CASE)) { - g_free (new_pathname); - return(NULL); - } - - components = g_strsplit (new_pathname, "/", 0); - if (components == NULL) { - /* This shouldn't happen */ - g_free (new_pathname); - return(NULL); - } - - while(components[num_components] != NULL) { - num_components++; - } - g_free (new_pathname); - - if (num_components == 0){ - return NULL; - } - - - new_components = (gchar **)g_new0 (gchar **, num_components + 1); - - if (num_components > 1) { - if (strcmp (components[0], "") == 0) { - /* first component blank, so start at / */ - scanning = opendir ("/"); - if (scanning == NULL) { -#ifdef DEBUG - g_message ("%s: opendir 1 error: %s", __func__, - g_strerror (errno)); -#endif - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - new_components[component++] = g_strdup (""); - } else { - DIR *current; - gchar *entry; - - current = opendir ("."); - if (current == NULL) { -#ifdef DEBUG - g_message ("%s: opendir 2 error: %s", __func__, - g_strerror (errno)); -#endif - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - entry = find_in_dir (current, components[0]); - if (entry == NULL) { - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - scanning = opendir (entry); - if (scanning == NULL) { -#ifdef DEBUG - g_message ("%s: opendir 3 error: %s", __func__, - g_strerror (errno)); -#endif - g_free (entry); - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - new_components[component++] = entry; - } - } else { - if (last_exists) { - if (strcmp (components[0], "") == 0) { - /* First and only component blank */ - new_components[component++] = g_strdup (""); - } else { - DIR *current; - gchar *entry; - - current = opendir ("."); - if (current == NULL) { -#ifdef DEBUG - g_message ("%s: opendir 4 error: %s", - __func__, - g_strerror (errno)); -#endif - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - entry = find_in_dir (current, components[0]); - if (entry == NULL) { - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - - new_components[component++] = entry; - } - } else { - new_components[component++] = g_strdup (components[0]); - } - } - -#ifdef DEBUG - g_message ("%s: Got first entry: [%s]\n", __func__, new_components[0]); -#endif - - g_assert (component == 1); - - for(; component < num_components; component++) { - gchar *entry; - gchar *path_so_far; - - if (!last_exists && - component == num_components -1) { - entry = g_strdup (components[component]); - closedir (scanning); - } else { - entry = find_in_dir (scanning, components[component]); - if (entry == NULL) { - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - } - - new_components[component] = entry; - - if (component < num_components -1) { - path_so_far = g_strjoinv ("/", new_components); - - scanning = opendir (path_so_far); - g_free (path_so_far); - if (scanning == NULL) { - g_strfreev (new_components); - g_strfreev (components); - return(NULL); - } - } - } - - g_strfreev (components); - - new_pathname = g_strjoinv ("/", new_components); - -#ifdef DEBUG - g_message ("%s: pathname [%s] became [%s]\n", __func__, pathname, - new_pathname); -#endif - - g_strfreev (new_components); - - if ((last_exists && - access (new_pathname, F_OK) == 0) || - (!last_exists)) { - return(new_pathname); - } - - g_free (new_pathname); - return(NULL); -} - -#else /* DISABLE_PORTABILITY */ - -MONO_EMPTY_SOURCE_FILE (mono_io_portability); - -#endif /* DISABLE_PORTABILITY */ diff --git a/src/mono/mono/utils/mono-io-portability.h b/src/mono/mono/utils/mono-io-portability.h deleted file mode 100644 index 220b4fa69b127..0000000000000 --- a/src/mono/mono/utils/mono-io-portability.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_IO_PORTABILITY_H -#define __MONO_IO_PORTABILITY_H - -#include -#include -#include "config.h" - -enum { - PORTABILITY_NONE = 0x00, - PORTABILITY_UNKNOWN = 0x01, - PORTABILITY_DRIVE = 0x02, - PORTABILITY_CASE = 0x04 -}; - -#ifdef DISABLE_PORTABILITY - -#define mono_portability_helpers_init() -#define mono_portability_find_file(pathname,last_exists) NULL - -#define IS_PORTABILITY_NONE FALSE -#define IS_PORTABILITY_UNKNOWN FALSE -#define IS_PORTABILITY_DRIVE FALSE -#define IS_PORTABILITY_CASE FALSE -#define IS_PORTABILITY_SET FALSE - -#else - -void mono_portability_helpers_init (void); -gchar *mono_portability_find_file (const gchar *pathname, gboolean last_exists); - -extern int mono_io_portability_helpers; - -#define IS_PORTABILITY_NONE (mono_io_portability_helpers & PORTABILITY_NONE) -#define IS_PORTABILITY_UNKNOWN (mono_io_portability_helpers & PORTABILITY_UNKNOWN) -#define IS_PORTABILITY_DRIVE (mono_io_portability_helpers & PORTABILITY_DRIVE) -#define IS_PORTABILITY_CASE (mono_io_portability_helpers & PORTABILITY_CASE) -#define IS_PORTABILITY_SET (mono_io_portability_helpers > 0) - -#endif - -#endif diff --git a/src/mono/mono/utils/mono-proclib.c b/src/mono/mono/utils/mono-proclib.c index 64c583da9ee71..1b19cdec49fb5 100644 --- a/src/mono/mono/utils/mono-proclib.c +++ b/src/mono/mono/utils/mono-proclib.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #if defined(_POSIX_VERSION) @@ -1041,23 +1040,7 @@ mono_pe_file_map (const gunichar2 *filename, guint32 *map_size, void **handle) goto exit; } - if ((filed = mono_file_map_open (filename_ext)) == NULL && IS_PORTABILITY_SET) { - gint saved_errno = errno; - - located_filename = mono_portability_find_file (filename_ext, TRUE); - if (!located_filename) { - mono_set_errno (saved_errno); - - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER_PROCESS, "%s: Error opening file %s (3): %s", __func__, filename_ext, strerror (errno)); - goto exit; - } - - if ((filed = mono_file_map_open (located_filename)) == NULL) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER_PROCESS, "%s: Error opening file %s (3): %s", __func__, located_filename, strerror (errno)); - goto exit; - } - } - else if (filed == NULL) { + if ((filed = mono_file_map_open (filename_ext)) == NULL) { mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER_PROCESS, "%s: Error opening file %s (3): %s", __func__, filename_ext, strerror (errno)); goto exit; }