aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.txt4
-rw-r--r--Makefile.in2
-rw-r--r--ports/unix/guts/mkfifoat.c64
-rw-r--r--ports/unix/guts/mknodat.c18
4 files changed, 72 insertions, 16 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 47229fb..7f51dbd 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2015-07-17:
+ * (seebs) allow actually making fifos without randomly closing fd 0
+ * 1.6.7
+
2015-07-16:
* (seebs) don't truncate xattr attributes that end with a slash.
* (seebs) allow actually making fifos
diff --git a/Makefile.in b/Makefile.in
index 4a36eb6..7379648 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,7 @@ BITS=@BITS@
ARCH_FLAGS=@ARCH_FLAGS@
MARK64=@MARK64@
RPATH=@RPATH@
-VERSION=1.6.6
+VERSION=1.6.7
LIB=@LIB@
BIN=bin
diff --git a/ports/unix/guts/mkfifoat.c b/ports/unix/guts/mkfifoat.c
index 3497f37..4101a72 100644
--- a/ports/unix/guts/mkfifoat.c
+++ b/ports/unix/guts/mkfifoat.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2010 Wind River Systems; see
+ * Copyright (c) 2015 Wind River Systems; see
* guts/COPYRIGHT for information.
*
* static int
@@ -7,7 +7,67 @@
* int rc = -1;
*/
- rc = wrap_mknodat(dirfd, path, (mode & 07777) | S_IFIFO, (dev_t) 0);
+ pseudo_msg_t *msg;
+ PSEUDO_STATBUF buf;
+ int save_errno = errno;
+
+ /* mask out mode bits appropriately */
+ mode = mode & ~pseudo_umask;
+
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+ if (dirfd != AT_FDCWD) {
+ errno = ENOSYS;
+ return -1;
+ }
+ rc = base_stat(path, &buf);
+#else
+ rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
+#endif
+ if (rc != -1) {
+ /* if we can stat the file, you can't mkfifo it */
+ errno = EEXIST;
+ return -1;
+ }
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+ rc = real_mkfifo(path, PSEUDO_FS_MODE(mode, 0));
+ if (rc == -1) {
+ return -1;
+ }
+ rc = base_stat(path, &buf);
+#else
+ rc = real_mkfifoat(dirfd, path, PSEUDO_FS_MODE(mode, 0));
+ if (rc == -1) {
+ return -1;
+ }
+ rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
+#endif
+ /* if the stat failed, we are going to give up and nuke
+ * any file we may have created, and hope for the best.
+ */
+ if (rc == 0) {
+ buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
+ /* mkfifo/mknod are the same op, in that they create a file
+ * with a non-file type.
+ */
+ msg = pseudo_client_op(OP_MKNOD, 0, -1, dirfd, path, &buf);
+ if (msg && msg->result != RESULT_SUCCEED) {
+ errno = EPERM;
+ rc = -1;
+ } else {
+ /* just pretend we worked */
+ errno = save_errno;
+ rc = 0;
+ }
+ }
+ if (rc == -1) {
+ save_errno = errno;
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+ real_unlink(path);
+#else
+ real_unlinkat(dirfd, path, AT_SYMLINK_NOFOLLOW);
+#endif
+ errno = save_errno;
+ }
/* return rc;
* }
diff --git a/ports/unix/guts/mknodat.c b/ports/unix/guts/mknodat.c
index d173ba5..5d8d47c 100644
--- a/ports/unix/guts/mknodat.c
+++ b/ports/unix/guts/mknodat.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011,2015 Wind River Systems; see
+ * Copyright (c) 2011 Wind River Systems; see
* guts/COPYRIGHT for information.
*
* int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev)
@@ -28,19 +28,11 @@
return -1;
}
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (S_ISFIFO(mode)) {
- rc = real_mkfifo(path, PSEUDO_FS_MODE(mode, 0));
- } else {
- rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL,
- PSEUDO_FS_MODE(mode, 0));
- }
+ rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL,
+ PSEUDO_FS_MODE(mode, 0));
#else
- if (S_ISFIFO(mode)) {
- rc = real_mkfifoat(dirfd, path, PSEUDO_FS_MODE(mode, 0));
- } else {
- rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL,
- PSEUDO_FS_MODE(mode, 0));
- }
+ rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL,
+ PSEUDO_FS_MODE(mode, 0));
#endif
if (rc == -1) {
return -1;