Esempio n. 1
0
/*
 * Called once to initialize data structures...
 */
static int
nfssvc_modevent(module_t mod, int type, void *data)
{
	static int registered;
	int error = 0;

	switch (type) {
	case MOD_LOAD:
		error = syscall_register(&nfssvc_offset, &nfssvc_sysent,
		    &nfssvc_prev_sysent, SY_THR_STATIC_KLD);
		if (error)
			break;
		registered = 1;
		break;

	case MOD_UNLOAD:
		if (nfsd_call_nfsserver != NULL || nfsd_call_nfscommon != NULL
		    || nfsd_call_nfscl != NULL || nfsd_call_nfsd != NULL) {
			error = EBUSY;
			break;
		}
		if (registered)
			syscall_deregister(&nfssvc_offset, &nfssvc_prev_sysent);
		registered = 0;
		break;
	default:
		error = EOPNOTSUPP;
		break;
	}
	return error;
}
Esempio n. 2
0
int
syscall_helper_unregister(struct syscall_helper_data *sd)
{
	struct syscall_helper_data *sd1;

	for (sd1 = sd; sd1->registered != 0; sd1++) {
		syscall_deregister(&sd1->syscall_no, &sd1->old_sysent);
		sd1->registered = 0;
	}
	return (0);
}
Esempio n. 3
0
int
syscall_module_handler(struct module *mod, int what, void *arg)
{
	struct syscall_module_data *data = arg;
	modspecific_t ms;
	int error;

	switch (what) {
	case MOD_LOAD:
		error = syscall_register(data->offset, data->new_sysent,
		    &data->old_sysent, data->flags);
		if (error) {
			/* Leave a mark so we know to safely unload below. */
			data->offset = NULL;
			return (error);
		}
		ms.intval = *data->offset;
		MOD_XLOCK;
		module_setspecific(mod, &ms);
		MOD_XUNLOCK;
		if (data->chainevh)
			error = data->chainevh(mod, what, data->chainarg);
		return (error);
	case MOD_UNLOAD:
		/*
		 * MOD_LOAD failed, so just return without calling the
		 * chained handler since we didn't pass along the MOD_LOAD
		 * event.
		 */
		if (data->offset == NULL)
			return (0);
		if (data->chainevh) {
			error = data->chainevh(mod, what, data->chainarg);
			if (error)
				return error;
		}
		error = syscall_deregister(data->offset, &data->old_sysent);
		return (error);
	default:
		if (data->chainevh)
			return (data->chainevh(mod, what, data->chainarg));
		return (EOPNOTSUPP);
	}

	/* NOTREACHED */
}
Esempio n. 4
0
int
afs_uninit(struct vfsconf *vfc)
{
#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
    int offset = AFS_SYSCALL;
#endif

    if (afs_globalVFS)
	return EBUSY;
#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
    syscall_deregister(&offset, &old_sysent);
#else
    sysent[AFS_SYSCALL].sy_narg = 0;
    sysent[AFS_SYSCALL].sy_call = old_handler;
#endif
    return 0;
}