bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] libdiskfs: fix receiver lookup


From: Justus Winter
Subject: [PATCH 3/3] libdiskfs: fix receiver lookup
Date: Sat, 5 Apr 2014 00:07:16 +0200

* libdiskfs/Makefile (exec_startup-MIGSFLAGS): New variable.
* libdiskfs/diskfs.h (struct bootinfo): New struct declaration.
(diskfs_begin_using_bootinfo_port): New function.
(diskfs_end_using_bootinfo): Likewise.
* libdiskfs/fsmutations.h: Add mutators for exec_startup_t.
* libdiskfs/priv.h (bootinfo_t): New type declaration to appease mig.
* libdiskfs/boot-start.c (S_exec_startup_get_info): Fix receiver lookup.
---
 libdiskfs/Makefile      |  1 +
 libdiskfs/boot-start.c  |  9 +++------
 libdiskfs/diskfs.h      | 23 +++++++++++++++++++++++
 libdiskfs/fsmutations.h |  7 +++++++
 libdiskfs/priv.h        |  1 +
 5 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/libdiskfs/Makefile b/libdiskfs/Makefile
index aeebe4e..996e86a 100644
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -68,6 +68,7 @@ fsys-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h 
-DREPLY_PORTS
 fs-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 io-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 ifsock-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
+exec_startup-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 MIGCOMSFLAGS = -prefix diskfs_
 
 include ../Makeconf
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 7b8a84f..9dd2751 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -299,7 +299,7 @@ diskfs_start_bootstrap ()
    call (as does any task) to get its state.  We can't give it all of
    its ports (we'll provide those with a later call to exec_init).  */
 kern_return_t
-diskfs_S_exec_startup_get_info (mach_port_t port,
+diskfs_S_exec_startup_get_info (struct bootinfo *upt,
                                vm_address_t *user_entry,
                                vm_address_t *phdr_data,
                                vm_size_t *phdr_size,
@@ -322,12 +322,10 @@ diskfs_S_exec_startup_get_info (mach_port_t port,
   error_t err;
   mach_port_t *portarray, *dtable;
   mach_port_t rootport;
-  struct ufsport *upt;
   struct protid *rootpi;
   struct peropen *rootpo;
 
-  if (!(upt = ports_lookup_port (diskfs_port_bucket, port,
-                                diskfs_execboot_class)))
+  if (! upt)
     return EOPNOTSUPP;
 
   *user_entry = 0;
@@ -368,13 +366,12 @@ diskfs_S_exec_startup_get_info (mach_port_t port,
   portarray[INIT_PORT_AUTH] = MACH_PORT_NULL;
   portarray[INIT_PORT_PROC] = MACH_PORT_NULL;
   portarray[INIT_PORT_CTTYID] = MACH_PORT_NULL;
-  portarray[INIT_PORT_BOOTSTRAP] = port; /* use the same port */
+  portarray[INIT_PORT_BOOTSTRAP] = upt->pi.port_right; /* use the same port */
 
   *portarraypoly = MACH_MSG_TYPE_MAKE_SEND;
 
   *dtablepoly = MACH_MSG_TYPE_COPY_SEND;
 
-  ports_port_deref (upt);
   return 0;
 }
 
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 359b11b..8151ddc 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -126,6 +126,11 @@ struct diskfs_control
   struct port_info pi;
 };
 
+struct bootinfo
+{
+  struct port_info pi;
+};
+
 /* Possibly lookup types for diskfs_lookup call */
 enum lookup_type
 {
@@ -801,9 +806,11 @@ 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 struct bootinfo *diskfs_begin_using_bootinfo_port (exec_startup_t port);
 
 extern void diskfs_end_using_protid_port (struct protid *cred);
 extern void diskfs_end_using_control_port (struct diskfs_control *cred);
+extern void diskfs_end_using_bootinfo (struct bootinfo *upt);
 
 #if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE)
 
@@ -823,6 +830,14 @@ diskfs_begin_using_control_port (fsys_t port)
   return ports_lookup_port (diskfs_port_bucket, port, NULL);
 }
 
+/* And for the exec_startup interface. */
+DISKFS_EXTERN_INLINE struct bootinfo *
+diskfs_begin_using_bootinfo_port (exec_startup_t port)
+{
+  return ports_lookup_port (diskfs_port_bucket, port, diskfs_execboot_class);
+}
+
+
 /* 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. */
@@ -841,6 +856,14 @@ diskfs_end_using_control_port (struct diskfs_control *cred)
     ports_port_deref (cred);
 }
 
+/* And for the exec_startup interface. */
+DISKFS_EXTERN_INLINE void
+diskfs_end_using_bootinfo (struct bootinfo *b)
+{
+  if (b)
+    ports_port_deref (b);
+}
+
 #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 68b6ae3..6248708 100644
--- a/libdiskfs/fsmutations.h
+++ b/libdiskfs/fsmutations.h
@@ -30,3 +30,10 @@
 #define IO_IMPORTS import "priv.h";
 #define FSYS_IMPORTS import "priv.h";
 #define IFSOCK_IMPORTS import "priv.h";
+
+#define EXEC_STARTUP_INTRAN                             \
+  bootinfo_t diskfs_begin_using_bootinfo_port (exec_startup_t)
+#define EXEC_STARTUP_DESTRUCTOR                         \
+  diskfs_end_using_bootinfo (bootinfo_t)
+#define EXEC_STARTUP_IMPORTS                            \
+  import "priv.h";
diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h
index b41fa43..4363a00 100644
--- a/libdiskfs/priv.h
+++ b/libdiskfs/priv.h
@@ -74,6 +74,7 @@ extern int _diskfs_diskdirty;
 /* Needed for MiG. */
 typedef struct protid *protid_t;
 typedef struct diskfs_control *control_t;
+typedef struct bootinfo *bootinfo_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.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]