diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-06-15 18:25:59 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-06-15 18:25:59 +0200 |
commit | aac4aaf42372f61c78061711916c81a9d5bcb42d (patch) | |
tree | 167fb3e426cc7757a43da2c7d04fc2baa293c5de /procfs/procfs_dir.h | |
parent | 65ebcc40e55dfb3ee776383891f8a6b15b176d27 (diff) | |
download | hurd-aac4aaf42372f61c78061711916c81a9d5bcb42d.tar.gz hurd-aac4aaf42372f61c78061711916c81a9d5bcb42d.tar.bz2 hurd-aac4aaf42372f61c78061711916c81a9d5bcb42d.zip |
Prepare the procfs translator to be merged into the Hurd sources
Move the procfs translator to its own subdirectory 'procfs'.
This is the last commit to this repository. Development of the procfs
translator will continue in the main Hurd repository.
* procfs/Makefile: Replace the standalone Makefile with the one from
the Debian packaging repository.
Diffstat (limited to 'procfs/procfs_dir.h')
-rw-r--r-- | procfs/procfs_dir.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/procfs/procfs_dir.h b/procfs/procfs_dir.h new file mode 100644 index 00000000..94c5b019 --- /dev/null +++ b/procfs/procfs_dir.h @@ -0,0 +1,63 @@ +/* Hurd /proc filesystem, infrastructure for directories. + Copyright (C) 2010 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This module provides an abstraction layer for implementing simple + directories with (mostly) static contents. The user defines the + contents of the directory by providing a table of entries and various + optional callback functions. */ + +/* These operations define how a given entry will behave. Either can be + omitted, both from the entry-specific operations and from the + directory-wide defaults. */ +struct procfs_dir_entry_ops +{ + /* Called when this entry is looked up to create a corresponding node. */ + struct node *(*make_node)(void *dir_hook, const void *entry_hook); + /* If this is provided and returns 0, this entry will be hidden. */ + int (*exists)(void *dir_hook, const void *entry_hook); +}; + +/* Describes an individual directory entry, associating a NAME with + * arbitrary HOOK data and node-specific OPS. */ +struct procfs_dir_entry +{ + const char *name; + const void *hook; + struct procfs_dir_entry_ops ops; +}; + +/* Describes a complete directory. ENTRIES is a table terminated by a + null NAME field. ENTRY_OPS provides default operations for the + entries which don't specify them. The optional CLEANUP function + should release all the resources associated with the directory hook. */ +struct procfs_dir_ops +{ + const struct procfs_dir_entry *entries; + void (*cleanup)(void *dir_hook); + struct procfs_dir_entry_ops entry_ops; +}; + +/* Create and return a new node for the directory described in OPS. + The DIR_HOOK is passed the MAKE_NODE callback function of looked up + entries, as well as to the CLEANUP callback when the node is + destroyed. If not enough memory can be allocated, OPS->CLEANUP is + invoked immediately and NULL is returned. */ +struct node * +procfs_dir_make_node (const struct procfs_dir_ops *ops, void *dir_hook); + |