This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH,HURD] mknod: allow to create also sockets


Hi,

attached there is a small patch to allow Hurd's mknod(at) to create also 
sockets; while POSIX does not specify them, on Linux they seem to be 
supported, and the implementation is very small.
I also took the liberty of simplifying the checks done to decide whether 
use the device number provided.

Thanks,
-- 
Pino Toscano
Hurd: mknodat: create also sockets

2012-09-28  Pino Toscano  <toscano.pino@tiscali.it>

	* sysdeps/mach/hurd/xmknodat.c: Allow to create sockets.  Simplify the
	check for translators needing the device number.
--- a/sysdeps/mach/hurd/xmknodat.c
+++ b/sysdeps/mach/hurd/xmknodat.c
@@ -39,6 +39,7 @@ __xmknodat (int vers, int fd, const char
   char buf[100], *bp;
   const char *translator;
   size_t len;
+  int needdevice = 0;
 
   if (vers != _MKNOD_VER)
     return __hurd_fail (EINVAL);
@@ -47,17 +48,24 @@ __xmknodat (int vers, int fd, const char
     {
       translator = _HURD_CHRDEV;
       len = sizeof (_HURD_CHRDEV);
+      needdevice = 1;
     }
   else if (S_ISBLK (mode))
     {
       translator = _HURD_BLKDEV;
       len = sizeof (_HURD_BLKDEV);
+      needdevice = 1;
     }
   else if (S_ISFIFO (mode))
     {
       translator = _HURD_FIFO;
       len = sizeof (_HURD_FIFO);
     }
+  else if (S_ISSOCK (mode))
+    {
+      translator = _HURD_IFSOCK;
+      len = sizeof (_HURD_IFSOCK);
+    }
   else if (S_ISREG (mode))
     {
       translator = NULL;
@@ -69,7 +77,7 @@ __xmknodat (int vers, int fd, const char
       return -1;
     }
 
-  if (translator != NULL && ! S_ISFIFO (mode))
+  if (needdevice)
     {
       /* We set the translator to "ifmt\0major\0minor\0", where IFMT
 	 depends on the S_IFMT bits of our MODE argument, and MAJOR and

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]