#define NULL_NHASH(vp) (&null_node_hashtbl[((((uintptr_t)vp) >> vnsz2log) + (uintptr_t)vnode_mount(vp)) & null_hash_mask])
static LIST_HEAD(null_node_hashhead, null_node) * null_node_hashtbl;
-static lck_mtx_t null_hashmtx;
-static lck_attr_t * null_hashlck_attr;
-static lck_grp_t * null_hashlck_grp;
-static lck_grp_attr_t * null_hashlck_grp_attr;
+static LCK_GRP_DECLARE(null_hashlck_grp, "com.apple.filesystems.nullfs");
+static LCK_MTX_DECLARE(null_hashmtx, &null_hashlck_grp);
static u_long null_hash_mask;
/* os x doesn't have hashes built into vnode. gonna try doing what freebsd does
static int null_hashins(struct mount *, struct null_node *, struct vnode **);
-int
+void
nullfs_init_lck(lck_mtx_t * lck)
{
- int error = 1;
- if (lck && null_hashlck_grp && null_hashlck_attr) {
- lck_mtx_init(lck, null_hashlck_grp, null_hashlck_attr);
- error = 0;
- }
- return error;
+ lck_mtx_init(lck, &null_hashlck_grp, LCK_ATTR_NULL);
}
-int
+void
nullfs_destroy_lck(lck_mtx_t * lck)
{
- int error = 1;
- if (lck && null_hashlck_grp) {
- lck_mtx_destroy(lck, null_hashlck_grp);
- error = 0;
- }
- return error;
+ lck_mtx_destroy(lck, &null_hashlck_grp);
}
/*
nullfs_init(__unused struct vfsconf * vfsp)
{
NULLFSDEBUG("%s\n", __FUNCTION__);
-
- /* assuming for now that this happens immediately and by default after fs
- * installation */
- null_hashlck_grp_attr = lck_grp_attr_alloc_init();
- if (null_hashlck_grp_attr == NULL) {
- goto error;
- }
- null_hashlck_grp = lck_grp_alloc_init("com.apple.filesystems.nullfs", null_hashlck_grp_attr);
- if (null_hashlck_grp == NULL) {
- goto error;
- }
- null_hashlck_attr = lck_attr_alloc_init();
- if (null_hashlck_attr == NULL) {
- goto error;
- }
-
- lck_mtx_init(&null_hashmtx, null_hashlck_grp, null_hashlck_attr);
null_node_hashtbl = hashinit(NULL_HASH_SIZE, M_TEMP, &null_hash_mask);
NULLFSDEBUG("%s finished\n", __FUNCTION__);
return 0;
-error:
- printf("NULLFS: failed to get lock element\n");
- if (null_hashlck_grp_attr) {
- lck_grp_attr_free(null_hashlck_grp_attr);
- null_hashlck_grp_attr = NULL;
- }
- if (null_hashlck_grp) {
- lck_grp_free(null_hashlck_grp);
- null_hashlck_grp = NULL;
- }
- if (null_hashlck_attr) {
- lck_attr_free(null_hashlck_attr);
- null_hashlck_attr = NULL;
- }
- return KERN_FAILURE;
}
int
-nullfs_uninit()
+nullfs_uninit(void)
{
/* This gets called when the fs is uninstalled, there wasn't an exact
* equivalent in vfsops */
- lck_mtx_destroy(&null_hashmtx, null_hashlck_grp);
hashdestroy(null_node_hashtbl, M_TEMP, null_hash_mask);
- if (null_hashlck_grp_attr) {
- lck_grp_attr_free(null_hashlck_grp_attr);
- null_hashlck_grp_attr = NULL;
- }
- if (null_hashlck_grp) {
- lck_grp_free(null_hashlck_grp);
- null_hashlck_grp = NULL;
- }
- if (null_hashlck_attr) {
- lck_attr_free(null_hashlck_attr);
- null_hashlck_attr = NULL;
- }
return 0;
}