summaryrefslogtreecommitdiff
path: root/src/os/freebsd-os_mount_tmpfs.c
blob: 183a799dab5df0783e5c25e024c94784fa437698 (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
33
34
/* ISC license. */

#include <skalibs/nonposix.h>

#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, 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, MNT_NOSUID, "mode=0755") == -1)
        strerr_diefu2sys(111, "mount tmpfs on ", point) ;
    }
  }
}