From 18b0de19830e7286ad5eecbba23013e835739cdc Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 26 Jun 2021 15:04:05 +0200 Subject: lib: Remove struct stat from RIB API The RIB API had a struct stat in the getattr() function, which made all components that exposed variables via the RIB dependent on . The rib now has its own struct rib_attr to set attributes such as size and last modified time. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/rib.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/lib/rib.c') diff --git a/src/lib/rib.c b/src/lib/rib.c index 0418252b..b5222d6d 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -24,15 +24,12 @@ #include "config.h" -#if defined (__FreeBSD__) -#define __XSI_VISIBLE 500 -#endif - #include #include #include #include + #include #include #include @@ -45,7 +42,10 @@ #define FUSE_USE_VERSION 26 #if defined (__linux__) #define __USE_XOPEN +#elif defined (__FreeBSD__) +#define __XSI_VISIBLE 500 #endif /* __linux__ */ +#include #include #ifndef CLOCK_REALTIME_COARSE @@ -187,6 +187,7 @@ static size_t __getattr(const char * path, struct list_head * p; char comp[RIB_PATH_LEN + 1]; char * c; + struct rib_attr attr; if (strlen(path) > RIB_PATH_LEN) return -1; @@ -198,13 +199,21 @@ static size_t __getattr(const char * path, if (c != NULL) *c = '\0'; + memset(&attr, 0, sizeof(attr)); + pthread_rwlock_rdlock(&rib.lock); list_for_each(p, &rib.reg_comps) { struct reg_comp * r = list_entry(p, struct reg_comp, next); if (strcmp(comp, r->path) == 0) { - size_t ret = r->ops->getattr(c + 1, st); + size_t ret = r->ops->getattr(c + 1, &attr); pthread_rwlock_unlock(&rib.lock); + st->st_mode = S_IFREG | 0755; + st->st_nlink = 1; + st->st_uid = getuid(); + st->st_gid = getgid(); + st->st_size = attr.size; + st->st_mtime = attr.mtime; return ret; } } -- cgit v1.2.3