我需要/
使用在 Linux 上运行的 C重新安装只读。到目前为止,我想出了以下代码:
mount("/dev/sda1", "/", "ext4", MS_REMOUNT | MS_RDONLY, NULL);
但我想知道是否有一种方法可以在不指定源设备 (/dev/sda1) 或文件系统类型 (ext4) 的情况下做到这一点,例如命令mount -o remount,ro /
. 系统调用的那些部分可以简单地替换为NULL
?
名称
getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r - 获取文件系统描述符文件条目
概要
#include <stdio.h> #include <mntent.h> FILE *setmntent(const char *filename, const char *type); struct mntent *getmntent(FILE *stream); int addmntent(FILE *stream, const struct mntent *mnt); int endmntent(FILE *streamp); char *hasmntopt(const struct mntent *mnt, const char *opt); /* GNU extension */ #include <mntent.h> struct mntent *getmntent_r(FILE *streamp, struct mntent *mntbuf, char *buf, int buflen);
找到挂载在 的文件系统/
,并从struct mntent
返回的设备中获取它的设备。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句