I read that we need superuser permission to access I/O ports from user space. But i am saying different behavior. ioperm is successful under normal user.
#include <stdio.h>
#include <errno.h>
#include <sys/io.h>
int main(int argc, char *argv[])
{
if (!ioperm(0x70, 3, 1)) {
perror("ioperm failed");
}
else {
printf("ioperm on 0x70 success\n");
}
return 0;
}
$ ./prog
ioperm on 0x70 success
Is this the expected behavior
From the manual:
You have this backwards. -1 means failure, but your code incorrectly assumes it means success.