summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-01-29 14:06:15 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-25 11:19:00 +0100
commit86e3141aaf13b1bc55d74bd6f557a62b814e944c (patch)
tree5478d2359f55b2aae2461695ea4b7bdeb50afdaf /libdiskfs
parent982261fec4707d0c8d0723d90d9c0e465d98aa93 (diff)
libdiskfs: fix receiver lookups in fsys server functions
* libdiskfs/diskfs.h (struct diskfs_control): New declaration. (diskfs_begin_using_control_port): New declaration and function. (diskfs_end_using_control_port): Likewise. * libdiskfs/fsmutations.h: Add translation functions. * libdiskfs/priv.h (control_t): New type declaration for mig. * libdiskfs/boot-start.c: Fix receiver lookups. * libdiskfs/fsys-getfile.c: Likewise. * libdiskfs/fsys-getroot.c: Likewise. * libdiskfs/fsys-goaway.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/fsys-syncfs.c: Likewise.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/boot-start.c18
-rw-r--r--libdiskfs/diskfs.h22
-rw-r--r--libdiskfs/fsmutations.h3
-rw-r--r--libdiskfs/fsys-getfile.c12
-rw-r--r--libdiskfs/fsys-getroot.c9
-rw-r--r--libdiskfs/fsys-goaway.c8
-rw-r--r--libdiskfs/fsys-options.c16
-rw-r--r--libdiskfs/fsys-syncfs.c10
-rw-r--r--libdiskfs/priv.h1
9 files changed, 51 insertions, 48 deletions
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 05d3b436..7b8a84f5 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -426,17 +426,16 @@ diskfs_execboot_fsys_startup (mach_port_t port, int flags,
/* Called by init to get the privileged ports as described
in <hurd/fsys.defs>. */
kern_return_t
-diskfs_S_fsys_getpriv (mach_port_t port,
+diskfs_S_fsys_getpriv (struct diskfs_control *init_bootstrap_port,
mach_port_t reply, mach_msg_type_name_t reply_type,
mach_port_t *host_priv, mach_msg_type_name_t *hp_type,
mach_port_t *dev_master, mach_msg_type_name_t *dm_type,
mach_port_t *fstask, mach_msg_type_name_t *task_type)
{
error_t err;
- struct port_info *init_bootstrap_port =
- ports_lookup_port (diskfs_port_bucket, port, diskfs_initboot_class);
- if (!init_bootstrap_port)
+ if (!init_bootstrap_port
+ || init_bootstrap_port->pi.class != diskfs_initboot_class)
return EOPNOTSUPP;
err = get_privileged_ports (host_priv, dev_master);
@@ -447,20 +446,17 @@ diskfs_S_fsys_getpriv (mach_port_t port,
*task_type = MACH_MSG_TYPE_COPY_SEND;
}
- ports_port_deref (init_bootstrap_port);
-
return err;
}
/* Called by init to give us ports to the procserver and authserver as
described in <hurd/fsys.defs>. */
kern_return_t
-diskfs_S_fsys_init (mach_port_t port,
+diskfs_S_fsys_init (struct diskfs_control *pt,
mach_port_t reply, mach_msg_type_name_t replytype,
mach_port_t procserver,
mach_port_t authhandle)
{
- struct port_info *pt;
static int initdone = 0;
mach_port_t host, startup;
error_t err;
@@ -468,10 +464,10 @@ diskfs_S_fsys_init (mach_port_t port,
struct protid *rootpi;
struct peropen *rootpo;
- pt = ports_lookup_port (diskfs_port_bucket, port, diskfs_initboot_class);
- if (!pt)
+ if (!pt
+ || pt->pi.class != diskfs_initboot_class)
return EOPNOTSUPP;
- ports_port_deref (pt);
+
if (initdone)
return EOPNOTSUPP;
initdone = 1;
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index db6a1d84..359b11b8 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -121,6 +121,11 @@ struct node
int author_tracks_uid;
};
+struct diskfs_control
+{
+ struct port_info pi;
+};
+
/* Possibly lookup types for diskfs_lookup call */
enum lookup_type
{
@@ -795,8 +800,10 @@ error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
void diskfs_finish_protid (struct protid *cred, struct iouser *user);
extern struct protid * diskfs_begin_using_protid_port (file_t port);
+extern struct diskfs_control * diskfs_begin_using_control_port (fsys_t port);
extern void diskfs_end_using_protid_port (struct protid *cred);
+extern void diskfs_end_using_control_port (struct diskfs_control *cred);
#if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE)
@@ -809,6 +816,13 @@ diskfs_begin_using_protid_port (file_t port)
return ports_lookup_port (diskfs_port_bucket, port, diskfs_protid_class);
}
+/* And for the fsys interface. */
+DISKFS_EXTERN_INLINE struct diskfs_control *
+diskfs_begin_using_control_port (fsys_t port)
+{
+ return ports_lookup_port (diskfs_port_bucket, port, NULL);
+}
+
/* Called by MiG after server routines have been run; this
balances begin_using_protid_port, and is arranged for the io
and fs interfaces by fsmutations.h. */
@@ -819,6 +833,14 @@ diskfs_end_using_protid_port (struct protid *cred)
ports_port_deref (cred);
}
+/* And for the fsys interface. */
+DISKFS_EXTERN_INLINE void
+diskfs_end_using_control_port (struct diskfs_control *cred)
+{
+ if (cred)
+ ports_port_deref (cred);
+}
+
#endif /* Use extern inlines. */
/* Called when a protid CRED has no more references. (Because references\
diff --git a/libdiskfs/fsmutations.h b/libdiskfs/fsmutations.h
index 5026810c..68b6ae3c 100644
--- a/libdiskfs/fsmutations.h
+++ b/libdiskfs/fsmutations.h
@@ -23,6 +23,9 @@
#define IO_INTRAN protid_t diskfs_begin_using_protid_port (io_t)
#define IO_DESTRUCTOR diskfs_end_using_protid_port (protid_t)
+#define FSYS_INTRAN control_t diskfs_begin_using_control_port (fsys_t)
+#define FSYS_DESTRUCTOR diskfs_end_using_control_port (control_t)
+
#define FILE_IMPORTS import "priv.h";
#define IO_IMPORTS import "priv.h";
#define FSYS_IMPORTS import "priv.h";
diff --git a/libdiskfs/fsys-getfile.c b/libdiskfs/fsys-getfile.c
index 2fe9495e..9dd5d732 100644
--- a/libdiskfs/fsys-getfile.c
+++ b/libdiskfs/fsys-getfile.c
@@ -27,7 +27,7 @@
/* Return in FILE & FILE_TYPE the file in FSYS corresponding to the NFS file
handle HANDLE & HANDLE_LEN. */
error_t
-diskfs_S_fsys_getfile (mach_port_t fsys,
+diskfs_S_fsys_getfile (struct diskfs_control *pt,
mach_port_t reply, mach_msg_type_name_t reply_type,
uid_t *uids, mach_msg_type_number_t nuids,
gid_t *gids, mach_msg_type_number_t ngids,
@@ -41,15 +41,13 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
struct protid *new_cred;
struct peropen *new_po;
struct iouser *user;
- struct port_info *pt =
- ports_lookup_port (diskfs_port_bucket, fsys, diskfs_control_class);
- if (!pt)
+ if (!pt
+ || pt->pi.class != diskfs_control_class)
return EOPNOTSUPP;
if (handle_len != sizeof *f)
{
- ports_port_deref (pt);
return EINVAL;
}
@@ -58,14 +56,12 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
err = diskfs_cached_lookup (f->data.cache_id, &node);
if (err)
{
- ports_port_deref (pt);
return err;
}
if (node->dn_stat.st_gen != f->data.gen)
{
diskfs_nput (node);
- ports_port_deref (pt);
return ESTALE;
}
@@ -73,7 +69,6 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
if (err)
{
diskfs_nput (node);
- ports_port_deref (pt);
return err;
}
@@ -98,7 +93,6 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
iohelp_free_iouser (user);
diskfs_nput (node);
- ports_port_deref (pt);
if (! err)
{
diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c
index 85e11671..52122146 100644
--- a/libdiskfs/fsys-getroot.c
+++ b/libdiskfs/fsys-getroot.c
@@ -26,7 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Implement fsys_getroot as described in <hurd/fsys.defs>. */
kern_return_t
-diskfs_S_fsys_getroot (fsys_t controlport,
+diskfs_S_fsys_getroot (struct diskfs_control *pt,
mach_port_t reply,
mach_msg_type_name_t replytype,
mach_port_t dotdot,
@@ -40,8 +40,6 @@ diskfs_S_fsys_getroot (fsys_t controlport,
file_t *returned_port,
mach_msg_type_name_t *returned_port_poly)
{
- struct port_info *pt = ports_lookup_port (diskfs_port_bucket, controlport,
- diskfs_control_class);
error_t err = 0;
mode_t type;
struct protid *newpi;
@@ -55,7 +53,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
path: NULL,
};
- if (!pt)
+ if (!pt
+ || pt->pi.class != diskfs_control_class)
return EOPNOTSUPP;
flags &= O_HURD;
@@ -200,8 +199,6 @@ diskfs_S_fsys_getroot (fsys_t controlport,
pthread_mutex_unlock (&diskfs_root_node->lock);
pthread_rwlock_unlock (&diskfs_fsys_lock);
- ports_port_deref (pt);
-
drop_idvec ();
return err;
diff --git a/libdiskfs/fsys-goaway.c b/libdiskfs/fsys-goaway.c
index 2aabce84..b9103873 100644
--- a/libdiskfs/fsys-goaway.c
+++ b/libdiskfs/fsys-goaway.c
@@ -25,16 +25,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Implement fsys_goaway as described in <hurd/fsys.defs>. */
error_t
-diskfs_S_fsys_goaway (fsys_t controlport,
+diskfs_S_fsys_goaway (struct diskfs_control *pt,
mach_port_t reply,
mach_msg_type_name_t reply_type,
int flags)
{
- struct port_info *pt = ports_lookup_port (diskfs_port_bucket, controlport,
- diskfs_control_class);
error_t ret;
- if (!pt)
+ if (!pt
+ || pt->pi.class != diskfs_control_class)
return EOPNOTSUPP;
/* XXX FSYS_GOAWAY_NOWAIT not implemented. */
@@ -48,6 +47,5 @@ diskfs_S_fsys_goaway (fsys_t controlport,
exit (0);
}
- ports_port_deref (pt);
return ret;
}
diff --git a/libdiskfs/fsys-options.c b/libdiskfs/fsys-options.c
index bb183198..b366d143 100644
--- a/libdiskfs/fsys-options.c
+++ b/libdiskfs/fsys-options.c
@@ -28,15 +28,13 @@
/* Implement fsys_set_options as described in <hurd/fsys.defs>. */
kern_return_t
-diskfs_S_fsys_set_options (fsys_t fsys,
+diskfs_S_fsys_set_options (struct diskfs_control *pt,
mach_port_t reply,
mach_msg_type_name_t replytype,
char *data, mach_msg_type_number_t len,
int do_children)
{
error_t err = 0;
- struct port_info *pt =
- ports_lookup_port (diskfs_port_bucket, fsys, diskfs_control_class);
error_t
helper (struct node *np)
@@ -60,7 +58,8 @@ diskfs_S_fsys_set_options (fsys_t fsys,
return error;
}
- if (!pt)
+ if (!pt
+ || pt->pi.class != diskfs_control_class)
return EOPNOTSUPP;
if (do_children)
@@ -77,13 +76,12 @@ diskfs_S_fsys_set_options (fsys_t fsys,
pthread_rwlock_unlock (&diskfs_fsys_lock);
}
- ports_port_deref (pt);
return err;
}
/* Implement fsys_get_options as described in <hurd/fsys.defs>. */
error_t
-diskfs_S_fsys_get_options (fsys_t fsys,
+diskfs_S_fsys_get_options (struct diskfs_control *port,
mach_port_t reply,
mach_msg_type_name_t replytype,
char **data, mach_msg_type_number_t *data_len)
@@ -91,10 +89,9 @@ diskfs_S_fsys_get_options (fsys_t fsys,
char *argz = 0;
size_t argz_len = 0;
error_t err;
- struct port_info *port =
- ports_lookup_port (diskfs_port_bucket, fsys, diskfs_control_class);
- if (!port)
+ if (!port
+ || port->pi.class != diskfs_control_class)
return EOPNOTSUPP;
err = argz_add (&argz, &argz_len, program_invocation_name);
@@ -111,6 +108,5 @@ diskfs_S_fsys_get_options (fsys_t fsys,
else
free (argz);
- ports_port_deref (port);
return err;
}
diff --git a/libdiskfs/fsys-syncfs.c b/libdiskfs/fsys-syncfs.c
index beb8881f..4dceed7f 100644
--- a/libdiskfs/fsys-syncfs.c
+++ b/libdiskfs/fsys-syncfs.c
@@ -24,14 +24,12 @@
/* Implement fsys_syncfs as described in <hurd/fsys.defs>. */
kern_return_t
-diskfs_S_fsys_syncfs (fsys_t controlport,
+diskfs_S_fsys_syncfs (struct diskfs_control *pi,
mach_port_t reply,
mach_msg_type_name_t replytype,
int wait,
int children)
{
- struct port_info *pi = ports_lookup_port (diskfs_port_bucket, controlport,
- diskfs_control_class);
error_t
helper (struct node *np)
{
@@ -49,7 +47,8 @@ diskfs_S_fsys_syncfs (fsys_t controlport,
return 0;
}
- if (!pi)
+ if (!pi
+ || pi->pi.class != diskfs_control_class)
return EOPNOTSUPP;
pthread_rwlock_rdlock (&diskfs_fsys_lock);
@@ -67,8 +66,5 @@ diskfs_S_fsys_syncfs (fsys_t controlport,
}
pthread_rwlock_unlock (&diskfs_fsys_lock);
-
- ports_port_deref (pi);
-
return 0;
}
diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h
index bd23ab90..b41fa43e 100644
--- a/libdiskfs/priv.h
+++ b/libdiskfs/priv.h
@@ -73,6 +73,7 @@ extern int _diskfs_diskdirty;
/* Needed for MiG. */
typedef struct protid *protid_t;
+typedef struct diskfs_control *control_t;
/* Actually read or write a file. The file size must already permit
the requested access. NP is the file to read/write. DATA is a buffer