[rtems-libbsd commit] Add RTEMS-specific getcredhostuuid()

Sebastian Huber sebh at rtems.org
Wed Jun 5 12:26:50 UTC 2019


Module:    rtems-libbsd
Branch:    master
Commit:    3bd43f00a7fdb244333c51ef835cd1fd60b79c8e
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=3bd43f00a7fdb244333c51ef835cd1fd60b79c8e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jun  5 13:29:20 2019 +0200

Add RTEMS-specific getcredhostuuid()

---

 .../include/machine/rtems-bsd-kernel-namespace.h   |  1 +
 rtemsbsd/rtems/rtems-kernel-jail.c                 | 39 ++++++++++++++++------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index d7967c6..83c4366 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -1279,6 +1279,7 @@
 #define	GetAckModified _bsd_GetAckModified
 #define	GetAliasAddress _bsd_GetAliasAddress
 #define	GetAliasPort _bsd_GetAliasPort
+#define	getcredhostuuid _bsd_getcredhostuuid
 #define	GetDefaultAliasAddress _bsd_GetDefaultAliasAddress
 #define	GetDeltaAckIn _bsd_GetDeltaAckIn
 #define	GetDeltaSeqOut _bsd_GetDeltaSeqOut
diff --git a/rtemsbsd/rtems/rtems-kernel-jail.c b/rtemsbsd/rtems/rtems-kernel-jail.c
index 59068ed..e53e4cc 100644
--- a/rtemsbsd/rtems/rtems-kernel-jail.c
+++ b/rtemsbsd/rtems/rtems-kernel-jail.c
@@ -3,14 +3,14 @@
  *
  * @ingroup rtems_bsd_rtems
  *
- * @brief This object is an minimal rtems implementation of kern_jail.c.
+ * @brief This object is an minimal RTEMS implementation of kern_jail.c.
  */
 
 /*
- * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2009, 2019 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
- *  Obere Lagerstr. 30
+ *  Dornierstr. 4.
  *  82178 Puchheim
  *  Germany
  *  <rtems at embedded-brains.de>
@@ -39,13 +39,6 @@
 
 #include <machine/rtems-bsd-kernel-space.h>
 
-/*#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/jail.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>*/
-
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/kernel.h>
@@ -70,6 +63,8 @@
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 
+#include <rtems/score/threadqimpl.h>
+
 #define DEFAULT_HOSTUUID  "00000000-0000-0000-0000-000000000000"
 
 /* Keep struct prison prison0 and some code in kern_jail_set() readable. */
@@ -96,6 +91,19 @@ struct prison prison0 = {
   .pr_path  = "/",
   .pr_securelevel = -1,
   .pr_childmax  = JAIL_MAX,
+
+  /*
+   * Statically initialize this mutex to allow a garbage collection of this
+   * structure.
+   */
+  .pr_mtx = {
+    .lock_object = { .lo_flags = LO_INITIALIZED },
+    .mutex = {
+      .queue = THREAD_QUEUE_INITIALIZER("jail mutex"),
+      .nest_level = 0
+    }
+  },
+
   .pr_hostuuid  = DEFAULT_HOSTUUID,
   .pr_children  = LIST_HEAD_INITIALIZER(prison0.pr_children),
 #ifdef VIMAGE
@@ -105,4 +113,13 @@ struct prison prison0 = {
 #endif
   .pr_allow = PR_ALLOW_ALL_STATIC
 };
-MTX_SYSINIT(prison0, &prison0.pr_mtx, "jail mutex", MTX_DEF);
+
+void
+getcredhostuuid(struct ucred *cred, char *buf, size_t size)
+{
+
+	(void)cred;
+	mtx_lock(&prison0.pr_mtx);
+	strlcpy(buf, prison0.pr_hostuuid, size);
+	mtx_unlock(&prison0.pr_mtx);
+}



More information about the vc mailing list