我正在尝试在我的程序中使用mount()
而不是mount
命令,我成功地使用了以下mount()
,结果返回了“success”,而不是“Invalid Argument”。
int rc = mount("172.16.74.20:/data/redun/snmp","/mnt/data/redun/snmp",
"nfs",0,"soft,timeo=2,addr=172.16.74.20");
if (rc != 0)
{
printf("mount failed, errCode=%d, reason=%s\n",errno, strerror(errno));
}
当我使用df -h
命令检查挂载点时,没有任何信息显示。我发现相关设备尚未挂载。出了什么问题?它真的成功挂载了吗?如何通过df
命令在Linux中显示已挂载设备?
df
命令不是读取mount()
系统调用更新的/etc/mtab
文件,而是直接读取/proc/mounts
文件。请检查你的/proc/mounts
文件。 - gavv/etc/mtab
,而不是挂载命名空间。我已经发布了一个更详细的答案。 - gavv