diff options
author | Sander Vrijders <[email protected]> | 2020-04-30 11:49:30 +0200 |
---|---|---|
committer | Dimitri Staessens <[email protected]> | 2020-04-30 12:32:53 +0200 |
commit | 978266fe4beba21292daad2d341fe5ff22e08aba (patch) | |
tree | d432100d7d40f4ece133fdb56233509f86839f8d /src/lib/rib.c | |
parent | f6ae2ac9f0735846c58e0e953c01c3d834dd7d08 (diff) | |
download | ouroboros-978266fe4beba21292daad2d341fe5ff22e08aba.tar.gz ouroboros-978266fe4beba21292daad2d341fe5ff22e08aba.zip |
lib: Unmount stale RIB directories
If Ouroboros crashed, the RIB directory might still be mounted. This
checks if this is the case, then unmounts it.
Signed-off-by: Sander Vrijders <[email protected]>
Signed-off-by: Dimitri Staessens <[email protected]>
Diffstat (limited to 'src/lib/rib.c')
-rw-r--r-- | src/lib/rib.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/rib.c b/src/lib/rib.c index 684c5dcd..6aacb0be 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -271,6 +271,7 @@ int rib_init(const char * mountpt) { #ifdef HAVE_FUSE struct stat st; + struct stat prefix_st; char * argv[] = {"-f", "-o", "ro," @@ -280,7 +281,7 @@ int rib_init(const char * mountpt) NULL}; struct fuse_args args = FUSE_ARGS_INIT(3, argv); - if (stat(FUSE_PREFIX, &st) == -1) + if (stat(FUSE_PREFIX, &prefix_st) == -1) return -1; sprintf(rib.mnt, FUSE_PREFIX "/%s", mountpt); @@ -298,6 +299,14 @@ int rib_init(const char * mountpt) return -1; } + /* + * If parent directory is a different filesystem, + * then directory was already mounted in a previous + * Ouroboros instance that was killed. + */ + if (st.st_dev != prefix_st.st_dev) + fuse_unmount(rib.mnt, rib.ch); + fuse_opt_parse(&args, NULL, NULL, NULL); list_head_init(&rib.reg_comps); |