virFileAbsPath;
virFileAccessibleAs;
virFileActivateDirOverride;
+virFileBindMountDevice;
virFileBuildPath;
virFileClose;
virFileDeleteTree;
virFileRewrite;
virFileRewriteStr;
virFileSanitizePath;
+virFileSetupDev;
virFileSkipRoot;
virFileStripSuffix;
virFileTouch;
return ret;
}
-static int lxcContainerBindMountDevice(const char *src, const char *dst)
-{
- if (virFileTouch(dst, 0666) < 0)
- return -1;
-
- if (mount(src, dst, "none", MS_BIND, NULL) < 0) {
- virReportSystemError(errno, _("Failed to bind %s on to %s"), src,
- dst);
- return -1;
- }
-
- return 0;
-}
-
static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
{
size_t i;
}
/* We have private devpts capability, so bind that */
- if (lxcContainerBindMountDevice("/dev/pts/ptmx", "/dev/ptmx") < 0)
+ if (virFileBindMountDevice("/dev/pts/ptmx", "/dev/ptmx") < 0)
return -1;
for (i = 0; i < nttyPaths; i++) {
if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0)
return -1;
- if (lxcContainerBindMountDevice(ttyPaths[i], tty) < 0) {
+ if (virFileBindMountDevice(ttyPaths[i], tty) < 0) {
return -1;
VIR_FREE(tty);
}
VIR_FREE(tty);
if (i == 0 &&
- lxcContainerBindMountDevice(ttyPaths[i], "/dev/console") < 0)
+ virFileBindMountDevice(ttyPaths[i], "/dev/console") < 0)
return -1;
}
return 0;
LXC_STATE_DIR, ctrl->def->name) < 0)
goto cleanup;
- if (virFileMakePath(dev) < 0) {
- virReportSystemError(errno,
- _("Failed to make path %s"), dev);
- goto cleanup;
- }
-
/*
* tmpfs is limited to 64kb, since we only have device nodes in there
* and don't want to DOS the entire OS RAM usage
"mode=755,size=65536%s", mount_options) < 0)
goto cleanup;
- VIR_DEBUG("Mount devfs on %s type=tmpfs flags=%x, opts=%s",
- dev, MS_NOSUID, opts);
- if (mount("devfs", dev, "tmpfs", MS_NOSUID, opts) < 0) {
- virReportSystemError(errno,
- _("Failed to mount devfs on %s type %s (%s)"),
- dev, "tmpfs", opts);
+ if (virFileSetupDev(dev, opts) < 0)
goto cleanup;
- }
if (lxcContainerChown(ctrl->def, dev) < 0)
goto cleanup;
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
+#if defined(HAVE_SYS_MOUNT_H)
+# include <sys/mount.h>
+#endif
#include <unistd.h>
#include <dirent.h>
#include <dirname.h>
VIR_FILE_SHFS_SMB |
VIR_FILE_SHFS_CIFS);
}
+
+
+#if defined(HAVE_SYS_MOUNT_H)
+int
+virFileSetupDev(const char *path,
+ const char *mount_options)
+{
+ const unsigned long mount_flags = MS_NOSUID;
+ const char *mount_fs = "tmpfs";
+ int ret = -1;
+
+ if (virFileMakePath(path) < 0) {
+ virReportSystemError(errno,
+ _("Failed to make path %s"), path);
+ goto cleanup;
+ }
+
+ VIR_DEBUG("Mount devfs on %s type=tmpfs flags=%lx, opts=%s",
+ path, mount_flags, mount_options);
+ if (mount("devfs", path, mount_fs, mount_flags, mount_options) < 0) {
+ virReportSystemError(errno,
+ _("Failed to mount devfs on %s type %s (%s)"),
+ path, mount_fs, mount_options);
+ goto cleanup;
+ }
+
+ ret = 0;
+ cleanup:
+ return ret;
+}
+
+
+int
+virFileBindMountDevice(const char *src,
+ const char *dst)
+{
+ if (virFileTouch(dst, 0666) < 0)
+ return -1;
+
+ if (mount(src, dst, "none", MS_BIND, NULL) < 0) {
+ virReportSystemError(errno, _("Failed to bind %s on to %s"), src,
+ dst);
+ return -1;
+ }
+
+ return 0;
+}
+
+#else /* !defined(HAVE_SYS_MOUNT_H) */
+
+int
+virFileSetupDev(const char *path ATTRIBUTE_UNUSED,
+ const char *mount_options ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("mount is not supported on this platform."));
+ return -1;
+}
+
+
+int
+virFileBindMountDevice(const char *src ATTRIBUTE_UNUSED,
+ const char *dst ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("mount is not supported on this platform."));
+ return -1;
+}
+#endif /* !defined(HAVE_SYS_MOUNT_H) */
unsigned long long *size);
int virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
size_t *ret_nfs);
+
+int virFileSetupDev(const char *path,
+ const char *mount_options);
+
+int virFileBindMountDevice(const char *src,
+ const char *dst);
#endif /* __VIR_FILE_H */