Whamcloud - gitweb
add one tag in buildcvs in order to checkout right libsysio
[fs/lustre-release.git] / libsysio / src / mknod.c
index 4c947d2..35ca0f9 100644 (file)
 #undef mknod
 #undef __xmknod
 
-#if defined(BSD) || defined(REDSTORM)
-#define _MKNOD_VER     0
-#endif
-
 int
 PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(int __ver, 
                                          const char *path, 
@@ -84,13 +80,17 @@ PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(int __ver,
        }
 
        /*
-        * Support only character-special and fifos right now.
+        * Support only regular, character-special and fifos right now.
+        * (mode & S_IFMT) == 0 is the same as S_IFREG.
         */
-       if (!(S_ISCHR(mode) || S_ISFIFO(mode))) {
+       if ((mode & S_IFMT) &&
+           !(S_ISREG(mode) || S_ISCHR(mode) || S_ISFIFO(mode))) {
                err = -EINVAL;
                goto out;
        }
 
+       mode &= ~(_sysio_umask & 0777); /* apply umask */
+
        INTENT_INIT(&intent, INT_CREAT, &mode, NULL);
        err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno);
        if (err)