Patch attached.
I tested it by running getconf.exe, and also as follows:
$ cat case_sens_test.c
#include <unistd.h>
#include <stdio.h>
void
test (const char *path)
{
int ret = pathconf (path, _PC_CASE_INSENSITIVE);
printf ("pathconf (\"%s\", _PC_CASE_INSENSITIVE) returns %d\n", path,
ret);
if (ret == -1)
perror (" pathconf");
}
int
main ()
{
test ("/tmp");
test ("/tmp/a");
test ("/cygdrive/c/cygwin");
test ("/");
test (".");
}
$ gcc case_sens_test.c
$ ./a
pathconf ("/tmp", _PC_CASE_INSENSITIVE) returns 0
pathconf ("/tmp/a", _PC_CASE_INSENSITIVE) returns -1
pathconf: No such file or directory
pathconf ("/cygdrive/c/cygwin", _PC_CASE_INSENSITIVE) returns 1
pathconf ("/", _PC_CASE_INSENSITIVE) returns 0
pathconf (".", _PC_CASE_INSENSITIVE) returns 0
This test was done, obviously, on a system with the obcaseinsensitive
registry key set to 0, and with /tmp/a non-existent. I also tested with
the registry key set to 1, with the expected results.
Ken
From 04b507edbfbbaade6ef19ba9302ac9a758886995 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbr...@cornell.edu>
Date: Thu, 20 Oct 2016 15:35:54 -0400
Subject: [PATCH] Add _PC_CASE_INSENSITIVE to [f]pathconf
Update the getconf utility to support the new flag as well as
_PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY. These were previously
unsupported, probably as an oversight.
---
newlib/libc/include/sys/unistd.h | 1 +
winsup/cygwin/fhandler.cc | 2 ++
winsup/cygwin/include/cygwin/version.h | 3 ++-
winsup/cygwin/release/2.6.1 | 2 ++
winsup/utils/getconf.c | 3 +++
5 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index 05b4f9d..143147d 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -490,6 +490,7 @@ int _EXFUN(unlinkat, (int, const char *, int));
#define _PC_POSIX_PERMISSIONS 90
/* Ask for full POSIX permission support including uid/gid settings. */
#define _PC_POSIX_SECURITY 91
+#define _PC_CASE_INSENSITIVE 92
#endif
/*
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index d77ccd3..9ab52ad 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1891,6 +1891,8 @@ fhandler_base::fpathconf (int v)
return pc.has_acls () || pc.fs_is_nfs ();
set_errno (EINVAL);
break;
+ case _PC_CASE_INSENSITIVE:
+ return !!pc.objcaseinsensitive ();
default:
set_errno (EINVAL);
break;
diff --git a/winsup/cygwin/include/cygwin/version.h
b/winsup/cygwin/include/cygwin/version.h
index 1c1402c..6ba602e 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -469,12 +469,13 @@ details. */
302: Export nl_langinfo_l.
303: Export pthread_getname_np, pthread_setname_np.
304: Export strerror_l, strptime_l, wcsftime_l.
+ 305: [f]pathconf flag _PC_CASE_INSENSITIVE added.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 304
+#define CYGWIN_VERSION_API_MINOR 305
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/release/2.6.1 b/winsup/cygwin/release/2.6.1
index 61ce2de..7ced3c4 100644
--- a/winsup/cygwin/release/2.6.1
+++ b/winsup/cygwin/release/2.6.1
@@ -1,6 +1,8 @@
What's new:
-----------
+- Add _PC_CASE_INSENSITIVE flag to [f]pathconf(3).
+
What changed:
-------------
diff --git a/winsup/utils/getconf.c b/winsup/utils/getconf.c
index 8539233..e6b319e 100644
--- a/winsup/utils/getconf.c
+++ b/winsup/utils/getconf.c
@@ -186,6 +186,7 @@ static const struct conf_variable conf_table[] =
{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX
},
/* Variables from fpathconf() */
+ { "CASE_INSENSITIVE", PATHCONF,
_PC_CASE_INSENSITIVE },
{ "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS
},
{ "LINK_MAX", PATHCONF, _PC_LINK_MAX
},
{ "MAX_CANON", PATHCONF, _PC_MAX_CANON
},
@@ -195,10 +196,12 @@ static const struct conf_variable conf_table[] =
{ "PIPE_BUF", PATHCONF, _PC_PIPE_BUF
},
{ "POSIX2_SYMLINKS", PATHCONF, _PC_2_SYMLINKS
},
{ "POSIX_ALLOC_SIZE_MIN", PATHCONF, _PC_ALLOC_SIZE_MIN
},
+ { "POSIX_PERMISSIONS", PATHCONF, _PC_POSIX_PERMISSIONS
},
{ "POSIX_REC_INCR_XFER_SIZE", PATHCONF,
_PC_REC_INCR_XFER_SIZE },
{ "POSIX_REC_MAX_XFER_SIZE", PATHCONF, _PC_REC_MAX_XFER_SIZE
},
{ "POSIX_REC_MIN_XFER_SIZE", PATHCONF, _PC_REC_MIN_XFER_SIZE
},
{ "POSIX_REC_XFER_ALIGN", PATHCONF, _PC_REC_XFER_ALIGN
},
+ { "POSIX_SECURITY", PATHCONF, _PC_POSIX_SECURITY
},
{ "SYMLINK_MAX", PATHCONF, _PC_SYMLINK_MAX
},
{ "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED
},
{ "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC
},
--
2.8.3