diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2021-06-28 21:47:09 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2021-06-29 08:56:03 +0200 |
commit | d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02 (patch) | |
tree | fd97e0b4b84e80f2429727e8882158647c0f563f /src/lib | |
parent | 16675c72764c59644c1822bf481482fcbd6e850c (diff) | |
download | ouroboros-d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02.tar.gz ouroboros-d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02.zip |
lib: Pass full path for RIB entries
The read functions for the RIB will now receive the full path, instead
of only the entry name. For IPCPs, we organized the RIB in an
/<ipcp>/<component>/entries
structure with a directory per component, so we don't need the full
path at this point. For process flow information, it's a lot more
convenient to organize it the following way
/<pid>/<fd>/stat
We can then register/unregister the flow descriptor when the frct
instance is created, and for getting the stats, we'd know the flow
descriptor from the fuse file path. If we would create a file per flow
instead of a directory per flow, something like
/<pid>/flows/<fd>
we'd need to do additional bookkeeping to list the contents of that
directory (we would need to track all flows with an active FRCT
instance), that fuse knows because it tracks the directories.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/rib.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/lib/rib.c b/src/lib/rib.c index b5222d6d..dfac69d7 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -52,8 +52,6 @@ #define CLOCK_REALTIME_COARSE CLOCK_REALTIME #endif -#define RT "/" - struct reg_comp { struct list_head next; @@ -108,8 +106,7 @@ static int rib_read(const char * path, strcpy(comp, path + 1); - c = strstr(comp, "/"); - + c = strstr(comp, RIB_SEPARATOR); if (c != NULL) *c = '\0'; @@ -121,7 +118,7 @@ static int rib_read(const char * path, list_for_each(p, &rib.reg_comps) { struct reg_comp * r = list_entry(p, struct reg_comp, next); if (strcmp(comp, r->path) == 0) { - int ret = r->ops->read(c + 1, buf, size); + int ret = r->ops->read(path + 1, buf, size); pthread_rwlock_unlock(&rib.lock); return ret; } @@ -148,7 +145,7 @@ static int rib_readdir(const char * path, pthread_rwlock_rdlock(&rib.lock); - if (strcmp(path, RT) == 0) { + if (strcmp(path, RIB_SEPARATOR) == 0) { list_for_each(p, &rib.reg_comps) { struct reg_comp * c; c = list_entry(p, struct reg_comp, next); @@ -194,8 +191,7 @@ static size_t __getattr(const char * path, strcpy(comp, path + 1); - c = strstr(comp, "/"); - + c = strstr(comp, RIB_SEPARATOR); if (c != NULL) *c = '\0'; @@ -206,7 +202,7 @@ static size_t __getattr(const char * path, 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, &attr); + size_t ret = r->ops->getattr(path + 1, &attr); pthread_rwlock_unlock(&rib.lock); st->st_mode = S_IFREG | 0755; st->st_nlink = 1; @@ -231,7 +227,7 @@ static int rib_getattr(const char * path, memset(st, 0, sizeof(*st)); - if (strcmp(path, RT) == 0) + if (strcmp(path, RIB_SEPARATOR) == 0) goto finish_dir; pthread_rwlock_rdlock(&rib.lock); @@ -352,6 +348,9 @@ void rib_fini(void) struct list_head * p; struct list_head * h; + if (strlen(rib.mnt) == 0) + return; + fuse_exit(rib.fuse); fuse_unmount(rib.mnt, rib.ch); |