I have a software that will unmount a partition programatically (if it's not busy) and mount it again after all of the work is done.If I run this in the terminal: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 vfatI get this in /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-roSo I made a mountinfo parser andto get the data to restore the mount, but I'm having with converting mount options (rw,relatime) and super options (the last part in /mountinfo: rw,sync,dirsync,...) with mountoptions and data:int mount(const char *source, const char *target,          const char *filesystemtype, unsigned long mountflags,          const void *data);My approach was to convert the mount options into the appropriate mountflags and to give special options straight to data, but then I get this error:[62857.390803] FAT-fs (sdb1): Unrecognized mount option rw or missing valueSo I made a function to copy the attributes in the super options thet just matches the filesystem specific data, and now it works. But I still have a problem: how can I set, for instance, sync and dirsync if they are not in the mount options flags and if they aren't for vfat specific attributes?If it can be made through the command line mount it can also be made in the command line version, right?
Mount(8) with mount(2)
filesystems;mount
Some of the parameters given to mount(8) are translated to flags specified in the mountflags parameter to mount(2):sync is MS_SYNCHRONOUS;dirsync is MS_DIRSYNC;relatime is MS_RELATIME;rw is the default, so it can't be specified; ro would be MS_RDONLY.