summaryrefslogtreecommitdiff
path: root/src/os/freebsd-os_mount_tmpfs.c
blob: 27a4f1f6bc7ef6daf4963387f1d317b862db87ba (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
32
/* ISC license. */

#include <errno.h>

#include <sys/param.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", MNT_UPDATE | MNT_NOSUID, "mode=0755") == -1)
        strerr_diefu2sys(111, "remount ", point) ;
    }
    else
    {
      if (unmount(point, MNT_FORCE) == -1)
      {
        if (errno != EINVAL)
          strerr_warnwu2sys("umount ", point) ;
      }
      if (mount("tmpfs", point, "tmpfs", MNT_NOSUID, "mode=0755") == -1)
        strerr_diefu2sys(111, "mount tmpfs on ", point) ;
    }
  }
}