2024-11-20 09:28:20 +01:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
|
|
|
#include "sourcefs.h"
|
|
|
|
#include <fcntl.h>
|
2024-11-20 10:32:33 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
2024-11-20 09:28:20 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2024-11-20 10:32:33 +01:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|