libsel4muslcsys: transition to new libcpio API
diff --git a/libsel4muslcsys/include/muslcsys/io.h b/libsel4muslcsys/include/muslcsys/io.h
index b0ef79d..192c71a 100644
--- a/libsel4muslcsys/include/muslcsys/io.h
+++ b/libsel4muslcsys/include/muslcsys/io.h
@@ -54,5 +54,7 @@
get_fd_struct(int fd);
/* install a cpio interface to use with open */
-typedef void *(*muslcsys_cpio_get_file_fn_t)(void *cpio_symbol, const char *name, unsigned long *size);
-void muslcsys_install_cpio_interface(void *cpio_symbol, muslcsys_cpio_get_file_fn_t fn);
+typedef void *(*muslcsys_cpio_get_file_fn_t)(void *cpio_symbol, unsigned long len,
+ const char *name, unsigned long *size);
+void muslcsys_install_cpio_interface(void *cpio_symbol, unsigned long cpio_len,
+ muslcsys_cpio_get_file_fn_t fn);
diff --git a/libsel4muslcsys/src/sys_io.c b/libsel4muslcsys/src/sys_io.c
index 801576a..cf42634 100644
--- a/libsel4muslcsys/src/sys_io.c
+++ b/libsel4muslcsys/src/sys_io.c
@@ -41,6 +41,7 @@
#define FREE_FD_TABLE_SIZE(x) (sizeof(int) * ((x) - FIRST_USER_FD))
static void *cpio_archive_symbol;
+static unsigned long cpio_archive_len;
static muslcsys_cpio_get_file_fn_t cpio_get_file_impl;
/* We need to wrap this in the config to prevent linker errors */
@@ -196,9 +197,9 @@
long unsigned int size;
char *file = NULL;
if (cpio_get_file_impl && cpio_archive_symbol) {
- file = cpio_get_file_impl(cpio_archive_symbol, pathname, &size);
+ file = cpio_get_file_impl(cpio_archive_symbol, cpio_archive_len, pathname, &size);
if (!file && strncmp(pathname, "./", 2) == 0) {
- file = cpio_get_file_impl(cpio_archive_symbol, pathname + 2, &size);
+ file = cpio_get_file_impl(cpio_archive_symbol, cpio_archive_len, pathname + 2, &size);
}
}
if (!file) {
@@ -539,7 +540,9 @@
return -EACCES;
}
-void muslcsys_install_cpio_interface(void *cpio_symbol, muslcsys_cpio_get_file_fn_t fn) {
+void muslcsys_install_cpio_interface(void *cpio_symbol, unsigned long cpio_len,
+ muslcsys_cpio_get_file_fn_t fn) {
cpio_archive_symbol = cpio_symbol;
+ cpio_archive_len = cpio_len;
cpio_get_file_impl = fn;
}
diff --git a/libsel4muslcsys/src/vsyscall.c b/libsel4muslcsys/src/vsyscall.c
index 9cf0470..20ab216 100644
--- a/libsel4muslcsys/src/vsyscall.c
+++ b/libsel4muslcsys/src/vsyscall.c
@@ -226,8 +226,10 @@
/* If we have a default CPIO file interface defined in the config then install it here */
#ifdef CONFIG_LIB_SEL4_MUSLC_SYS_CPIO_FS
extern char _cpio_archive[];
+extern char _cpio_archive_end[];
static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) install_default_cpio(void) {
- muslcsys_install_cpio_interface(_cpio_archive, cpio_get_file);
+ unsigned long cpio_len = _cpio_archive_end - _cpio_archive;
+ muslcsys_install_cpio_interface(_cpio_archive, cpio_len, cpio_get_file);
}
#endif