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;
} }
if(omode == nil || (flag & O_CREAT) != 0){
/* translate permissions */ /* translate permissions */
if(mode & S_IRUSR) if(mode & S_IRUSR)
*cperm |= OREAD << 6; *cperm |= DMREAD << 6;
if(mode & S_IWUSR) if(mode & S_IWUSR)
*cperm |= OWRITE << 6; *cperm |= DMWRITE << 6;
if(mode & S_IXUSR) if(mode & S_IXUSR)
*cperm |= OEXEC << 6; *cperm |= DMEXEC << 6;
if(mode & S_IRGRP) if(mode & S_IRGRP)
*cperm |= OREAD << 3; *cperm |= DMREAD << 3;
if(mode & S_IWGRP) if(mode & S_IWGRP)
*cperm |= OWRITE << 3; *cperm |= DMWRITE << 3;
if(mode & S_IXGRP) if(mode & S_IXGRP)
*cperm |= OEXEC << 3; *cperm |= DMEXEC << 3;
if(mode & S_IROTH) if(mode & S_IROTH)
*cperm |= OREAD; *cperm |= DMREAD;
if(mode & S_IWOTH) if(mode & S_IWOTH)
*cperm |= OWRITE; *cperm |= DMWRITE;
if(mode & S_IXOTH) if(mode & S_IXOTH)
*cperm |= OEXEC; *cperm |= DMEXEC;
}
if(flag & O_CREAT){ if(flag & O_CREAT){
if(flag & O_DIRECTORY){ if(flag & O_DIRECTORY){