Browse Source

Cleanups.

alpine-vm-issue106
Martin Pärtel 1 year ago
parent
commit
9664dcb762
  1. 67
      src/bindfs.c
  2. 2
      tests/odirect_write.c

67
src/bindfs.c

@ -221,13 +221,6 @@ static int is_mirroring_enabled();
/* Checks whether the uid is to be the mirrored owner of all files. */
static int is_mirrored_user(uid_t uid);
#ifdef HAVE_FUSE_3
#ifndef __NR_renameat2
/* Returns the path to a temporary file inside the same directory as src_path */
char *tmpnam_inpath(char *src_path);
#endif
#endif
/* Processes the virtual path to a real path. Always free() the result. */
static char *process_path(const char *path, bool resolve_symlinks);
@ -377,66 +370,6 @@ static int is_mirrored_user(uid_t uid)
return 0;
}
#ifdef HAVE_FUSE_3
#ifndef __NR_renameat2
char *tmpnam_inpath(char *src_path)
{
char *res, tmp[L_tmpnam], *path, *fname, *tfname, *src_path_cpy, *src_path_cpy_1, *tmp_cpy;
int i = 0;
src_path_cpy = (char *) calloc((strlen(src_path)), sizeof(char));
strcpy(src_path_cpy, src_path);
src_path_cpy_1 = (char *) calloc((strlen(src_path)), sizeof(char));
strcpy(src_path_cpy_1, src_path);
path = dirname(src_path_cpy);
fname = basename(src_path_cpy_1);
tmpnam(tmp);
tmp_cpy = (char *) calloc((strlen(tmp)), sizeof(char));
strcpy(tmp_cpy, tmp);
tfname = basename(tmp_cpy);
res = (char *) calloc( (strlen(path) + 2 + strlen(tfname) + 1 + strlen(fname) + 1), sizeof(char));
strcat(res, path);
strcat(res, "/.");
strcat(res, tfname);
strcat(res, "~");
strcat(res, fname);
while (access( res, F_OK ) == 0 && i < 10) {
tmpnam(tmp);
tmp_cpy = (char *) calloc((strlen(tmp)), sizeof(char));
strcpy(tmp_cpy, tmp);
tfname = basename(tmp_cpy);
res = (char *) calloc( (strlen(path) + 2 + strlen(tfname) + 1 + strlen(fname) + 1), sizeof(char));
strcat(res, path);
strcat(res, "/.");
strcat(res, tfname);
strcat(res, "~");
strcat(res, fname);
i++;
}
if (access( res, F_OK ) == 0) {
return NULL;
}
return res;
}
#endif
#endif
static char *process_path(const char *path, bool resolve_symlinks)
{
if (path == NULL) { /* possible? */

2
tests/odirect_write.c

@ -57,7 +57,7 @@ int main(int argc, char** argv) {
}
if (res != buf_size) {
// Too lazy to write a loop here unless it turns out to be necessary.
fprintf(stderr, "Failed to write exactly %ld bytes", amt_read);
fprintf(stderr, "Failed to write exactly %lu bytes", (unsigned long)amt_read);
}
}

Loading…
Cancel
Save