summaryrefslogtreecommitdiff
path: root/libdiskfs/init-init.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-16 23:06:33 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-28 14:47:44 +0200
commit80485401a9a5e9df03bd3a1503bc5e59d1f2e5c1 (patch)
tree7188cacc3f1f0eced3f309fb7c98c9ce55ae9841 /libdiskfs/init-init.c
parent1d1da90042d2ee7a8215dc6291b54bc1ebe59fe4 (diff)
libdiskfs: add diskfs_make_node_alloc to allocate fat nodes
libdiskfs has two kind of nodes, struct node and struct netnode. struct node is used to store libdiskfs specific data, while struct netnode contains user supplied data. Previously, both objects were allocated separatly, and a pointer from the node to the netnode provided a mapping from the former to the latter. Provide a function diskfs_make_node_alloc that allocates both nodes in a contiguous region. This reduces the memory allocation overhead when creating nodes. It also makes the relation between node and netnode a simple offset calculation. Provide two functions to compute the netnode address from the node address and vice-versa. Most notably, this makes implementing a cache on top of libdiskfs easier. Auxiliary data for the cache can be stored in the user-defined netnode, and the fat node can be used as the value. * libdiskfs/node-make.c (init_node): Move initialization here. (diskfs_make_node): Use init_node. (diskfs_make_node_alloc): New function to allocate fat nodes. * libdiskfs/diskfs.h (diskfs_make_node_alloc): New declaration. (_diskfs_sizeof_struct_node): Likewise. (diskfs_node_disknode): Compute disknode address from node address. (diskfs_disknode_node): And vice-versa. * libdiskfs/init-init.c (_diskfs_sizeof_struct_node): New variable.
Diffstat (limited to 'libdiskfs/init-init.c')
-rw-r--r--libdiskfs/init-init.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libdiskfs/init-init.c b/libdiskfs/init-init.c
index 35be7edd..7a7f2485 100644
--- a/libdiskfs/init-init.c
+++ b/libdiskfs/init-init.c
@@ -25,6 +25,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <maptime.h>
+/* For safe inlining of diskfs_node_disknode and
+ diskfs_disknode_node. */
+size_t const _diskfs_sizeof_struct_node = sizeof (struct node);
+
mach_port_t diskfs_default_pager;
mach_port_t diskfs_auth_server_port;
volatile struct mapped_time_value *diskfs_mtime;