projects
/
rrq
/
fuse_xattrs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e70621e
)
ensure paret directories for sidecars
author
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Fri, 12 Nov 2021 03:27:12 +0000
(14:27 +1100)
committer
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Fri, 12 Nov 2021 03:27:12 +0000
(14:27 +1100)
binary_storage.c
patch
|
blob
|
history
diff --git
a/binary_storage.c
b/binary_storage.c
index 0f0289119baa719a38fff12eea2a920878cb0727..3e4144111be32cadc1081ff74986c92104009166 100644
(file)
--- a/
binary_storage.c
+++ b/
binary_storage.c
@@
-12,6
+12,9
@@
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "binary_storage.h"
#include "utils.h"
#include "binary_storage.h"
#include "utils.h"
@@
-228,6
+231,25
@@
int __write_to_file(FILE *file, const char *name, const char *value, const size_
return 0;
}
return 0;
}
+static int ensure_dirs(char *path) {
+ int n = strlen( path );
+ char *p = stralloc( n+1 );
+ memcpy( p, path, n+1 );
+ char *e = p + 1;
+ for ( ;; ) {
+ while ( *e && *e != '/' ) e++;
+ if ( *e ) {
+ *e = 0;
+ if ( access( p, F_OK ) && mkdir( p, 0777 ) ) {
+ return 1;
+ }
+ *(e++) = '/';
+ } else {
+ return 0;
+ }
+ }
+}
+
/**
*
* @param path - path to file.
/**
*
* @param path - path to file.
@@
-259,6
+281,11
@@
int binary_storage_write_key(const char *path, const char *name, const char *val
int status;
char *sidecar_path = get_sidecar_path(path);
int status;
char *sidecar_path = get_sidecar_path(path);
+
+ if ( ensure_dirs( sidecar_path ) ) {
+ return -ENOATTR;
+ }
+
FILE *file = fopen(sidecar_path, "w");
strfree(sidecar_path);
FILE *file = fopen(sidecar_path, "w");
strfree(sidecar_path);