diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-06-16 19:23:58 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-06-16 19:23:58 +0000 |
commit | 6c40ea7c3c87cbda213126fc5742d5c7d4f41cdf (patch) | |
tree | ab6a0a89038d638b6d60a144fd2572c6cdf4c4f7 /libdiskfs | |
parent | 47fbd0b8d6d87ff7adb6e2319b26637205b2b7ca (diff) |
entered into RCS
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/file-access.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/libdiskfs/file-access.c b/libdiskfs/file-access.c index 3f24d07d..7553ffda 100644 --- a/libdiskfs/file-access.c +++ b/libdiskfs/file-access.c @@ -17,30 +17,28 @@ #include "priv.h" #include "fs_S.h" +#include <fcntl.h> kern_return_t -diskfs_S_file_access (struct protid *cred, - int type) +diskfs_S_file_check_access (struct protid *cred, + int *type) { struct node *np; - error_t err; if (!cred) return EOPNOTSUPP; - if (type & ~(R_OK|W_OK|X_OK)) - return EINVAL; - np = cred->po->np; mutex_lock (&np->lock); - err = 0; - if (type & R_OK) - err = diskfs_access (np, S_IREAD, cred); - if (!err && (type & W_OK)) - err = diskfs_access (np, S_IWRITE, cred); - if (!err && (type & X_OK)) - err = diskfs_access (np, S_IEXEC, cred); + *type = 0; + if (diskfs_access (np, S_IREAD, cred) == 0) + *type |= O_READ; + if (diskfs_access (np, S_IWRITE, cred) == 0) + *type |= O_WRITE; + if (diskfs_access (np, S_IEXEC, cred) == 0) + *type |= O_EXEC; + mutex_unlock (&np->lock); - return err; + return 0; } |