0

I want to mount 100 MB tmpfs within a C program in Linux. How can pass pass mount's options (i.e. -o size=100M,mode=0755) to the mount syscall?

It is the mount interface for C:

#include <sys/mount.h>

int mount(const char *source, const char *target,
            const char *filesystemtype, unsigned long mountflags,
            const void *data);
Jens Gustedt
  • 76,821
  • 6
  • 102
  • 177
SAP
  • 5
  • 8

1 Answers1

0

Reading mount(2) man-page, it seems that filesystem independent options are given in mountflags as combination of different flags, and other filesystem specific options in data as comma-separated string exactly as they are used in mount(8).

So in your case just pass those options as string:

const char *data = "size=100M,mode=0755";
...
mount(source, target, filesystemtype, mountflags, data);
Markus Laire
  • 2,837
  • 2
  • 17
  • 23
  • thank you for answer. I sent file-system options via data, but i can't find my tmpfs. Can I use this partition outside of my program. – SAP Jul 30 '16 at 13:29
  • Look into this address: http://stackoverflow.com/questions/32814782/mount-system-call-in-linux-cannot-display-the-mountpoint-of-file-system-by-df-co – SAP Jul 31 '16 at 06:58