summaryrefslogtreecommitdiff
path: root/libdiskfs/file-access.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-06-16 19:23:58 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-06-16 19:23:58 +0000
commit6c40ea7c3c87cbda213126fc5742d5c7d4f41cdf (patch)
treeab6a0a89038d638b6d60a144fd2572c6cdf4c4f7 /libdiskfs/file-access.c
parent47fbd0b8d6d87ff7adb6e2319b26637205b2b7ca (diff)
entered into RCS
Diffstat (limited to 'libdiskfs/file-access.c')
-rw-r--r--libdiskfs/file-access.c26
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;
}