From: Helg Subject: fuse: remove ioctl from /dev/fuse0 To: tech@openbsd.org Date: Sun, 7 Sep 2025 18:45:35 +0200 Cleanup the kernel fuse device code to remove support for ioctl. This is no longer needed since an fbuf is now read or written in one go, rather than a combination of read(2) or write(2) and ioctl(2) to read or write the buffer used by the vfs syscalls read, write, readlink and readdir. OK? Index: sys/miscfs/fuse/fuse_device.c =================================================================== RCS file: /cvs/src/sys/miscfs/fuse/fuse_device.c,v diff -u -p -r1.43 fuse_device.c --- sys/miscfs/fuse/fuse_device.c 6 Sep 2025 06:15:52 -0000 1.43 +++ sys/miscfs/fuse/fuse_device.c 7 Sep 2025 16:16:53 -0000 @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,6 @@ struct fuse_d *fuse_lookup(int); void fuseattach(int); int fuseopen(dev_t, int, int, struct proc *); int fuseclose(dev_t, int, int, struct proc *); -int fuseioctl(dev_t, u_long, caddr_t, int, struct proc *); int fuseread(dev_t, struct uio *, int); int fusewrite(dev_t, struct uio *, int); int fusekqfilter(dev_t dev, struct knote *kn); @@ -272,130 +270,6 @@ end: free(fd, M_DEVBUF, sizeof(*fd)); stat_opened_fusedev--; return (0); -} - -/* - * FIOCGETFBDAT Get fusebuf data from kernel to user - * FIOCSETFBDAT Set fusebuf data from user to kernel - */ -int -fuseioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) -{ - struct fb_ioctl_xch *ioexch; - struct fusebuf *lastfbuf; - struct fusebuf *fbuf; - struct fuse_d *fd; - int error = 0; - - fd = fuse_lookup(minor(dev)); - if (fd == NULL) - return (ENXIO); - - switch (cmd) { - case FIOCGETFBDAT: - ioexch = (struct fb_ioctl_xch *)addr; - - /* Looking for uuid in fd_fbufs_in */ - rw_enter_write(&fd->fd_lock); - SIMPLEQ_FOREACH(fbuf, &fd->fd_fbufs_in, fb_next) { - if (fbuf->fb_uuid == ioexch->fbxch_uuid) - break; - - lastfbuf = fbuf; - } - if (fbuf == NULL) { - rw_exit_write(&fd->fd_lock); - printf("fuse: Cannot find fusebuf\n"); - return (EINVAL); - } - - /* Remove the fbuf from fd_fbufs_in */ - if (fbuf == SIMPLEQ_FIRST(&fd->fd_fbufs_in)) - SIMPLEQ_REMOVE_HEAD(&fd->fd_fbufs_in, fb_next); - else - SIMPLEQ_REMOVE_AFTER(&fd->fd_fbufs_in, lastfbuf, - fb_next); - rw_exit_write(&fd->fd_lock); - - stat_fbufs_in--; - - /* Do not handle fbufs with bad len */ - if (fbuf->fb_len != ioexch->fbxch_len) { - printf("fuse: Bad fusebuf len\n"); - return (EINVAL); - } - - /* Update the userland fbuf */ - error = copyout(fbuf->fb_dat, ioexch->fbxch_data, - ioexch->fbxch_len); - if (error) { - printf("fuse: cannot copyout\n"); - return (error); - } - -#ifdef FUSE_DEBUG - fuse_dump_buff(fbuf->fb_dat, fbuf->fb_len); -#endif - - /* Adding fbuf in fd_fbufs_wait */ - free(fbuf->fb_dat, M_FUSEFS, fbuf->fb_len); - fbuf->fb_dat = NULL; - SIMPLEQ_INSERT_TAIL(&fd->fd_fbufs_wait, fbuf, fb_next); - stat_fbufs_wait++; - break; - - case FIOCSETFBDAT: - DPRINTF("SET BUFFER\n"); - ioexch = (struct fb_ioctl_xch *)addr; - - /* looking for uuid in fd_fbufs_wait */ - SIMPLEQ_FOREACH(fbuf, &fd->fd_fbufs_wait, fb_next) { - if (fbuf->fb_uuid == ioexch->fbxch_uuid) - break; - - lastfbuf = fbuf; - } - if (fbuf == NULL) { - printf("fuse: Cannot find fusebuf\n"); - return (EINVAL); - } - - /* Do not handle fbufs with bad len */ - if (fbuf->fb_len != ioexch->fbxch_len) { - printf("fuse: Bad fusebuf size\n"); - return (EINVAL); - } - - /* fetching data from userland */ - fbuf->fb_dat = malloc(ioexch->fbxch_len, M_FUSEFS, - M_WAITOK | M_ZERO); - error = copyin(ioexch->fbxch_data, fbuf->fb_dat, - ioexch->fbxch_len); - if (error) { - printf("fuse: Cannot copyin\n"); - free(fbuf->fb_dat, M_FUSEFS, fbuf->fb_len); - fbuf->fb_dat = NULL; - return (error); - } - -#ifdef FUSE_DEBUG - fuse_dump_buff(fbuf->fb_dat, fbuf->fb_len); -#endif - - /* Remove fbuf from fd_fbufs_wait */ - if (fbuf == SIMPLEQ_FIRST(&fd->fd_fbufs_wait)) - SIMPLEQ_REMOVE_HEAD(&fd->fd_fbufs_wait, fb_next); - else - SIMPLEQ_REMOVE_AFTER(&fd->fd_fbufs_wait, lastfbuf, - fb_next); - stat_fbufs_wait--; - wakeup(fbuf); - break; - default: - error = EINVAL; - } - - return (error); } int Index: sys/miscfs/fuse/fusefs.h =================================================================== RCS file: /cvs/src/sys/miscfs/fuse/fusefs.h,v diff -u -p -r1.14 fusefs.h --- sys/miscfs/fuse/fusefs.h 20 Jan 2020 23:21:56 -0000 1.14 +++ sys/miscfs/fuse/fusefs.h 7 Sep 2025 16:16:53 -0000 @@ -33,16 +33,6 @@ { "fusefs_pool_pages", CTLTYPE_INT }, \ } -struct fb_ioctl_xch { - uint64_t fbxch_uuid; - size_t fbxch_len; - uint8_t *fbxch_data; -}; - -/* FUSE Device ioctls */ -#define FIOCGETFBDAT _IOW('F', 0, struct fb_ioctl_xch) -#define FIOCSETFBDAT _IOW('F', 1, struct fb_ioctl_xch) - #ifdef _KERNEL struct fuse_msg; Index: sys/sys/conf.h =================================================================== RCS file: /cvs/src/sys/sys/conf.h,v diff -u -p -r1.167 conf.h --- sys/sys/conf.h 25 Jun 2025 20:29:29 -0000 1.167 +++ sys/sys/conf.h 7 Sep 2025 16:16:53 -0000 @@ -453,7 +453,7 @@ extern struct cdevsw cdevsw[]; /* open, close, read, write, ioctl */ #define cdev_fuse_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \ - dev_init(c,n,write), dev_init(c,n,ioctl), \ + dev_init(c,n,write), (dev_type_ioctl((*))) enodev, \ (dev_type_stop((*))) enodev, 0, \ (dev_type_mmap((*))) enodev, 0, D_CLONE, dev_init(c,n,kqfilter) }