Linux 挂载使用重新挂载以允许读写

Linux Mount using Remount to allow read-write

本文关键字:许读写 读写 新挂载 Linux      更新时间:2023-10-16

我想使用 root 帐户重新挂载只读文件系统,使其变为读写状态。

检查 Linux 手册页面,我注意到没有像 MS_RDWRITE 这样的标志,所以我的问题是,有没有人知道网上的一个示例,该示例演示使用带有重新挂载标志的挂载,该标志设置了只读路径以允许读取和写入?

这将在运行嵌入式 Linux 的设备C++完成。

/* Here's the declared function for Mount a filesystem.  */
extern int mount (__const char *__special_file, __const char *__dir,
__const char *__fstype, unsigned long int __rwflag,
__const void *__data) __THROW;

我无法让本机 API 正常工作。 根据制造商的说法,他们建议在终端窗口中使用重新安装命令。这对我来说是正确的。

当使用 root 权限调用时,这会将整个根文件夹重新挂载为读写。

// Remount the root folder.         
char* cmd = "mount -nwo remount,rw /";
if (-1 == system(cmd))
{
// handle the error.
}