commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 06/07: Serve mounts node with a passive translator record


From: Samuel Thibault
Subject: [hurd] 06/07: Serve mounts node with a passive translator record
Date: Mon, 16 Sep 2013 07:41:32 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch procfs-jkoenig
in repository hurd.

commit 969078c9755b7e28dcabe277629f757e20a19f1a
Author: Justus Winter <address@hidden>
Date:   Mon Jul 22 17:54:39 2013 +0200

    Serve mounts node with a passive translator record
    
    Make mounts a node with a passive translator record so that the mtab
    translator is started on access if it is available.
    
    * rootdir.c (MTAB_TRANSLATOR): New macro.
    (rootdir_mounts_get_translator): New function.
    (rootdir_mounts_exists): New function.
    (rootdir_translator_make_node): Likewise.
    (rootdir_entries): Add "mounts" node.
---
 rootdir.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/rootdir.c b/rootdir.c
index f234dd0..34bf91c 100644
--- a/rootdir.c
+++ b/rootdir.c
@@ -1,5 +1,5 @@
 /* Hurd /proc filesystem, permanent files of the root directory.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010,13 Free Software Foundation, Inc.
 
    This file is part of the GNU Hurd.
 
@@ -404,6 +404,31 @@ rootdir_gc_fakeself (void *hook, char **contents, ssize_t 
*contents_len)
   return 0;
 }
 
+/* The mtab translator to use by default for the "mounts" node.  */
+#define MTAB_TRANSLATOR        "/hurd/mtab"
+
+static error_t
+rootdir_mounts_get_translator (void *hook, char **argz, size_t *argz_len)
+{
+  static const char const mtab_argz[] = MTAB_TRANSLATOR "\0/";
+
+  *argz = malloc (sizeof mtab_argz);
+  if (! *argz)
+    return ENOMEM;
+
+  memcpy (*argz, mtab_argz, sizeof mtab_argz);
+  *argz_len = sizeof mtab_argz;
+  return 0;
+}
+
+static int
+rootdir_mounts_exists (void *dir_hook, const void *entry_hook)
+{
+  static int translator_exists = -1;
+  if (translator_exists == -1)
+    translator_exists = access (MTAB_TRANSLATOR, F_OK|X_OK) == 0;
+  return translator_exists;
+}
 
 /* Glue logic and entries table */
 
@@ -426,6 +451,18 @@ rootdir_symlink_make_node (void *dir_hook, const void 
*entry_hook)
   return np;
 }
 
+static struct node *
+rootdir_translator_make_node (void *dir_hook, const void *entry_hook)
+{
+  struct node *np = procfs_make_node (entry_hook, dir_hook);
+  if (np)
+    {
+      procfs_node_chtype (np, S_IFREG | S_IPTRANS);
+      procfs_node_chmod (np, 0444);
+    }
+  return np;
+}
+
 static const struct procfs_dir_entry rootdir_entries[] = {
   {
     .name = "self",
@@ -487,6 +524,16 @@ static const struct procfs_dir_entry rootdir_entries[] = {
       .cleanup_contents = procfs_cleanup_contents_with_free,
     },
   },
+  {
+    .name = "mounts",
+    .hook = & (struct procfs_node_ops) {
+      .get_translator = rootdir_mounts_get_translator,
+    },
+    .ops = {
+      .make_node = rootdir_translator_make_node,
+      .exists = rootdir_mounts_exists,
+    }
+  },
 #ifdef PROFILE
   /* In order to get a usable gmon.out file, we must apparently use exit(). */
   {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

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