aboutsummaryrefslogtreecommitdiff
path: root/libnetfs/fsys-getroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnetfs/fsys-getroot.c')
-rw-r--r--libnetfs/fsys-getroot.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/libnetfs/fsys-getroot.c b/libnetfs/fsys-getroot.c
index f7f40385..d3e78332 100644
--- a/libnetfs/fsys-getroot.c
+++ b/libnetfs/fsys-getroot.c
@@ -1,5 +1,5 @@
-/*
- Copyright (C) 1996 Free Software Foundation, Inc.
+/*
+ Copyright (C) 1996,97,2001,02 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -26,6 +26,8 @@
error_t
netfs_S_fsys_getroot (mach_port_t cntl,
+ mach_port_t reply,
+ mach_msg_type_name_t reply_type,
mach_port_t dotdot,
uid_t *uids, mach_msg_type_number_t nuids,
uid_t *gids, mach_msg_type_number_t ngids,
@@ -33,43 +35,46 @@ netfs_S_fsys_getroot (mach_port_t cntl,
retry_type *do_retry,
char *retry_name,
mach_port_t *retry_port,
- mach_port_t *retry_port_type)
+ mach_msg_type_name_t *retry_port_type)
{
struct port_info *pt = ports_lookup_port (netfs_port_bucket, cntl,
netfs_control_class);
- struct netcred *cred;
+ struct iouser *cred;
error_t err;
struct protid *newpi;
mode_t type;
+ struct peropen peropen_context = { root_parent: dotdot };
if (!pt)
return EOPNOTSUPP;
ports_port_deref (pt);
- cred = netfs_make_credential (uids, nuids, gids, ngids);
-
+ err = iohelp_create_complex_iouser (&cred, uids, nuids, gids, ngids);
+ if (err)
+ return err;
+
flags &= O_HURD;
-
+
mutex_lock (&netfs_root_node->lock);
err = netfs_validate_stat (netfs_root_node, cred);
if (err)
goto out;
-
+
type = netfs_root_node->nn_stat.st_mode & S_IFMT;
- if ((netfs_root_node->istranslated
+ if (((netfs_root_node->nn_stat.st_mode & S_IPTRANS)
|| fshelp_translated (&netfs_root_node->transbox))
&& !(flags & O_NOTRANS))
{
err = fshelp_fetch_root (&netfs_root_node->transbox,
- &dotdot, dotdot, uids, nuids,
- gids, ngids, flags,
+ &peropen_context, dotdot, cred, flags,
_netfs_translator_callback1,
_netfs_translator_callback2,
do_retry, retry_name, retry_port);
if (err != ENOENT)
{
mutex_unlock (&netfs_root_node->lock);
+ iohelp_free_iouser (cred);
if (!err)
*retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
return err;
@@ -77,17 +82,19 @@ netfs_S_fsys_getroot (mach_port_t cntl,
/* ENOENT means translator has vanished inside fshelp_fetch_root. */
err = 0;
}
-
+
if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS)))
{
char pathbuf[netfs_root_node->nn_stat.st_size + 1];
-
+
err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf);
- mutex_unlock (&netfs_root_node->lock);
if (err)
goto out;
-
+
+ mutex_unlock (&netfs_root_node->lock);
+ iohelp_free_iouser (cred);
+
if (pathbuf[0] == '/')
{
*do_retry = FS_RETRY_MAGICAL;
@@ -106,34 +113,34 @@ netfs_S_fsys_getroot (mach_port_t cntl,
return 0;
}
}
-
- if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR
+
+ if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR
|| type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC)))
{
- mutex_unlock (&netfs_root_node->lock);
- return EOPNOTSUPP;
+ err = EOPNOTSUPP;
+ goto out;
}
-
+
err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0);
if (err)
goto out;
-
+
flags &= ~OPENONLY_STATE_MODES;
-
+
newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
- dotdot),
+ &peropen_context),
cred);
mach_port_deallocate (mach_task_self (), dotdot);
+
*do_retry = FS_RETRY_NORMAL;
*retry_port = ports_get_right (newpi);
*retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
retry_name[0] = '\0';
ports_port_deref (newpi);
-
+
out:
+ if (err)
+ iohelp_free_iouser (cred);
mutex_unlock (&netfs_root_node->lock);
return err;
}
-
-
-