我想在 Linux 中的 C 程序中安装 100 MB tmpfs。 如何将挂载选项(即 -o size=100M,mode=0755)传递给 mount 系统调用?
C盘的挂载接口(interface):
#include <sys/mount.h>
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
最佳答案
阅读 mount(2)手册页,似乎文件系统独立选项在 mountflags
中作为不同标志的组合给出,而其他文件系统特定选项在 data
中作为逗号分隔的字符串,与它们完全一样用于 mount(8) .
因此在您的情况下,只需将这些选项作为字符串传递:
const char *data = "size=100M,mode=0755";
...
mount(source, target, filesystemtype, mountflags, data);
关于linux - 如何将选项传递给挂载系统调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38673786/