Пример #1
0
/*
 * Consumers might need to operate by minor number instead of fd, since
 * they might be running in another thread (e.g. txg_sync_thread). Callers
 * of this function must call zfs_onexit_fd_rele() when they're finished
 * using the minor number.
 */
int
zfs_onexit_fd_hold(int fd, minor_t *minorp)
{
	file_t *fp = NULL;
	zfs_onexit_t *zo;
    uint32_t vipd;
    vattr_t va;

    fp = getf(fd);
    if (fp == NULL)
        return EBADF;

#ifdef __APPLE__
    *minorp = zfsdev_getminor(current_proc());
#else
    *minorp = zfsdev_getminor(fp->f_file);
#endif
    return (zfs_onexit_minor_to_state(*minorp, &zo));
}
Пример #2
0
/*
 * Consumers might need to operate by minor number instead of fd, since
 * they might be running in another thread (e.g. txg_sync_thread). Callers
 * of this function must call zfs_onexit_fd_rele() when they're finished
 * using the minor number.
 */
int
zfs_onexit_fd_hold(int fd, minor_t *minorp)
{
	file_t *fp, *tmpfp;
	zfs_onexit_t *zo;
	void *data;
	int error;

	fp = getf(fd, CAP_NONE);
	if (fp == NULL)
		return (SET_ERROR(EBADF));

	tmpfp = curthread->td_fpop;
	curthread->td_fpop = fp;
	error = devfs_get_cdevpriv(&data);
	if (error == 0)
		*minorp = (minor_t)(uintptr_t)data;
	curthread->td_fpop = tmpfp;
	if (error != 0)
		return (error);
	return (zfs_onexit_minor_to_state(*minorp, &zo));
}
Пример #3
0
/*
 * Return the data associated with this callback.  This allows consumers
 * of the cleanup-on-exit interfaces to stash kernel data across system
 * calls, knowing that it will be cleaned up if the calling process exits.
 */
int
zfs_onexit_cb_data(minor_t minor, uint64_t action_handle, void **data)
{
	zfs_onexit_t *zo;
	zfs_onexit_action_node_t *ap;
	int error;

	*data = NULL;

	error = zfs_onexit_minor_to_state(minor, &zo);
	if (error)
		return (error);

	mutex_enter(&zo->zo_lock);
	ap = zfs_onexit_find_cb(zo, action_handle);
	if (ap != NULL)
		*data = ap->za_data;
	else
		error = ENOENT;
	mutex_exit(&zo->zo_lock);

	return (error);
}