From ed441b3c5f8c726ae9f8cbb21650f1ab96fdcd17 Mon Sep 17 00:00:00 2001 From: fedir Date: Thu, 1 May 2025 16:17:11 +0200 Subject: [PATCH] Absolved fuse operations of responsibility for filename translation --- src/fuse_operations.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/fuse_operations.c b/src/fuse_operations.c index 6d29052..8c6077e 100644 --- a/src/fuse_operations.c +++ b/src/fuse_operations.c @@ -11,6 +11,8 @@ See the file LICENSE. */ +#include "real_filename.h" +#include #include #define FUSE_USE_VERSION 31 @@ -94,9 +96,6 @@ const char *get_process_name_by_pid(const int pid) { */ } -// TODO: move this somewhere else -const char *real_filename(const char *filename) { return filename; } - static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { (void)conn; cfg->use_ino = 1; @@ -120,6 +119,7 @@ static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { cfg->attr_timeout = 0; cfg->negative_timeout = 0; fprintf(stderr, "%d\n", getpid()); + assert(get_mountpoint() != NULL); return NULL; } @@ -157,7 +157,7 @@ static int xmp_access(const char *path, int mask) { // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), proc_info, 0)) { + if (!interactive_access(path, proc_info, 0)) { free((void *)proc_info.name); return -EACCES; } @@ -323,7 +323,7 @@ static int xmp_unlink(const char *path) { // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), pi, 0)) { + if (!interactive_access(path, pi, 0)) { free(pi.name); return -EACCES; } @@ -371,15 +371,14 @@ static int xmp_rename(const char *from, const char *to, unsigned int flags) { // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(from), pi, 0)) { + if (!interactive_access(from, pi, 0)) { free(pi.name); return -EACCES; } // the "to" file may exist and the process needs to get persmission to modify // it - if (source_access(to, F_OK) == 0 && - !interactive_access(real_filename(to), pi, 0)) { + if (source_access(to, F_OK) == 0 && !interactive_access(to, pi, 0)) { free(pi.name); return -EACCES; } @@ -402,7 +401,7 @@ static int xmp_link(const char *from, const char *to) { pi.name = get_process_name_by_pid(pi.PID); // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(from), pi, 0)) { + if (!interactive_access(from, pi, 0)) { free(pi.name); return -EACCES; } @@ -427,7 +426,7 @@ static int xmp_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) { pi.name = get_process_name_by_pid(pi.PID); // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), pi, 0)) { + if (!interactive_access(path, pi, 0)) { free(pi.name); return -EACCES; } @@ -458,7 +457,7 @@ static int xmp_chown(const char *path, uid_t uid, gid_t gid, pi.name = get_process_name_by_pid(pi.PID); // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), pi, 0)) { + if (!interactive_access(path, pi, 0)) { free(pi.name); return -EACCES; } @@ -518,7 +517,7 @@ static int xmp_create(const char *path, mode_t mode, // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), pi, GRANT_PERM)) { + if (!interactive_access(path, pi, GRANT_PERM)) { free(pi.name); return -EACCES; } @@ -542,7 +541,7 @@ static int xmp_open(const char *path, struct fuse_file_info *fi) { pi.name = get_process_name_by_pid(pi.PID); // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (!interactive_access(real_filename(path), pi, 0)) { + if (!interactive_access(path, pi, 0)) { free(pi.name); return -EACCES; }