summaryrefslogtreecommitdiff
path: root/src/lib/rib.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2021-06-26 15:04:05 +0200
committerSander Vrijders <sander@ouroboros.rocks>2021-06-28 15:29:19 +0200
commit18b0de19830e7286ad5eecbba23013e835739cdc (patch)
tree6c7f1cadb2c1fd4a19c388c1e42ac94700a568aa /src/lib/rib.c
parentcb70b78c443de5f8b95c4469dd8eb7f77af880ed (diff)
downloadouroboros-18b0de19830e7286ad5eecbba23013e835739cdc.tar.gz
ouroboros-18b0de19830e7286ad5eecbba23013e835739cdc.zip
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 <sys/stat.h>. The rib now has its own struct rib_attr to set attributes such as size and last modified time. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/rib.c')
-rw-r--r--src/lib/rib.c19
1 files changed, 14 insertions, 5 deletions
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 <ouroboros/errno.h>
#include <ouroboros/list.h>
#include <ouroboros/rib.h>
#include <ouroboros/utils.h>
+
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
@@ -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 <sys/stat.h>
#include <fuse.h>
#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;
}
}