From 6c40ea7c3c87cbda213126fc5742d5c7d4f41cdf Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 16 Jun 1994 19:23:58 +0000 Subject: entered into RCS --- libdiskfs/file-access.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'libdiskfs') 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 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; } -- cgit v1.2.3