return (-1);
}
-static int load_plugins(void)
+int fsi_init(void)
{
const char *fsdir = getenv("XEN_FSIMAGE_FSDIR");
struct dirent *dp = NULL;
fsi_plugin_t *fp;
int ret = 0;
- if (plugins == NULL && (ret = load_plugins()) != 0)
+ if (plugins == NULL && (ret = fsi_init()) != 0)
goto out;
for (fp = plugins; fp != NULL; fp = fp->fp_next) {
typedef struct fsi fsi_t;
typedef struct fsi_file fsi_file_t;
+/*
+ * Optional initialization function. If invoked it loads the associated
+ * dynamic libraries for the backends ahead of time. This is required if
+ * the library is to run as part of a highly deprivileged executable, as
+ * the libraries may not be reachable after depriv.
+ */
+int fsi_init(void);
+
fsi_t *fsi_open_fsimage(const char *, uint64_t, const char *);
void fsi_close_fsimage(fsi_t *);
return Py_BuildValue("s", bootstring);
}
+static PyObject *
+fsimage_init(PyObject *o, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return (NULL);
+
+ return Py_BuildValue("i", fsi_init());
+}
+
PyDoc_STRVAR(fsimage_open__doc__,
"open(name, [offset=off]) - Open the given file as a filesystem image.\n"
"\n"
"getbootstring(fs) - Return the boot string needed for this file system "
"or NULL if none is needed.\n");
+PyDoc_STRVAR(fsimage_init__doc__,
+ "init() - Loads every dynamic library contained in xenfsimage "
+ "into memory so that it can be used in chrooted environments.\n");
+
static struct PyMethodDef fsimage_module_methods[] = {
+ { "init", (PyCFunction)fsimage_init,
+ METH_VARARGS, fsimage_init__doc__ },
{ "open", (PyCFunction)fsimage_open,
METH_VARARGS|METH_KEYWORDS, fsimage_open__doc__ },
{ "getbootstring", (PyCFunction)fsimage_getbootstring,