47
*----------------------------------------------------------------------------
51
* Finds the id of the provided loaded module.
54
* The id on success, a negative error code on failure.
59
*----------------------------------------------------------------------------
63
GetModuleId(const char *name) // IN: module name to search for
70
*-----------------------------------------------------------------------------
74
* Lookup and, if loaded, unload the VMBlock kernel module.
77
* TRUE on success, FALSE otherwise
82
*-----------------------------------------------------------------------------
86
UnloadModule(int id) // IN: module id for kldunload(2)
88
if (kldunload(id) < 0) {
89
Error("failed to unload vmblock: %s\n", strerror(errno));
98
*-----------------------------------------------------------------------------
102
* Load the VMBlock kernel module.
105
* TRUE on success, FALSE otherwise
110
*-----------------------------------------------------------------------------
117
* Kldload(2) will handle module search paths for us.
119
if (kldload(MODULE_NAME) == -1) {
120
Error("failed to load vmblock: %s\n", strerror(errno));
129
*-----------------------------------------------------------------------------
133
* Unmount the VMBlock file system.
136
* TRUE on success, FALSE otherwise.
141
*-----------------------------------------------------------------------------
145
UnmountVMBlock(const char *mountPoint) // IN: VMBlock mount point
147
if (unmount(mountPoint, 0) == -1) {
155
*-----------------------------------------------------------------------------
159
* Mount the VMBlock file system.
162
* TRUE on success, FALSE otherwise
167
*-----------------------------------------------------------------------------
174
* These arguments are given as interleaved key => value pairs. We're
175
* requesting mount of the VMBlock filesystem (fstype), with TMP_DIR (target)
176
* remounted over VMBLOCK_MOUNT_POINT (fspath).
178
struct iovec iov[] = {
179
{ .iov_base = "fstype", .iov_len = sizeof "fstype" },
180
{ .iov_base = "vmblock", .iov_len = sizeof "vmblock" },
181
{ .iov_base = "fspath", .iov_len = sizeof "fspath" },
182
{ .iov_base = VMBLOCK_MOUNT_POINT, .iov_len = sizeof VMBLOCK_MOUNT_POINT },
183
{ .iov_base = "target", .iov_len = sizeof "target" },
184
{ .iov_base = TMP_DIR, .iov_len = sizeof TMP_DIR }
187
if (nmount(iov, ARRAYSIZE(iov), MNT_NOSUID) == -1) {
188
Error("failed to mount vmblock file system: %s\n", strerror(errno));
196
41
#ifdef USES_LOCATIONS_DB
198
43
*-----------------------------------------------------------------------------