[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH 6/7] lib/vfscore: Expose max fds to sysconf
Expose FDTABLE_MAX_FILES from vfscore as the return value of sysconf(_SC_OPEN_MAX) if CONFIG_LIBVFSCORE is enabled. This allows language runtimes to inspect the number of active fds (e.g. for tests). Signed-off-by: Cristian Banu <cristb@xxxxxxxxx> --- lib/posix-sysinfo/sysinfo.c | 10 ++++++++++ lib/vfscore/fd.c | 2 -- lib/vfscore/include/vfscore/file.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/posix-sysinfo/sysinfo.c b/lib/posix-sysinfo/sysinfo.c index 7bcfc8b..075f320 100644 --- a/lib/posix-sysinfo/sysinfo.c +++ b/lib/posix-sysinfo/sysinfo.c @@ -43,6 +43,11 @@ #include <sys/sysinfo.h> #include <uk/syscall.h> +#if CONFIG_LIBVFSCORE +/* For FDTABLE_MAX_FILES. */ +#include <vfscore/file.h> +#endif + static struct utsname utsname = { .sysname = "Unikraft", .nodename = "unikraft", @@ -85,6 +90,11 @@ long sysconf(int name) if (name == _SC_PAGESIZE) return __PAGE_SIZE; +#if CONFIG_LIBVFSCORE + if (name == _SC_OPEN_MAX) + return FDTABLE_MAX_FILES; +#endif + return 0; } diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c index 684ea50..956846f 100644 --- a/lib/vfscore/fd.c +++ b/lib/vfscore/fd.c @@ -42,8 +42,6 @@ #include <errno.h> #include <uk/ctors.h> -#define FDTABLE_MAX_FILES 1024 - void init_stdio(void); struct fdtable { diff --git a/lib/vfscore/include/vfscore/file.h b/lib/vfscore/include/vfscore/file.h index be23974..ec45a08 100644 --- a/lib/vfscore/include/vfscore/file.h +++ b/lib/vfscore/include/vfscore/file.h @@ -80,6 +80,9 @@ int fdrop(struct vfscore_file* fp); #define FOF_OFFSET 0x0800 /* Use the offset in uio argument */ +/* Used from posix-sysinfo to determine sysconf(_SC_OPEN_MAX). */ +#define FDTABLE_MAX_FILES 1024 + #ifdef __cplusplus } #endif -- 2.26.2
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |