Compare commits

...

2 Commits

Author SHA1 Message Date
ff6a8713d3 Removed useless comments from main.c. 2024-11-20 10:35:58 +01:00
8fcfebe3f9 Implemented getattr and source_stat.
Now filesystem implements getattr through source_stat,
which is a wrapper for an fstatat with
`dirfd == handle.root_path`.
2024-11-20 10:32:33 +01:00
3 changed files with 26 additions and 1 deletions

View File

@ -20,8 +20,17 @@ static void *icfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
return NULL; return NULL;
} }
static int icfs_getattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi) {
int statret = source_stat(path, stbuf);
return statret;
}
static const struct fuse_operations icfs_oper = { static const struct fuse_operations icfs_oper = {
.init = icfs_init, .init = icfs_init,
.getattr = icfs_getattr,
}; };
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {

View File

@ -1,8 +1,9 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include "sourcefs.h" #include "sourcefs.h"
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
static struct source_files_handle { static struct source_files_handle {
int root_fd; int root_fd;
@ -19,3 +20,9 @@ int source_init(const char *root_path) {
return 0; return 0;
} }
// Currently this literally is a fstatat wrapper.
int source_stat(const char *restrict pathname, struct stat *restrict statbuf) {
int statret = fstatat(handle.root_fd, pathname, statbuf, 0);
return statret;
}

View File

@ -3,6 +3,8 @@
#ifndef SOURCEFS_H #ifndef SOURCEFS_H
#define SOURCEFS_H #define SOURCEFS_H
#include <sys/stat.h>
/** /**
* Initializes the source file handling. * Initializes the source file handling.
* *
@ -11,4 +13,11 @@
*/ */
int source_init(const char *root_path); int source_init(const char *root_path);
/**
* `stat()`, but for source files.
*
* @see `stat()`
*/
int source_stat(const char *restrict pathname, struct stat *restrict statbuf);
#endif // !SOURCEFS_H #endif // !SOURCEFS_H