Absolved fuse operations of responsibility for filename translation

This commit is contained in:
fedir 2025-05-01 16:17:11 +02:00
parent 48342b0d5f
commit ed441b3c5f
Signed by: fedir
GPG Key ID: C959EE85F0C9362C

View File

@ -11,6 +11,8 @@
See the file LICENSE.
*/
#include "real_filename.h"
#include <assert.h>
#include <stddef.h>
#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;
}