Skip to content

Conversation

@msg555
Copy link

@msg555 msg555 commented Mar 18, 2021

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 added 2 commits March 17, 2021 16:42
Signed-off-by: Mark Gordon <msg555@gmail.com>
Signed-off-by: Mark Gordon <msg555@gmail.com>
@ruiwen-zhao
Copy link

ruiwen-zhao commented Dec 9, 2021

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
Copy link

/cc @tv42

@time-river
Copy link

time-river commented Jun 12, 2023

anyone focus on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants