Search code examples
clinuxpermissionsiommuvfio

Cannot open /dev/vfio/noiommu-0: Operation not permitted


I am trying to open file /dev/vfio/noiommu-0 with read and write access (O_RDWR), but the error occurs.

char* filename = "/dev/vfio/noiommu-0";
int fd = open(filename, O_RDWR);
if (fd < 0)
    printf("Cannot open %s: %s\n", filename, strerror(errno));

The output is Cannot open /dev/vfio/noiommu-0: Operation not permitted

I've changed the permissions of the file to crw-rw-rw- and changed the owner of the file from root to myuser, but it didn't help. Also myuser has permissions to read upper folders.

Could you please explain why I cannot read and write to this file, and how can I overcome these issues?


Solution

  • Setting CAP_SYS_RAWIO capabilities solved the issue (source).