shelly wrote:
> i would like to know how to include a ioctl in zfs_ioctl.c. 
> 
> So would be grateful if somebody explained how zfs ioctls work.

zfs ioctls are made to the device /dev/zfs. To add a new ioctl, you'd
have to do the following.

1. Add an entry say, ZFS_IOC_MYIOCTL, for the new ioctl to zfs_ioc_t.
See: usr/src/uts/common/sys/fs/zfs.h, enum zfs_ioc

2. You'll have to add an entry to the ioctl vector zfs_ioc_vec.
Something like:
{ zfs_ioc_myioctl, zfs_secpolicy_[read|write|none|...=],
[pool_name|dataset_name|no_name] },

Make sure the new additions to zfs_ioc and zfs_ioc_vec are at the same
offset.

3. Add your ioctl handling routine to
usr/src/uts/common/fs/zfs/zfs_ioctl.c
static int zfs_ioc_myioctl(zfs_cmd_t *zc)
{
        // your ioctl implementation
}

4. You might want to add a library routine to call the ioctl to
usr/src/lib/libzfs/common/libzfs_pool.c
int zpool_myioctl(libzfs_handle_t *hdl)
{
        zfs_cmd_t zc = { 0 };
        int error;
        error = ioctl(hdl->libzfs_fd, ZFS_IOC_MYIOCTL, &zc);
        return (error);
}

5. You could declare the new library routine in libzfs.h
usr/src/lib/libzfs/common/libzfs.h
extern int zpool_myioctl(libzfs_handle_t *);

At least, you should now know which files to look at.

Good luck and happy hacking!

Cheers
Manoj


Reply via email to