簡體   English   中英

如何將選項傳遞到掛載系統調用?

[英]How to pass options into the mount system call?

我想在Linux的C程序中掛載100 MB的tmpfs。 如何將傳遞掛載的選項(即-o size = 100M,mode = 0755)傳遞到掛載 syscall?

它是C的安裝接口:

#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其他文件系統特定的選項mountflags與逗號相同的字符串形式出現在mount(8)中

因此,在您的情況下,只需將這些選項作為字符串傳遞即可:

const char *data = "size=100M,mode=0755";
...
mount(source, target, filesystemtype, mountflags, data);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM