From: Ralph Ronnquist Date: Sat, 13 Nov 2021 00:18:25 +0000 (+1100) Subject: avoid reconfirming the root paths X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=10f81048b040f61d76f476300a485dd55b22cbe8;p=rrq%2Ffuse_xattrs.git avoid reconfirming the root paths --- diff --git a/binary_storage.c b/binary_storage.c index 3e41441..e8eaba4 100644 --- a/binary_storage.c +++ b/binary_storage.c @@ -20,6 +20,7 @@ #include "utils.h" #include "fuse_xattrs_config.h" #include "stringmem.h" +#include "xattrs_config.h" #include @@ -231,11 +232,22 @@ int __write_to_file(FILE *file, const char *name, const char *value, const size_ return 0; } +// Ensure existence of tail path from either source_dir or sidecar_dir static int ensure_dirs(char *path) { int n = strlen( path ); char *p = stralloc( n+1 ); memcpy( p, path, n+1 ); char *e = p + 1; + if ( strncmp( path, xattrs_config.source_dir, + xattrs_config.source_dir_size ) == 0 ) { + e += xattrs_config.source_dir_size; + } else if ( strncmp( path, xattrs_config.sidecar_dir, + xattrs_config.sidecar_dir_size ) == 0 ) { + e += xattrs_config.sidecar_dir_size; + } + if ( e - p >= n ) { + return 0; + } for ( ;; ) { while ( *e && *e != '/' ) e++; if ( *e ) {