我有一个软件,它将以编程方式卸载一个分区(如果它不是很忙的话),并在所有工作完成后再挂载它。
如果我在终点站运行这个:
sudo mount /dev/sdb1 /mnt/fat32 -o sync,dirsync,rw,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro -t vfat我在/proc/self/mountinfo上看到了这个:
100 24 8:17 / /mnt/fat32 rw,relatime shared:61 - vfat /dev/sdb1 rw,sync,dirsync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro因此,我创建了一个挂载信息解析器,并获得恢复挂载的数据,但是我有转换挂载选项(rw,relatime)和超级选项( /mountinfo:rw,sync,dirsync,.中的最后一部分)。使用mountoptions和data:
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);我的方法是将挂载选项转换为适当的mountflags,并直接将特殊选项提供给data,但随后我得到了以下错误:
[62857.390803] FAT-fs (sdb1): Unrecognized mount option "rw" or missing value因此,我创建了一个函数来复制超级选项中的属性,而不是只匹配特定于文件系统的数据,现在它可以工作了。但是我仍然有一个问题:例如,如果sync和dirsync不在挂载选项标志中,如果它们不是针对特定于vfat的属性,那么如何设置它们?
如果它可以通过命令行挂载,它也可以在命令行版本中制作,对吗?
发布于 2016-05-18 09:34:35
提供给mount(8)的一些参数被转换为在mountflags参数中指定的标志为mount(2):
sync为MS_SYNCHRONOUS;dirsync为MS_DIRSYNC;relatime为MS_RELATIME;rw是默认的,因此不能指定它;ro是MS_RDONLY。https://unix.stackexchange.com/questions/283876
复制相似问题