diff options
author | Roland McGrath <roland@gnu.org> | 2001-07-03 01:10:27 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-07-03 01:10:27 +0000 |
commit | abd1e84b6b14f34beae53005fcead93b1d755ff5 (patch) | |
tree | bf183d6169378a2f8914b0e9e77f5bfbbf1d07fc | |
parent | cfdf7c3ded1e3165ae643a740a4a0425cecdadcb (diff) |
2001-06-21 Neal H Walfield <neal@cs.uml.edu>
* file-getcontrol.c (diskfs_S_file_getcontrol): When checking
if we can give the control port out, use fshelp_iscontroller
rather than doing the check by hand.
-rw-r--r-- | libdiskfs/file-getcontrol.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/libdiskfs/file-getcontrol.c b/libdiskfs/file-getcontrol.c index 4f1ae23a..23afb7cb 100644 --- a/libdiskfs/file-getcontrol.c +++ b/libdiskfs/file-getcontrol.c @@ -1,5 +1,5 @@ /* libdiskfs implementation of fs.defs:file_getcontrol.c - Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1992,93,94,95,96,2001 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 @@ -17,6 +17,7 @@ #include "priv.h" #include "fs_S.h" +#include <hurd/fshelp.h> /* Implement file_getcontrol as described in <hurd/fs.defs>. */ kern_return_t @@ -24,28 +25,27 @@ diskfs_S_file_getcontrol (struct protid *cred, mach_port_t *control, mach_msg_type_name_t *controltype) { - int error = 0; + int error; struct port_info *newpi; if (!cred) return EOPNOTSUPP; - if (!idvec_contains (cred->user->uids, 0)) - error = EPERM; - else - { - error = ports_create_port (diskfs_control_class, diskfs_port_bucket, - sizeof (struct port_info), &newpi); - if (! error) - { - spin_lock (&_diskfs_control_lock); - _diskfs_ncontrol_ports++; - spin_unlock (&_diskfs_control_lock); - *control = ports_get_right (newpi); - *controltype = MACH_MSG_TYPE_MAKE_SEND; - ports_port_deref (newpi); - } - } - - return error; + error = fshelp_iscontroller (&diskfs_root_node->dn_stat, cred->user); + if (error) + return error; + + error = ports_create_port (diskfs_control_class, diskfs_port_bucket, + sizeof (struct port_info), &newpi); + if (error) + return error; + + spin_lock (&_diskfs_control_lock); + _diskfs_ncontrol_ports++; + spin_unlock (&_diskfs_control_lock); + *control = ports_get_right (newpi); + *controltype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (newpi); + + return 0; } |