From patchwork Mon Jul 30 19:45:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 28689 Received: (qmail 99348 invoked by alias); 30 Jul 2018 19:46:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 99221 invoked by uid 89); 30 Jul 2018 19:45:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LINEPADDING, KAM_SHORT autolearn=ham version=3.3.2 spammy=distribute, unlimited, H*RU:Unknown_Domain, Hx-spam-relays-external:Unknown_Domain X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Jul 2018 19:45:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1532979953; h=From:Sender:Reply-To:Subject:Date:Message-Id:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=H3qb4AanRtheyIJ+Cl+XPmNltQ6XLb68GFk81k7ZUbY=; b=gI4Awq0K1zwNv38nsXv+Pq6DVOjUdBzJXb4i8olxjkqsSEvp2NLhG9xLxo199pJw Qxx612qUI+ERo4gISZOlJsu59tU+IVRoBpkfgOmNw7VrYLC6sZ8klJ3xPNSdZseQ rTNG2UqOC2poUILCkfes2KWb9aZbevmGC6vGn7dATEE=; Received: from ESESBMB501.ericsson.se (Unknown_Domain [153.88.183.114]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 04.1D.27833.1FA6F5B5; Mon, 30 Jul 2018 21:45:53 +0200 (CEST) Received: from ESESBMR505.ericsson.se (153.88.183.201) by ESESBMB501.ericsson.se (153.88.183.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 30 Jul 2018 21:45:52 +0200 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESBMR505.ericsson.se (153.88.183.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 30 Jul 2018 21:45:52 +0200 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Mon, 30 Jul 2018 21:45:52 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gRS+2LirO5ElwlkSb30wrSCib6hpUv0c1cRvLaHH6bM=; b=TiD5Oxtbg/Y+hiTRF40xgE6XiIS+CO/cRU2pBnKH90+8hRuTIhjxbVjQolFBDOmrscwHD576D9hXl4hIUs5VK/8g+nTU52XBYWLAoh91ihM6eILNwSztOuXxG71H2k+1Mau9+rLKgSL4s9XF5B10NqmX/Ru1cy68EDNR7A0s3CE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ca.am.ericsson.se (192.75.88.130) by BN7PR15MB2385.namprd15.prod.outlook.com (2603:10b6:406:8c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Mon, 30 Jul 2018 19:45:49 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH v3 3/5] Import gnulib's mkdir module Date: Mon, 30 Jul 2018 15:45:32 -0400 Message-Id: <1532979934-25275-4-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1532979934-25275-1-git-send-email-simon.marchi@ericsson.com> References: <1532979934-25275-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes The following patch makes use of the mkdir function. Import the mkdir gnulib module to ensure proper operation on all platforms. gdb/ChangeLog: * gnulib/aclocal.m4: Re-generate. * gnulib/config.in: Re-generate. * gnulib/configure: Re-generate. * gnulib/import/Makefile.am: Re-generate. * gnulib/import/Makefile.in: Re-generate. * gnulib/import/m4/gnulib-cache.m4: Re-generate. * gnulib/import/m4/gnulib-comp.m4: Re-generate. * gnulib/import/m4/mkdir.m4: New file. * gnulib/import/mkdir.c: New file. * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkdir module. --- gdb/gnulib/aclocal.m4 | 1 + gdb/gnulib/config.in | 4 ++ gdb/gnulib/configure | 126 +++++++++++++++++++++++++++++++++++ gdb/gnulib/import/Makefile.am | 11 ++- gdb/gnulib/import/Makefile.in | 16 +++-- gdb/gnulib/import/m4/gnulib-cache.m4 | 3 +- gdb/gnulib/import/m4/gnulib-comp.m4 | 7 ++ gdb/gnulib/import/m4/mkdir.m4 | 69 +++++++++++++++++++ gdb/gnulib/import/mkdir.c | 93 ++++++++++++++++++++++++++ gdb/gnulib/update-gnulib.sh | 1 + 10 files changed, 322 insertions(+), 9 deletions(-) create mode 100644 gdb/gnulib/import/m4/mkdir.m4 create mode 100644 gdb/gnulib/import/mkdir.c diff --git a/gdb/gnulib/aclocal.m4 b/gdb/gnulib/aclocal.m4 index 276b9bb..b897337 100644 --- a/gdb/gnulib/aclocal.m4 +++ b/gdb/gnulib/aclocal.m4 @@ -1350,6 +1350,7 @@ m4_include([import/m4/memchr.m4]) m4_include([import/m4/memmem.m4]) m4_include([import/m4/mempcpy.m4]) m4_include([import/m4/memrchr.m4]) +m4_include([import/m4/mkdir.m4]) m4_include([import/m4/mkstemp.m4]) m4_include([import/m4/mmap-anon.m4]) m4_include([import/m4/mode_t.m4]) diff --git a/gdb/gnulib/config.in b/gdb/gnulib/config.in index 543eb8b..41351ea 100644 --- a/gdb/gnulib/config.in +++ b/gdb/gnulib/config.in @@ -64,6 +64,10 @@ MSVC and with C++ compilers. */ #undef FLEXIBLE_ARRAY_MEMBER +/* Define to 1 if mkdir mistakenly creates a directory given with a trailing + dot component. */ +#undef FUNC_MKDIR_DOT_BUG + /* Define to 1 if realpath() can malloc memory, always gives an absolute path, and handles trailing slash correctly. */ #undef FUNC_REALPATH_WORKS diff --git a/gdb/gnulib/configure b/gdb/gnulib/configure index a5d76ac..8c30276 100644 --- a/gdb/gnulib/configure +++ b/gdb/gnulib/configure @@ -5732,6 +5732,7 @@ fi # Code from module memmem-simple: # Code from module mempcpy: # Code from module memrchr: + # Code from module mkdir: # Code from module mkstemp: # Code from module msvc-inval: # Code from module msvc-nothrow: @@ -20781,6 +20782,131 @@ $as_echo "#define GNULIB_TEST_MEMRCHR 1" >>confdefs.h + : + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing slash" >&5 +$as_echo_n "checking whether mkdir handles trailing slash... " >&6; } +if ${gl_cv_func_mkdir_trailing_slash_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.dir + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_mkdir_trailing_slash_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include + +int +main () +{ +return mkdir ("conftest.dir/", 0700); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_mkdir_trailing_slash_works=yes +else + gl_cv_func_mkdir_trailing_slash_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.dir + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_slash_works" >&5 +$as_echo "$gl_cv_func_mkdir_trailing_slash_works" >&6; } + case "$gl_cv_func_mkdir_trailing_slash_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing dot" >&5 +$as_echo_n "checking whether mkdir handles trailing dot... " >&6; } +if ${gl_cv_func_mkdir_trailing_dot_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.dir + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include + +int +main () +{ +return !mkdir ("conftest.dir/./", 0700); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_mkdir_trailing_dot_works=yes +else + gl_cv_func_mkdir_trailing_dot_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.dir + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_dot_works" >&5 +$as_echo "$gl_cv_func_mkdir_trailing_dot_works" >&6; } + case "$gl_cv_func_mkdir_trailing_dot_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + +$as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h + + ;; + esac + + if test $REPLACE_MKDIR = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext" + + fi + + : diff --git a/gdb/gnulib/import/Makefile.am b/gdb/gnulib/import/Makefile.am index 8409386..67acc9d 100644 --- a/gdb/gnulib/import/Makefile.am +++ b/gdb/gnulib/import/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h +# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkdir mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h AUTOMAKE_OPTIONS = 1.9.6 gnits @@ -1169,6 +1169,15 @@ EXTRA_libgnu_a_SOURCES += memrchr.c ## end gnulib module memrchr +## begin gnulib module mkdir + + +EXTRA_DIST += mkdir.c + +EXTRA_libgnu_a_SOURCES += mkdir.c + +## end gnulib module mkdir + ## begin gnulib module mkstemp diff --git a/gdb/gnulib/import/Makefile.in b/gdb/gnulib/import/Makefile.in index 8f00111..5c1a22b 100644 --- a/gdb/gnulib/import/Makefile.in +++ b/gdb/gnulib/import/Makefile.in @@ -35,7 +35,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h +# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkdir mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h @@ -189,6 +189,7 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \ $(top_srcdir)/import/m4/memmem.m4 \ $(top_srcdir)/import/m4/mempcpy.m4 \ $(top_srcdir)/import/m4/memrchr.m4 \ + $(top_srcdir)/import/m4/mkdir.m4 \ $(top_srcdir)/import/m4/mkstemp.m4 \ $(top_srcdir)/import/m4/mmap-anon.m4 \ $(top_srcdir)/import/m4/mode_t.m4 \ @@ -1465,9 +1466,9 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h assure.h \ lstat.c malloc.c malloca.h malloca.valgrind math.in.h \ mbrtowc.c mbsinit.c mbsrtowcs-impl.h mbsrtowcs-state.c \ mbsrtowcs.c memchr.c memchr.valgrind memmem.c str-two-way.h \ - mempcpy.c memrchr.c mkstemp.c msvc-inval.c msvc-inval.h \ - msvc-nothrow.c msvc-nothrow.h open.c openat.c openat.h \ - dirent-private.h opendir.c pathmax.h rawmemchr.c \ + mempcpy.c memrchr.c mkdir.c mkstemp.c msvc-inval.c \ + msvc-inval.h msvc-nothrow.c msvc-nothrow.h open.c openat.c \ + openat.h dirent-private.h opendir.c pathmax.h rawmemchr.c \ rawmemchr.valgrind dirent-private.h readdir.c readlink.c \ realloc.c rename.c dirent-private.h rewinddir.c rmdir.c \ same-inode.h save-cwd.h secure_getenv.c setenv.c signal.in.h \ @@ -1533,9 +1534,9 @@ EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c canonicalize-lgpl.c \ fstatat.c getcwd.c getcwd-lgpl.c getdtablesize.c getlogin_r.c \ gettimeofday.c glob.c isnan.c isnand.c isnan.c isnanl.c \ lstat.c malloc.c mbrtowc.c mbsinit.c mbsrtowcs-state.c \ - mbsrtowcs.c memchr.c memmem.c mempcpy.c memrchr.c mkstemp.c \ - msvc-inval.c msvc-nothrow.c open.c openat.c opendir.c \ - rawmemchr.c readdir.c readlink.c realloc.c rename.c \ + mbsrtowcs.c memchr.c memmem.c mempcpy.c memrchr.c mkdir.c \ + mkstemp.c msvc-inval.c msvc-nothrow.c open.c openat.c \ + opendir.c rawmemchr.c readdir.c readlink.c realloc.c rename.c \ rewinddir.c rmdir.c secure_getenv.c setenv.c stat.c \ strchrnul.c strdup.c strerror.c strerror-override.c strstr.c \ strtok_r.c unsetenv.c @@ -1667,6 +1668,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memrchr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkstemp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-inval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-nothrow.Po@am__quote@ diff --git a/gdb/gnulib/import/m4/gnulib-cache.m4 b/gdb/gnulib/import/m4/gnulib-cache.m4 index f65058f..225b52a 100644 --- a/gdb/gnulib/import/m4/gnulib-cache.m4 +++ b/gdb/gnulib/import/m4/gnulib-cache.m4 @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h +# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkdir mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -46,6 +46,7 @@ gl_MODULES([ lstat memchr memmem + mkdir mkstemp pathmax rawmemchr diff --git a/gdb/gnulib/import/m4/gnulib-comp.m4 b/gdb/gnulib/import/m4/gnulib-comp.m4 index c5a8092..6fee9ef 100644 --- a/gdb/gnulib/import/m4/gnulib-comp.m4 +++ b/gdb/gnulib/import/m4/gnulib-comp.m4 @@ -118,6 +118,7 @@ AC_DEFUN([gl_EARLY], # Code from module memmem-simple: # Code from module mempcpy: # Code from module memrchr: + # Code from module mkdir: # Code from module mkstemp: # Code from module msvc-inval: # Code from module msvc-nothrow: @@ -424,6 +425,10 @@ AC_DEFUN([gl_INIT], gl_PREREQ_MEMRCHR fi gl_STRING_MODULE_INDICATOR([memrchr]) + gl_FUNC_MKDIR + if test $REPLACE_MKDIR = 1; then + AC_LIBOBJ([mkdir]) + fi gl_FUNC_MKSTEMP if test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1; then AC_LIBOBJ([mkstemp]) @@ -813,6 +818,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/memmem.c lib/mempcpy.c lib/memrchr.c + lib/mkdir.c lib/mkstemp.c lib/msvc-inval.c lib/msvc-inval.h @@ -952,6 +958,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/memmem.m4 m4/mempcpy.m4 m4/memrchr.m4 + m4/mkdir.m4 m4/mkstemp.m4 m4/mmap-anon.m4 m4/mode_t.m4 diff --git a/gdb/gnulib/import/m4/mkdir.m4 b/gdb/gnulib/import/m4/mkdir.m4 new file mode 100644 index 0000000..574092b --- /dev/null +++ b/gdb/gnulib/import/m4/mkdir.m4 @@ -0,0 +1,69 @@ +# serial 11 + +# Copyright (C) 2001, 2003-2004, 2006, 2008-2016 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# On some systems, mkdir ("foo/", 0700) fails because of the trailing slash. +# On others, mkdir ("foo/./", 0700) mistakenly succeeds. +# On such systems, arrange to use a wrapper function. +AC_DEFUN([gl_FUNC_MKDIR], +[dnl + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether mkdir handles trailing slash], + [gl_cv_func_mkdir_trailing_slash_works], + [rm -rf conftest.dir + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +# include +# include +]], [return mkdir ("conftest.dir/", 0700);])], + [gl_cv_func_mkdir_trailing_slash_works=yes], + [gl_cv_func_mkdir_trailing_slash_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_mkdir_trailing_slash_works="guessing no" ;; + esac + ]) + rm -rf conftest.dir + ] + ) + case "$gl_cv_func_mkdir_trailing_slash_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + ;; + esac + + AC_CACHE_CHECK([whether mkdir handles trailing dot], + [gl_cv_func_mkdir_trailing_dot_works], + [rm -rf conftest.dir + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +# include +# include +]], [return !mkdir ("conftest.dir/./", 0700);])], + [gl_cv_func_mkdir_trailing_dot_works=yes], + [gl_cv_func_mkdir_trailing_dot_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;; + esac + ]) + rm -rf conftest.dir + ] + ) + case "$gl_cv_func_mkdir_trailing_dot_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly + creates a directory given with a trailing dot component.]) + ;; + esac +]) diff --git a/gdb/gnulib/import/mkdir.c b/gdb/gnulib/import/mkdir.c new file mode 100644 index 0000000..59bdea1 --- /dev/null +++ b/gdb/gnulib/import/mkdir.c @@ -0,0 +1,93 @@ +/* On some systems, mkdir ("foo/", 0700) fails because of the trailing + slash. On those systems, this wrapper removes the trailing slash. + + Copyright (C) 2001, 2003, 2006, 2008-2016 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#include "dirname.h" + +/* Disable the definition of mkdir to rpl_mkdir (from the + substitute) in this file. Otherwise, we'd get an endless recursion. */ +#undef mkdir + +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. + Additionally, it declares _mkdir (and depending on compile flags, an + alias mkdir), only in the nonstandard includes and , + which are included in the override. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define mkdir(name,mode) _mkdir (name) +# define maybe_unused _GL_UNUSED +#else +# define maybe_unused /* empty */ +#endif + +/* This function is required at least for NetBSD 1.5.2. */ + +int +rpl_mkdir (char const *dir, mode_t mode maybe_unused) +{ + int ret_val; + char *tmp_dir; + size_t len = strlen (dir); + + if (len && dir[len - 1] == '/') + { + tmp_dir = strdup (dir); + if (!tmp_dir) + { + /* Rather than rely on strdup-posix, we set errno ourselves. */ + errno = ENOMEM; + return -1; + } + strip_trailing_slashes (tmp_dir); + } + else + { + tmp_dir = (char *) dir; + } +#if FUNC_MKDIR_DOT_BUG + /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */ + { + char *last = last_component (tmp_dir); + if (*last == '.' && (last[1] == '\0' + || (last[1] == '.' && last[2] == '\0'))) + { + struct stat st; + if (stat (tmp_dir, &st) == 0) + errno = EEXIST; + return -1; + } + } +#endif /* FUNC_MKDIR_DOT_BUG */ + + ret_val = mkdir (tmp_dir, mode); + + if (tmp_dir != dir) + free (tmp_dir); + + return ret_val; +} diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh index bef4937..1c2ee4b 100755 --- a/gdb/gnulib/update-gnulib.sh +++ b/gdb/gnulib/update-gnulib.sh @@ -44,6 +44,7 @@ IMPORTED_GNULIB_MODULES="\ limits-h \ memchr \ memmem \ + mkdir \ mkstemp \ pathmax \ rawmemchr \