summaryrefslogtreecommitdiff
path: root/src/os/linux-os_mount_tmpfs.c
blob: 0e173d02eca909e7a385e1973356fe15aac909fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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) ;
    }
  }
}