diff options
author | Matthew Macy <[email protected]> | 2020-02-28 14:50:32 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-28 14:50:32 -0800 |
commit | ae9f92f6f31c81f4d1aa4602f812f912b4392e7c (patch) | |
tree | 1d9c28079e96eb6746a53140d7c2c02e5f945b8c /module/zfs/zfs_ioctl.c | |
parent | 9cdf7b1f6b00cdd0a31d07e3fbc679d0e9eff247 (diff) |
Re-share zfsdev_getminor and zfs_onexit_fd_hold
By adding a zfs_file_private accessor to the common
interfaces and some extensions to FreeBSD platform
code it is now possible to share the implementations
for the aforementioned functions.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #10073
Diffstat (limited to 'module/zfs/zfs_ioctl.c')
-rw-r--r-- | module/zfs/zfs_ioctl.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 6f5faf357..d57aef509 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -7154,6 +7154,41 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type, return (error); } +int +zfsdev_getminor(int fd, minor_t *minorp) +{ + zfsdev_state_t *zs, *fpd; + zfs_file_t *fp; + int rc; + + ASSERT(!MUTEX_HELD(&zfsdev_state_lock)); + + if ((rc = zfs_file_get(fd, &fp))) + return (rc); + + fpd = zfs_file_private(fp); + if (fpd == NULL) + return (SET_ERROR(EBADF)); + + mutex_enter(&zfsdev_state_lock); + + for (zs = zfsdev_state_list; zs != NULL; zs = zs->zs_next) { + + if (zs->zs_minor == -1) + continue; + + if (fpd == zs) { + *minorp = fpd->zs_minor; + mutex_exit(&zfsdev_state_lock); + return (0); + } + } + + mutex_exit(&zfsdev_state_lock); + + return (SET_ERROR(EBADF)); +} + static void * zfsdev_get_state_impl(minor_t minor, enum zfsdev_state_type which) { |