jehanne: fix open_translator

This commit is contained in:
2017-08-24 00:10:39 +02:00
parent 779da685df
commit 0ec8faf91e

View File

@ -18,6 +18,7 @@
/* we cannot include u.h and libc.h due to name collisions */ /* we cannot include u.h and libc.h due to name collisions */
#define nil ((void*)0)
typedef long off_t; typedef long off_t;
typedef long ptrdiff_t; typedef long ptrdiff_t;
typedef unsigned long uint64_t; typedef unsigned long uint64_t;
@ -157,25 +158,27 @@ open_translator(int flag, int mode, long *omode, long *cperm)
*omode |= OCEXEC; *omode |= OCEXEC;
} }
/* translate permissions */ if(omode == nil || (flag & O_CREAT) != 0){
if(mode & S_IRUSR) /* translate permissions */
*cperm |= OREAD << 6; if(mode & S_IRUSR)
if(mode & S_IWUSR) *cperm |= DMREAD << 6;
*cperm |= OWRITE << 6; if(mode & S_IWUSR)
if(mode & S_IXUSR) *cperm |= DMWRITE << 6;
*cperm |= OEXEC << 6; if(mode & S_IXUSR)
if(mode & S_IRGRP) *cperm |= DMEXEC << 6;
*cperm |= OREAD << 3; if(mode & S_IRGRP)
if(mode & S_IWGRP) *cperm |= DMREAD << 3;
*cperm |= OWRITE << 3; if(mode & S_IWGRP)
if(mode & S_IXGRP) *cperm |= DMWRITE << 3;
*cperm |= OEXEC << 3; if(mode & S_IXGRP)
if(mode & S_IROTH) *cperm |= DMEXEC << 3;
*cperm |= OREAD; if(mode & S_IROTH)
if(mode & S_IWOTH) *cperm |= DMREAD;
*cperm |= OWRITE; if(mode & S_IWOTH)
if(mode & S_IXOTH) *cperm |= DMWRITE;
*cperm |= OEXEC; if(mode & S_IXOTH)
*cperm |= DMEXEC;
}
if(flag & O_CREAT){ if(flag & O_CREAT){
if(flag & O_DIRECTORY){ if(flag & O_DIRECTORY){