diff --git a/libsysio/src/mkdir.c b/libsysio/src/mkdir.c index 1d89acd9dceba06204207022921a9b8b52ab47b3..ee59348515d18fb6591e3d2970f7ca761faecea5 100644 --- a/libsysio/src/mkdir.c +++ b/libsysio/src/mkdir.c @@ -76,6 +76,8 @@ SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode) err = -EROFS; goto error; } + mode |= S_IFDIR; + mode &= ~(_sysio_umask & 0777); /* apply umask */ err = (*pno->p_parent->p_base->pb_ino->i_ops.inop_mkdir)(pno, mode); error: P_RELE(pno); diff --git a/libsysio/src/mknod.c b/libsysio/src/mknod.c index 288dccea75ad8692385220515a551b8778fe0b42..35ca0f982a6e76596990f1879e9f8e3ad5f02d3e 100644 --- a/libsysio/src/mknod.c +++ b/libsysio/src/mknod.c @@ -80,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)