[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 71/87: procfs: reorganize rootdir.c
From: |
Samuel Thibault |
Subject: |
[hurd] 71/87: procfs: reorganize rootdir.c |
Date: |
Sun, 09 Nov 2014 11:05:05 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 02c47da17b716bfff20bfafe2d5958b2b720ff49
Author: Justus Winter <address@hidden>
Date: Fri Sep 19 10:10:24 2014 +0200
procfs: reorganize rootdir.c
* procfs/rootdir.c: Move the translator linkage code to the
appropriate location.
---
procfs/rootdir.c | 153 ++++++++++++++++++++++++++++---------------------------
1 file changed, 77 insertions(+), 76 deletions(-)
diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index a04fb3e..d68645e 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -409,83 +409,7 @@ rootdir_gc_fakeself (void *hook, char **contents, ssize_t
*contents_len)
}
static struct node *rootdir_mounts_node;
-
-/* Translator linkage. */
-static pthread_spinlock_t rootdir_translated_node_lock =
- PTHREAD_SPINLOCK_INITIALIZER;
-
-struct procfs_translated_node_ops
-{
- struct procfs_node_ops node_ops;
-
- struct node **npp;
- char *argz;
- size_t argz_len;
-};
-
-static struct node *
-rootdir_make_translated_node (void *dir_hook, const void *entry_hook)
-{
- const struct procfs_translated_node_ops *ops = entry_hook;
- struct node *np, *prev;
- pthread_spin_lock (&rootdir_translated_node_lock);
- np = *ops->npp;
- pthread_spin_unlock (&rootdir_translated_node_lock);
-
- if (np != NULL)
- {
- netfs_nref (np);
- return np;
- }
-
- np = procfs_make_node (entry_hook, entry_hook);
- if (np == NULL)
- return NULL;
-
- procfs_node_chtype (np, S_IFREG | S_IPTRANS);
- procfs_node_chmod (np, 0444);
-
- pthread_spin_lock (&rootdir_translated_node_lock);
- prev = *ops->npp;
- if (*ops->npp == NULL)
- *ops->npp = np;
- pthread_spin_unlock (&rootdir_translated_node_lock);
-
- if (prev != NULL)
- {
- procfs_cleanup (np);
- np = prev;
- }
-
- return np;
-}
-
-static error_t
-rootdir_translated_node_get_translator (void *hook, char **argz,
- size_t *argz_len)
-{
- const struct procfs_translated_node_ops *ops = hook;
-
- *argz = malloc (ops->argz_len);
- if (! *argz)
- return ENOMEM;
-
- memcpy (*argz, ops->argz, ops->argz_len);
- *argz_len = ops->argz_len;
- return 0;
-}
-
-#define ROOTDIR_DEFINE_TRANSLATED_NODE(NPP, ARGZ) \
- &(struct procfs_translated_node_ops) { \
- .node_ops = { \
- .get_translator = rootdir_translated_node_get_translator, \
- }, \
- .npp = NPP, \
- .argz = (ARGZ), \
- .argz_len = sizeof (ARGZ), \
- }
-
static error_t
rootdir_gc_slabinfo (void *hook, char **contents, ssize_t *contents_len)
{
@@ -619,7 +543,84 @@ rootdir_symlink_make_node (void *dir_hook, const void
*entry_hook)
procfs_node_chtype (np, S_IFLNK);
return np;
}
+
+/* Translator linkage. */
+
+static pthread_spinlock_t rootdir_translated_node_lock =
+ PTHREAD_SPINLOCK_INITIALIZER;
+
+struct procfs_translated_node_ops
+{
+ struct procfs_node_ops node_ops;
+
+ struct node **npp;
+ char *argz;
+ size_t argz_len;
+};
+
+static struct node *
+rootdir_make_translated_node (void *dir_hook, const void *entry_hook)
+{
+ const struct procfs_translated_node_ops *ops = entry_hook;
+ struct node *np, *prev;
+
+ pthread_spin_lock (&rootdir_translated_node_lock);
+ np = *ops->npp;
+ pthread_spin_unlock (&rootdir_translated_node_lock);
+
+ if (np != NULL)
+ {
+ netfs_nref (np);
+ return np;
+ }
+
+ np = procfs_make_node (entry_hook, entry_hook);
+ if (np == NULL)
+ return NULL;
+
+ procfs_node_chtype (np, S_IFREG | S_IPTRANS);
+ procfs_node_chmod (np, 0444);
+
+ pthread_spin_lock (&rootdir_translated_node_lock);
+ prev = *ops->npp;
+ if (*ops->npp == NULL)
+ *ops->npp = np;
+ pthread_spin_unlock (&rootdir_translated_node_lock);
+
+ if (prev != NULL)
+ {
+ procfs_cleanup (np);
+ np = prev;
+ }
+
+ return np;
+}
+
+static error_t
+rootdir_translated_node_get_translator (void *hook, char **argz,
+ size_t *argz_len)
+{
+ const struct procfs_translated_node_ops *ops = hook;
+ *argz = malloc (ops->argz_len);
+ if (! *argz)
+ return ENOMEM;
+
+ memcpy (*argz, ops->argz, ops->argz_len);
+ *argz_len = ops->argz_len;
+ return 0;
+}
+
+#define ROOTDIR_DEFINE_TRANSLATED_NODE(NPP, ARGZ) \
+ &(struct procfs_translated_node_ops) { \
+ .node_ops = { \
+ .get_translator = rootdir_translated_node_get_translator, \
+ }, \
+ .npp = NPP, \
+ .argz = (ARGZ), \
+ .argz_len = sizeof (ARGZ), \
+ }
+
static const struct procfs_dir_entry rootdir_entries[] = {
{
.name = "self",
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 56/87: hurd: fix semantic of file_get_children, (continued)
- [hurd] 56/87: hurd: fix semantic of file_get_children, Samuel Thibault, 2014/11/09
- [hurd] 47/87: Make the ncursesw driver of the console client compile properly, Samuel Thibault, 2014/11/09
- [hurd] 65/87: exec: add proper argument parsing, add --device-master-port, Samuel Thibault, 2014/11/09
- [hurd] 18/87: hurd: fix type of optimal_transfer_size, Samuel Thibault, 2014/11/09
- [hurd] 50/87: sutils: add urandom device target to MAKEDEV, Samuel Thibault, 2014/11/09
- [hurd] 45/87: Revert "libpipe: fix calls to pipe_send with no data", Samuel Thibault, 2014/11/09
- [hurd] 57/87: include: detect use-after-free errors using the reference counts, Samuel Thibault, 2014/11/09
- [hurd] 73/87: libdiskfs: remove code counting cache misses, Samuel Thibault, 2014/11/09
- [hurd] 82/87: Fix dead name notification in static binaries, Samuel Thibault, 2014/11/09
- [hurd] 68/87: procfs: implement /proc/filesystems, Samuel Thibault, 2014/11/09
- [hurd] 71/87: procfs: reorganize rootdir.c,
Samuel Thibault <=
- [hurd] 78/87: Fix proc_getprocinfo calls, Samuel Thibault, 2014/11/09
- [hurd] 80/87: Fix actual procinfo_t type, Samuel Thibault, 2014/11/09
- [hurd] 83/87: Use a mere weak attribute instead of a weak alias, Samuel Thibault, 2014/11/09
- [hurd] 17/87: include: use unsigned literal in combination with binary not, Samuel Thibault, 2014/11/09
- [hurd] 79/87: Fix proc_getprocinfo calls, Samuel Thibault, 2014/11/09
- [hurd] 20/87: libdiskfs: avoid implicit integer conversion, Samuel Thibault, 2014/11/09
- [hurd] 67/87: procfs: implement /proc/N/maps, Samuel Thibault, 2014/11/09
- [hurd] 69/87: procfs: do not test whether /hurd/mtab exists, Samuel Thibault, 2014/11/09
- [hurd] 16/87: libnetfs: fix memory leak, Samuel Thibault, 2014/11/09
- [hurd] 13/87: Fix buffer allocation on io_read, Samuel Thibault, 2014/11/09