diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-04-20 00:00:22 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-04-20 00:00:22 +0000 |
| commit | 1172c1e817d26d5f9bb0ec289dd9a71aadf2759c (patch) | |
| tree | 6c7e5eb2ebb255c7be81d1535559fa7c4a63af4b /src/os/linux-os_mount_tmpfs.c | |
| parent | 3bde455795bb3273922ec7be293e3911913576c2 (diff) | |
| download | s6-linux-init-1172c1e817d26d5f9bb0ec289dd9a71aadf2759c.tar.gz | |
Add portability infrastructure
Diffstat (limited to 'src/os/linux-os_mount_tmpfs.c')
| -rw-r--r-- | src/os/linux-os_mount_tmpfs.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <errno.h> + +#include <sys/mount.h> + +#include <skalibs/strerr2.h> + +#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) ; + } + } +} |
