1 /* VTreeFS - extra.c - per-inode storage of arbitrary extra data */
6 * Right now, we maintain the extra data (if requested) as a separate buffer,
7 * so that we don't have to make the inode structure variable in size. Later,
8 * if for example the maximum node name length becomes a runtime setting, we
9 * could reconsider this.
11 static char *extra_ptr
= NULL
;
12 static size_t extra_size
= 0; /* per inode */
15 * Initialize memory to store extra data.
18 init_extra(unsigned int nr_inodes
, size_t inode_extra
)
24 if ((extra_ptr
= calloc(nr_inodes
, inode_extra
)) == NULL
)
27 extra_size
= inode_extra
;
33 * Initialize the extra data for the given inode to zero.
36 clear_inode_extra(struct inode
* node
)
42 memset(&extra_ptr
[node
->i_num
* extra_size
], 0, extra_size
);
46 * Retrieve a pointer to the extra data for the given inode.
49 get_inode_extra(const struct inode
* node
)
55 return (void *)&extra_ptr
[node
->i_num
* extra_size
];