summaryrefslogtreecommitdiff
path: root/libtrivfs
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1998-07-14 20:51:12 +0000
committerThomas Bushnell <thomas@gnu.org>1998-07-14 20:51:12 +0000
commiteec166bfee3c6bf51e0df3ba4c057ea0477fc2f9 (patch)
tree7ca7e37d94e12bd10ffba54abbc87fd8fe553afa /libtrivfs
parent2a73bf157cefb9f4fef54dd9bd822808423bb380 (diff)
Tue Jul 14 16:47:28 1998 Thomas Bushnell, n/BSG <tb@mit.edu>
* dir-lookup.c (trivfs_S_dir_lookup): In null-pathname case, this should work even for non-directories, so actually do it, making this a simpler case of trivfs_S_fsys_getroot.
Diffstat (limited to 'libtrivfs')
-rw-r--r--libtrivfs/ChangeLog6
-rw-r--r--libtrivfs/dir-lookup.c37
2 files changed, 41 insertions, 2 deletions
diff --git a/libtrivfs/ChangeLog b/libtrivfs/ChangeLog
index 2fcb7a08..b110a213 100644
--- a/libtrivfs/ChangeLog
+++ b/libtrivfs/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jul 14 16:47:28 1998 Thomas Bushnell, n/BSG <tb@mit.edu>
+
+ * dir-lookup.c (trivfs_S_dir_lookup): In null-pathname case, this
+ should work even for non-directories, so actually do it, making
+ this a simpler case of trivfs_S_fsys_getroot.
+
Thu Feb 20 13:13:13 1997 Miles Bader <miles@gnu.ai.mit.edu>
* protid-classes.c (trivfs_protid_portclasses,
diff --git a/libtrivfs/dir-lookup.c b/libtrivfs/dir-lookup.c
index cdcfd4be..ff836363 100644
--- a/libtrivfs/dir-lookup.c
+++ b/libtrivfs/dir-lookup.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994 Free Software Foundation
+ Copyright (C) 1994, 1998 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -32,8 +32,41 @@ trivfs_S_dir_lookup (struct trivfs_protid *cred,
mach_port_t *retrypt,
mach_msg_type_name_t *retrypt_type)
{
+ int perms;
+ error_t err;
+ struct trivfs_protid *newcred;
+
if (!cred)
return EOPNOTSUPP;
- return ENOTDIR;
+ if (filename[0])
+ return ENOTDIR;
+
+ /* This is a null-pathname "reopen" call; do the right thing. */
+
+ /* Burn off flags we don't actually implement */
+ flags &= O_HURD;
+ flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS);
+
+ /* Validate permissions */
+ file_check_access (cred->realnode, &perms);
+ if ((flags & (O_READ|O_WRITE|O_EXEC) & perms)
+ != (flags & (O_READ|O_WRITE|O_EXEC)))
+ return EACCES;
+
+ /* Execute the open */
+ if (trivfs_check_open_hook)
+ err = (*trivfs_check_open_hook) (cred->po->cntl, user, flags);
+ if (!err)
+ err = trivfs_open (cred->po->cntl, cred->user, flags,
+ cred->realnode, &newcred);
+ if (err)
+ return err;
+
+ *retry_type = FS_RETRY_NORMAL;
+ *retry_name = '\0';
+ *retrypt = ports_get_right (newcred);
+ *retrypt_type = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newcred);
+ return 0;
}