Make zfsdev_getminor signature cross platform

Only pass the file descriptor to make zfsdev_get_miror() portable.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9466
This commit is contained in:
Matthew Macy 2019-10-16 18:43:52 -07:00 committed by Brian Behlendorf
parent 0e939e434a
commit 08f530c699
4 changed files with 10 additions and 16 deletions

View File

@ -546,7 +546,7 @@ typedef struct zfsdev_state {
} zfsdev_state_t; } zfsdev_state_t;
extern void *zfsdev_get_state(minor_t minor, enum zfsdev_state_type which); extern void *zfsdev_get_state(minor_t minor, enum zfsdev_state_type which);
extern int zfsdev_getminor(struct file *filp, minor_t *minorp); extern int zfsdev_getminor(int fd, minor_t *minorp);
extern minor_t zfsdev_minor_alloc(void); extern minor_t zfsdev_minor_alloc(void);
extern uint_t zfs_fsyncer_key; extern uint_t zfs_fsyncer_key;

View File

@ -175,14 +175,18 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
} }
int int
zfsdev_getminor(struct file *filp, minor_t *minorp) zfsdev_getminor(int fd, minor_t *minorp)
{ {
zfsdev_state_t *zs, *fpd; zfsdev_state_t *zs, *fpd;
file_t *fp;
ASSERT(filp != NULL);
ASSERT(!MUTEX_HELD(&zfsdev_state_lock)); ASSERT(!MUTEX_HELD(&zfsdev_state_lock));
fp = getf(fd);
fpd = filp->private_data; if (fp == NULL)
return (SET_ERROR(EBADF));
fpd = fp->f_file->private_data;
if (fpd == NULL) if (fpd == NULL)
return (SET_ERROR(EBADF)); return (SET_ERROR(EBADF));

View File

@ -40,15 +40,10 @@
int int
zfs_onexit_fd_hold(int fd, minor_t *minorp) zfs_onexit_fd_hold(int fd, minor_t *minorp)
{ {
file_t *fp;
zfs_onexit_t *zo = NULL; zfs_onexit_t *zo = NULL;
int error; int error;
fp = getf(fd); error = zfsdev_getminor(fd, minorp);
if (fp == NULL)
return (SET_ERROR(EBADF));
error = zfsdev_getminor(fp->f_file, minorp);
if (error) { if (error) {
zfs_onexit_fd_rele(fd); zfs_onexit_fd_rele(fd);
return (error); return (error);

View File

@ -582,14 +582,9 @@ zfs_zevent_minor_to_state(minor_t minor, zfs_zevent_t **ze)
int int
zfs_zevent_fd_hold(int fd, minor_t *minorp, zfs_zevent_t **ze) zfs_zevent_fd_hold(int fd, minor_t *minorp, zfs_zevent_t **ze)
{ {
file_t *fp;
int error; int error;
fp = getf(fd); error = zfsdev_getminor(fd, minorp);
if (fp == NULL)
return (SET_ERROR(EBADF));
error = zfsdev_getminor(fp->f_file, minorp);
if (error == 0) if (error == 0)
error = zfs_zevent_minor_to_state(*minorp, ze); error = zfs_zevent_minor_to_state(*minorp, ze);