Improved code readability and added database file argument.

This commit is contained in:
BritishTeapot
2025-04-07 19:38:33 +02:00
parent aea6e94ad7
commit 16b8d77fb9
4 changed files with 46 additions and 36 deletions

View File

@@ -10,16 +10,15 @@
See the file LICENSE.
*/
#include <sys/types.h>
#include <unistd.h>
#define FUSE_USE_VERSION 31
#define _GNU_SOURCE
#include <fuse3/fuse.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "fuse_operations.h"
#include "sourcefs.h"
@@ -28,15 +27,25 @@
const char *mountpoint = NULL;
int main(int argc, char *argv[]) {
if (argc < 3) {
fprintf(stderr, "Usage: icfs <FUSE arguments> [target directory] [path to "
"the permanent permissions database\n");
return EXIT_FAILURE;
}
// if umask != 0, the filesystem will create files with more restrictive
// permissions than it's caller reqested
umask(0);
int ret = init_ui_socket();
// ui socket should always be initialized before anything else, since it
// handles the setuid bits!
int ret = init_ui_socket(argv[argc - 1]);
if (ret != 0) {
fprintf(stderr, "Could not initalize ui-socket.\n");
exit(EXIT_FAILURE);
}
mountpoint = realpath(argv[argc - 1], NULL);
mountpoint = realpath(argv[argc - 2], NULL);
ret = source_init(mountpoint);
if (ret != 0) {
@@ -44,9 +53,9 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE);
}
ret = fuse_main(argc, argv, get_fuse_operations(), NULL);
ret = fuse_main(argc - 1, argv, get_fuse_operations(), NULL);
free(mountpoint);
free((void *)mountpoint);
destroy_ui_socket();
return ret;
}