[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/3] libdiskfs: fix receiver lookups in fsys server functions
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 3/3] libdiskfs: fix receiver lookups in fsys server functions |
Date: |
Tue, 25 Feb 2014 00:31:06 -0500 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Wed 12 Feb 2014 18:22:26 +0100, a écrit :
> * 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.
Ack.
> ---
> libdiskfs/boot-start.c | 18 +++++++-----------
> libdiskfs/diskfs.h | 22 ++++++++++++++++++++++
> libdiskfs/fsmutations.h | 3 +++
> libdiskfs/fsys-getfile.c | 12 +++---------
> libdiskfs/fsys-getroot.c | 9 +++------
> libdiskfs/fsys-goaway.c | 8 +++-----
> libdiskfs/fsys-options.c | 16 ++++++----------
> libdiskfs/fsys-syncfs.c | 10 +++-------
> libdiskfs/priv.h | 1 +
> 9 files changed, 51 insertions(+), 48 deletions(-)
>
> diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
> index 05d3b43..7b8a84f 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 db6a1d8..359b11b 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 5026810..68b6ae3 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 2fe9495..9dd5d73 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 85e1167..5212214 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 2aabce8..b910387 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 bb18319..b366d14 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 beb8881..4dceed7 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 bd23ab9..b41fa43 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
> --
> 1.8.5.2
>
--
Samuel
gawk; talk; nice; date; wine; grep; touch; unzip; strip; \
touch; gasp; finger; gasp; lyx; gasp; latex; mount; fsck; \
more; yes; gasp; umount; make clean; make mrproper; sleep
- [PATCH 4/6] tmpfs: set diskfs_disk_name to "none", (continued)
- [PATCH 4/6] tmpfs: set diskfs_disk_name to "none", Justus Winter, 2014/02/11
- [PATCH 5/6] trans/mtab: do not map unknown source strings to "none", Justus Winter, 2014/02/11
- [PATCH 6/6] New RPCs, fix build, Justus Winter, 2014/02/11
- [PATCH 1/6] hurd: fix the get-children and get-source procedures, Justus Winter, 2014/02/11
- [PATCH 1/3] libdiskfs: fix typo, Justus Winter, 2014/02/12
- Re: [PATCH 1/3] libdiskfs: fix typo, Samuel Thibault, 2014/02/12