Re: Implement mkfifo() and mkfifoat() using mknodat()

2014-10-23 Thread Dimitris Papastamos
On Thu, Oct 23, 2014 at 11:12:02AM -0400, Ted Unangst wrote:
> On Thu, Oct 23, 2014 at 15:16, Dimitris Papastamos wrote:
> > Hi everyone,
> > 
> > This is my attempt to add libc wrappers for mkfifo() and
> > mkfifoat() using mknodat().
> 
> Is there a reason? This would seem to do nothing except complicate the
> interpretation of ktrace.

This is a valid point.  I'll drop this for now.



Re: Implement mkfifo() and mkfifoat() using mknodat()

2014-10-23 Thread Theo de Raadt
>On Thu, Oct 23, 2014 at 15:16, Dimitris Papastamos wrote:
>> Hi everyone,
>> 
>> This is my attempt to add libc wrappers for mkfifo() and
>> mkfifoat() using mknodat().
>
>Is there a reason? This would seem to do nothing except complicate the
>interpretation of ktrace.

Exactly.  We have steered clear of other such wrappers recently for
the same reason.



Re: Implement mkfifo() and mkfifoat() using mknodat()

2014-10-23 Thread Todd C. Miller
I'm not convinced we actually want to do this, but your wrapper is
missing something like this:

mode &= ~ACCESSPERMS;

 - todd



Re: Implement mkfifo() and mkfifoat() using mknodat()

2014-10-23 Thread Ted Unangst
On Thu, Oct 23, 2014 at 15:16, Dimitris Papastamos wrote:
> Hi everyone,
> 
> This is my attempt to add libc wrappers for mkfifo() and
> mkfifoat() using mknodat().

Is there a reason? This would seem to do nothing except complicate the
interpretation of ktrace.



Implement mkfifo() and mkfifoat() using mknodat()

2014-10-23 Thread Dimitris Papastamos
Hi everyone,

This is my attempt to add libc wrappers for mkfifo() and
mkfifoat() using mknodat().

Do I need to do anything else?  Should the manpage for mkfifo(2)
and mkfifoat(2) be moved to section 3?

Cheers,
Dimitris

===
RCS file: /cvs/src/lib/libc/sys/Makefile.inc,v
retrieving revision 1.122
diff -u -p -r1.122 Makefile.inc
--- sys/Makefile.inc31 Aug 2014 04:02:08 -  1.122
+++ sys/Makefile.inc23 Oct 2014 14:14:13 -
@@ -11,7 +11,7 @@ SRCS+=Ovfork.S brk.S cerror.S exect.S f
sigsuspend.S syscall.S tfork_thread.S
 
 # glue to offer userland wrappers for some syscalls
-SRCS+= posix_madvise.c
+SRCS+= posix_madvise.c mkfifo.c mkfifoat.c
 
 # glue to provide compatibility between GCC 1.X and 2.X and for compat
 # with old syscall interfaces.
@@ -41,7 +41,7 @@ ASM=  __get_tcb.o __getcwd.o __semctl.o _
getsockopt.o getthrid.o gettimeofday.o getuid.o ioctl.o \
issetugid.o kevent.o kill.o kqueue.o ktrace.o lchown.o \
link.o linkat.o listen.o lstat.o madvise.o mincore.o \
-   minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \
+   minherit.o mkdir.o mkdirat.o \
mknod.o mknodat.o mlock.o mlockall.o mount.o mprotect.o \
msgctl.o msgget.o msgrcv.o msgsnd.o msync.o munlock.o \
munlockall.o munmap.o nanosleep.o nfssvc.o \
Index: sys/mkfifo.c
===
RCS file: sys/mkfifo.c
diff -N sys/mkfifo.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/mkfifo.c23 Oct 2014 14:14:13 -
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Dimitris Papastamos 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+
+int
+mkfifo(const char *path, mode_t mode)
+{
+   return mknodat(AT_FDCWD, path, mode | S_IFIFO, 0);
+}
Index: sys/mkfifoat.c
===
RCS file: sys/mkfifoat.c
diff -N sys/mkfifoat.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/mkfifoat.c  23 Oct 2014 14:14:13 -
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Dimitris Papastamos 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+
+int
+mkfifoat(int fd, const char *path, mode_t mode)
+{
+   return mknodat(fd, path, mode | S_IFIFO, 0);
+}