Module: OsCtl::ExportFS::Sys

Defined in:
lib/osctl/exportfs/sys.rb

Defined Under Namespace

Modules: Int

Constant Summary collapse

CLONE_NEWNS =
0x00020000
CLONE_NEWUTS =
0x04000000
CLONE_NEWUSER =
0x10000000
CLONE_NEWPID =
0x20000000
CLONE_NEWNET =
0x40000000
CLONE_NEWIPC =
0x08000000

Class Method Summary collapse

Class Method Details

.bind_mount(src, dst) ⇒ Object

Raises:

  • (SystemCallError)


42
43
44
45
46
# File 'lib/osctl/exportfs/sys.rb', line 42

def self.bind_mount(src, dst)
  ret = Int.mount(src, dst, 0, Int::MS_MGC_VAL | Int::MS_BIND, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.chroot(path) ⇒ Object

Raises:

  • (SystemCallError)


122
123
124
125
126
# File 'lib/osctl/exportfs/sys.rb', line 122

def self.chroot(path)
  ret = Int.chroot(path)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.make_rshared(dst) ⇒ Object

Raises:

  • (SystemCallError)


72
73
74
75
76
# File 'lib/osctl/exportfs/sys.rb', line 72

def self.make_rshared(dst)
  ret = Int.mount("none", dst, 0, Int::MS_REC | Int::MS_SHARED, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.make_rslave(dst) ⇒ Object

Raises:

  • (SystemCallError)


84
85
86
87
88
# File 'lib/osctl/exportfs/sys.rb', line 84

def self.make_rslave(dst)
  ret = Int.mount("none", dst, 0, Int::MS_REC | Int::MS_SLAVE, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.make_shared(dst) ⇒ Object

Raises:

  • (SystemCallError)


66
67
68
69
70
# File 'lib/osctl/exportfs/sys.rb', line 66

def self.make_shared(dst)
  ret = Int.mount("none", dst, 0, Int::MS_SHARED, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.make_slave(dst) ⇒ Object

Raises:

  • (SystemCallError)


78
79
80
81
82
# File 'lib/osctl/exportfs/sys.rb', line 78

def self.make_slave(dst)
  ret = Int.mount("none", dst, 0, Int::MS_SLAVE, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.mount_proc(dst) ⇒ Object

Raises:

  • (SystemCallError)


60
61
62
63
64
# File 'lib/osctl/exportfs/sys.rb', line 60

def self.mount_proc(dst)
  ret = Int.mount("none", dst, "proc", Int::MS_MGC_VAL, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.mount_tmpfs(dst) ⇒ Object

Raises:

  • (SystemCallError)


54
55
56
57
58
# File 'lib/osctl/exportfs/sys.rb', line 54

def self.mount_tmpfs(dst)
  ret = Int.mount("none", dst, "tmpfs", Int::MS_MGC_VAL, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.move_mount(src, dst) ⇒ Object

Raises:

  • (SystemCallError)


36
37
38
39
40
# File 'lib/osctl/exportfs/sys.rb', line 36

def self.move_mount(src, dst)
  ret = Int.mount(src, dst, 0, Int::MS_MGC_VAL | Int::MS_MOVE, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.rbind_mount(src, dst) ⇒ Object

Raises:

  • (SystemCallError)


48
49
50
51
52
# File 'lib/osctl/exportfs/sys.rb', line 48

def self.rbind_mount(src, dst)
  ret = Int.mount(src, dst, 0, Int::MS_MGC_VAL | Int::MS_BIND | Int::MS_REC, 0)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.setns_io(io, nstype) ⇒ Object

Raises:

  • (SystemCallError)


110
111
112
113
114
# File 'lib/osctl/exportfs/sys.rb', line 110

def self.setns_io(io, nstype)
  ret = Int.setns(io.fileno, nstype)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.setns_path(path, nstype) ⇒ Object

Raises:

  • (SystemCallError)


102
103
104
105
106
107
108
# File 'lib/osctl/exportfs/sys.rb', line 102

def self.setns_path(path, nstype)
  f = File.open(path)
  ret = Int.setns(f.fileno, nstype)
  f.close
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.unmount(mountpoint) ⇒ Object

Raises:

  • (SystemCallError)


90
91
92
93
94
# File 'lib/osctl/exportfs/sys.rb', line 90

def self.unmount(mountpoint)
  ret = Int.umount2(mountpoint, 0) # force unmount returns EACCESS
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.unmount_lazy(mountpoint) ⇒ Object

Raises:

  • (SystemCallError)


96
97
98
99
100
# File 'lib/osctl/exportfs/sys.rb', line 96

def self.unmount_lazy(mountpoint)
  ret = Int.umount2(mountpoint, Int::MNT_DETACH)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end

.unshare_ns(type) ⇒ Object

Raises:

  • (SystemCallError)


116
117
118
119
120
# File 'lib/osctl/exportfs/sys.rb', line 116

def self.unshare_ns(type)
  ret = Int.unshare(type)
  raise SystemCallError, Fiddle.last_error if ret != 0
  ret
end