在 RHEL6 上,我试图以非超级用户 (abc_admin) 身份挂载文件系统。我想我已经正确设置了所有权限,但我仍然收到权限错误。
这是我的块设备上的权限:
brw-rw----. 1 abc_admin abc_admin 8, 5 Oct 10 09:25 /dev/sda5
以下是挂载目录的权限:
drwxr-xr-x. 2 abc_admin abc_admin 4096 Oct 8 12:49 mount
这是我的代码:
int main() {
int stat = mount("/dev/sda5", "/mount", "ext4", 0, "");
if (0 != stat) {
perror("mount failed");
exit(5);
}
return 0;
}
这里是 strace:
mount("/dev/sda5", "/mount", "ext4", 0, "") = -1 EPERM (Operation not permitted)
dup(2) = 3
fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
brk(0) = 0x1416000
brk(0x1437000) = 0x1437000
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f479bf3e000
lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "mount failed: Operation not perm"..., 38mount failed: Operation not permitted
) = 38
close(3)