Пример #1
0
int
afs_module_handler(module_t mod, int what, void *arg)
{
    static int inited = 0;
    int error = 0;

    switch (what) {
    case MOD_LOAD:
	if (inited) {
	    printf("afs cannot be MOD_LOAD'd more than once\n");
	    error = EBUSY;
	    break;
	}
	memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
#ifdef AFS_FBSD53_ENV
	afs_vfsconf.vfc_version = VFS_VERSION;
#endif
	strcpy(afs_vfsconf.vfc_name, "AFS");
	afs_vfsconf.vfc_vfsops = &afs_vfsops;
	afs_vfsconf.vfc_typenum = -1;	/* set by vfs_register */
	afs_vfsconf.vfc_flags = VFCF_NETWORK;
	if ((error = vfs_register(&afs_vfsconf)) != 0)
	    break;
	vfs_add_vnodeops(&afs_vnodeop_opv_desc);
	inited = 1;
	break;
    case MOD_UNLOAD:
#ifndef RXK_LISTENER_ENV
	/* shutdown is incomplete unless RXK_LISTENER_ENV */
	printf("afs: I can't be unloaded yet\n");
	return -1;
#endif
	if (!inited) {
	    error = 0;
	    break;
	}
	if ((error = vfs_unregister(&afs_vfsconf)) != 0) {
	    break;
	}
	vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
	break;
    }

    return (error);
}
Пример #2
0
/*
 * Standard kernel module handling code for filesystem modules.
 * Referenced from VFS_SET().
 */
int
vfs_modevent(module_t mod, int type, void *data)
{
	struct vfsconf *vfc;
	int error = 0;

	vfc = (struct vfsconf *)data;

	switch (type) {
	case MOD_LOAD:
		if (vfc)
			error = vfs_register(vfc);
		break;

	case MOD_UNLOAD:
		if (vfc)
			error = vfs_unregister(vfc);
		break;
	default:
		error = EOPNOTSUPP;
		break;
	}
	return (error);
}