Added source files initialization.

Now source files handling is delegated to functions defined
in `sourcefs.c` file. By encapsulating methods for managing
the underlying source files structure we ensure that all
code changes to the source file protection strategy will be
localized to `sourcefs.c` file.

Also changed Makefile to use more sane way of handling
options and build flags.
This commit is contained in:
2024-11-20 09:28:20 +01:00
parent 424543cd99
commit e48cbc62f1
4 changed files with 59 additions and 12 deletions

View File

@@ -16,6 +16,7 @@ static void *icfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
(void)conn; /* Explicit way to tell we ignore these arguments. */
(void)cfg; /* This also silences the compiler warnings. */
source_init(mountpoint);
return NULL;
}

21
sources/sourcefs.c Normal file
View File

@@ -0,0 +1,21 @@
#define _GNU_SOURCE
#include "sourcefs.h"
#include <fcntl.h>
static struct source_files_handle {
int root_fd;
} handle;
int source_init(const char *root_path) {
int root_fd = open(root_path, O_PATH);
if (root_fd == -1) {
return -1;
}
handle.root_fd = root_fd;
return 0;
}

14
sources/sourcefs.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef SOURCEFS_H
#define SOURCEFS_H
/**
* Initializes the source file handling.
*
* @param root_path The root of the source files folder.
* @return 0 on success, 1 on failure.
*/
int source_init(const char *root_path);
#endif // !SOURCEFS_H