From 1172c1e817d26d5f9bb0ec289dd9a71aadf2759c Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 20 Apr 2021 00:00:22 +0000 Subject: Add portability infrastructure --- src/os/linux-os_mount_tmpfs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/os/linux-os_mount_tmpfs.c (limited to 'src/os/linux-os_mount_tmpfs.c') diff --git a/src/os/linux-os_mount_tmpfs.c b/src/os/linux-os_mount_tmpfs.c new file mode 100644 index 0000000..0e173d0 --- /dev/null +++ b/src/os/linux-os_mount_tmpfs.c @@ -0,0 +1,31 @@ +/* ISC license. */ + +#include + +#include + +#include + +#include "os.h" + +void os_mount_tmpfs (char const *point, unsigned int mounttype) +{ + if (mounttype) + { + if (mounttype == 2) + { + if (mount("tmpfs", point, "tmpfs", MS_REMOUNT | MS_NODEV | MS_NOSUID, "mode=0755") == -1) + strerr_diefu2sys(111, "remount ", point) ; + } + else + { + if (umount(point) == -1) + { + if (errno != EINVAL) + strerr_warnwu2sys("umount ", point) ; + } + if (mount("tmpfs", point, "tmpfs", MS_NODEV | MS_NOSUID, "mode=0755") == -1) + strerr_diefu2sys(111, "mount tmpfs on ", point) ; + } + } +} -- cgit v1.3.1