|
|
147e83 |
commit adbb8027be47b3295367019b2f45863ea3d6c727
|
|
|
147e83 |
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
|
|
|
147e83 |
Date: Thu Mar 7 12:15:08 2013 +0530
|
|
|
147e83 |
|
|
|
147e83 |
Remove PIPE_BUF Linux-specific code
|
|
|
147e83 |
|
|
|
147e83 |
Fixes BZ #12723
|
|
|
147e83 |
|
|
|
147e83 |
The variable pipe buffer size does nothing to the value of PIPE_BUF,
|
|
|
147e83 |
since the number of bytes that are atomically written is still
|
|
|
147e83 |
PIPE_BUF on Linux.
|
|
|
147e83 |
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/posix/Makefile glibc-2.17-c758a686/posix/Makefile
|
|
|
147e83 |
index 2cacd21..658c47e 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/posix/Makefile
|
|
|
147e83 |
+++ glibc-2.17-c758a686/posix/Makefile
|
|
|
147e83 |
@@ -86,7 +86,8 @@ tests := tstgetopt testfnm runtests runptests \
|
|
|
147e83 |
tst-rfc3484-3 \
|
|
|
147e83 |
tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \
|
|
|
147e83 |
bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
|
|
|
147e83 |
- bug-getopt5 tst-getopt_long1 bug-regex34
|
|
|
147e83 |
+ bug-getopt5 tst-getopt_long1 bug-regex34 \
|
|
|
147e83 |
+ tst-pathconf
|
|
|
147e83 |
xtests := bug-ga2
|
|
|
147e83 |
ifeq (yes,$(build-shared))
|
|
|
147e83 |
test-srcs := globtest
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/posix/tst-pathconf.c glibc-2.17-c758a686/posix/tst-pathconf.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..7627a24
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ glibc-2.17-c758a686/posix/tst-pathconf.c
|
|
|
147e83 |
@@ -0,0 +1,176 @@
|
|
|
147e83 |
+/* Test that values of pathconf and fpathconf are consistent for a file.
|
|
|
147e83 |
+ Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include <fcntl.h>
|
|
|
147e83 |
+#include <stdio.h>
|
|
|
147e83 |
+#include <stdlib.h>
|
|
|
147e83 |
+#include <string.h>
|
|
|
147e83 |
+#include <unistd.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+
|
|
|
147e83 |
+static void prepare (void);
|
|
|
147e83 |
+#define PREPARE(argc, argv) prepare ()
|
|
|
147e83 |
+
|
|
|
147e83 |
+static int do_test (void);
|
|
|
147e83 |
+#define TEST_FUNCTION do_test ()
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include "../test-skeleton.c"
|
|
|
147e83 |
+
|
|
|
147e83 |
+static int dir_fd;
|
|
|
147e83 |
+static char *dirbuf;
|
|
|
147e83 |
+
|
|
|
147e83 |
+static void
|
|
|
147e83 |
+prepare (void)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ size_t test_dir_len = strlen (test_dir);
|
|
|
147e83 |
+ static const char dir_name[] = "/tst-pathconf.XXXXXX";
|
|
|
147e83 |
+
|
|
|
147e83 |
+ size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
|
|
147e83 |
+ dirbuf = malloc (dirbuflen);
|
|
|
147e83 |
+ if (dirbuf == NULL)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ puts ("Out of memory");
|
|
|
147e83 |
+ exit (1);
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
|
|
147e83 |
+ if (mkdtemp (dirbuf) == NULL)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("Cannot create temporary directory: %s\n", strerror (errno));
|
|
|
147e83 |
+ exit (1);
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ add_temp_file (dirbuf);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ dir_fd = open (dirbuf, O_RDONLY);
|
|
|
147e83 |
+ if (dir_fd == -1)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("Cannot open directory: %s\n", strerror (errno));
|
|
|
147e83 |
+ exit (1);
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+}
|
|
|
147e83 |
+
|
|
|
147e83 |
+
|
|
|
147e83 |
+static int
|
|
|
147e83 |
+do_test (void)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ int ret = 0;
|
|
|
147e83 |
+ static const char *fifo_name = "some-fifo";
|
|
|
147e83 |
+
|
|
|
147e83 |
+ size_t filenamelen = strlen (dirbuf) + strlen (fifo_name) + 2;
|
|
|
147e83 |
+ char *filename = malloc (filenamelen);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ snprintf (filename, filenamelen, "%s/%s", dirbuf, fifo_name);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Create a fifo in the directory. */
|
|
|
147e83 |
+ int e = mkfifo (filename, 0777);
|
|
|
147e83 |
+ if (e == -1)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("fifo creation failed (%s)\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out_nofifo;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ long dir_pathconf = pathconf (dirbuf, _PC_PIPE_BUF);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (dir_pathconf < 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("pathconf on directory failed: %s\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out_nofifo;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ long fifo_pathconf = pathconf (filename, _PC_PIPE_BUF);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (fifo_pathconf < 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("pathconf on file failed: %s\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out_nofifo;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ int fifo = open (filename, O_RDONLY | O_NONBLOCK);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (fifo < 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("fifo open failed (%s)\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out_nofifo;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ long dir_fpathconf = fpathconf (dir_fd, _PC_PIPE_BUF);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (dir_fpathconf < 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("fpathconf on directory failed: %s\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ long fifo_fpathconf = fpathconf (fifo, _PC_PIPE_BUF);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (fifo_fpathconf < 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("fpathconf on file failed: %s\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (fifo_pathconf != fifo_fpathconf)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("fifo pathconf (%ld) != fifo fpathconf (%ld)\n", fifo_pathconf,
|
|
|
147e83 |
+ fifo_fpathconf);
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (dir_pathconf != fifo_pathconf)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("directory pathconf (%ld) != fifo pathconf (%ld)\n",
|
|
|
147e83 |
+ dir_pathconf, fifo_pathconf);
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (dir_fpathconf != fifo_fpathconf)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("directory fpathconf (%ld) != fifo fpathconf (%ld)\n",
|
|
|
147e83 |
+ dir_fpathconf, fifo_fpathconf);
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ goto out;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+out:
|
|
|
147e83 |
+ close (fifo);
|
|
|
147e83 |
+out_nofifo:
|
|
|
147e83 |
+ close (dir_fd);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (unlink (filename) != 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("Could not remove fifo (%s)\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (rmdir (dirbuf) != 0)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("Could not remove directory (%s)\n", strerror (errno));
|
|
|
147e83 |
+ ret = 1;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
+ return ret;
|
|
|
147e83 |
+}
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/fpathconf.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/fpathconf.c
|
|
|
147e83 |
index c971644..e8c4dc9 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/fpathconf.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/fpathconf.c
|
|
|
147e83 |
@@ -33,7 +33,6 @@ __fpathconf (fd, name)
|
|
|
147e83 |
int name;
|
|
|
147e83 |
{
|
|
|
147e83 |
struct statfs fsbuf;
|
|
|
147e83 |
- int r;
|
|
|
147e83 |
|
|
|
147e83 |
switch (name)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -49,12 +48,6 @@ __fpathconf (fd, name)
|
|
|
147e83 |
case _PC_CHOWN_RESTRICTED:
|
|
|
147e83 |
return __statfs_chown_restricted (__fstatfs (fd, &fsbuf), &fsbuf);
|
|
|
147e83 |
|
|
|
147e83 |
- case _PC_PIPE_BUF:
|
|
|
147e83 |
- r = __fcntl (fd, F_GETPIPE_SZ);
|
|
|
147e83 |
- if (r > 0)
|
|
|
147e83 |
- return r;
|
|
|
147e83 |
- /* FALLTHROUGH */
|
|
|
147e83 |
-
|
|
|
147e83 |
default:
|
|
|
147e83 |
return posix_fpathconf (fd, name);
|
|
|
147e83 |
}
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
|
|
|
147e83 |
index edc691e..de91a45 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
|
|
|
147e83 |
@@ -39,8 +39,6 @@ long int
|
|
|
147e83 |
__pathconf (const char *file, int name)
|
|
|
147e83 |
{
|
|
|
147e83 |
struct statfs fsbuf;
|
|
|
147e83 |
- int fd;
|
|
|
147e83 |
- int flags;
|
|
|
147e83 |
|
|
|
147e83 |
switch (name)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -56,21 +54,6 @@ __pathconf (const char *file, int name)
|
|
|
147e83 |
case _PC_CHOWN_RESTRICTED:
|
|
|
147e83 |
return __statfs_chown_restricted (__statfs (file, &fsbuf), &fsbuf);
|
|
|
147e83 |
|
|
|
147e83 |
- case _PC_PIPE_BUF:
|
|
|
147e83 |
- flags = O_RDONLY|O_NONBLOCK|O_NOCTTY;
|
|
|
147e83 |
-#ifdef O_CLOEXEC
|
|
|
147e83 |
- flags |= O_CLOEXEC;
|
|
|
147e83 |
-#endif
|
|
|
147e83 |
- fd = open_not_cancel_2 (file, flags);
|
|
|
147e83 |
- if (fd >= 0)
|
|
|
147e83 |
- {
|
|
|
147e83 |
- long int r = __fcntl (fd, F_GETPIPE_SZ);
|
|
|
147e83 |
- close_not_cancel_no_status (fd);
|
|
|
147e83 |
- if (r > 0)
|
|
|
147e83 |
- return r;
|
|
|
147e83 |
- }
|
|
|
147e83 |
- /* FALLTHROUGH */
|
|
|
147e83 |
-
|
|
|
147e83 |
default:
|
|
|
147e83 |
return posix_pathconf (file, name);
|
|
|
147e83 |
}
|