fuse icon indicating copy to clipboard operation
fuse copied to clipboard

Adds Ioctl support

Open msg555 opened this issue 3 years ago • 3 comments

Adds support for handling ioctl requests made to fuse. This implementation comes from looking at the fuse implementation to fill in the missing ioctl functionality. Note that fuse servers do not support "unrestricted" ioctls meaning that there is no utility in supporting the ioctl retry mechanism. That part of the protocol appears to be reserved for cuse based servers.

If it's useful to anyone I was using this C program to test out the functionality (although a similar automated test has been added with this PR)

#include <stdint.h>

#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <asm-generic/ioctl.h>

struct mydata {
  uint32_t a;
  uint32_t b;
  uint32_t c;
  uint32_t d;
};

int main(int argc, char** argv) {
  for (int i = 1; i < argc; i++) {
    int fd = open(argv[i], O_RDONLY);
    if (fd == -1) {
      perror("open failed");
      return 1;
    }

    struct mydata x = {
      1, 2, 3, 4
    };

    int cmd = _IOWR('h', 0, mydata);

    int res = ioctl(fd, cmd, &x);
    if (res == -1) {
      perror("ioctl failed");
      return 1;
    }
    printf("RESULT: %d\n", res);
    printf("x.a=%d\n", x.a);

    close(fd);
  }
  return 0;
}

msg555 avatar Mar 18 '21 01:03 msg555

This looks very needed especially considering the change in kernel 5.15, where overlayfs calls IOCTL on lowerdirs when writing on upperdirs, but currently brazil-fuse does not support IOCTL

Can we get more people to review this?

ruiwen-zhao avatar Dec 09 '21 07:12 ruiwen-zhao

/cc @tv42

ruiwen-zhao avatar Dec 09 '21 19:12 ruiwen-zhao

anyone focus on it?

time-river avatar Jun 12 '23 08:06 time-river