Using Debian 11 kernel 5.10.
I try to make fuse linux kernel library getting to work.
When I use "mkdir" in terminal for mounted path it says "function no implemented", e.g. mkdir /drv/drive1/test
Same message was for curlftpfs for "ls" command (and any command like mkdir, rm, ls returns input/ouput error) but it's problem with FTP and not fuse. On the FTP server side it logs "Command LIST -a" and 550 response code - "Couldn't open the file or directory" (FTP server runs on Windows - FileZilla FTP Server). Although connecting to FTP with FTP client for same credentials works fine (it does not use LIST command, instead - CWD). For this reason I decided to write my own network share over ftp but may there is solution to this curlftpfs issue?
Here's the C++ code (without FTP part), what am I missing?:
#define FUSE_USE_VERSION 30
#include <fuse.h>
#include <iostream>
static const char* mount_point = "/drv/drive1";
static int success = 0;
static int my_mkdir(const char* path, mode_t mode)
{
std::cout << "called mkdir" << std::endl;
int res = mkdir(path, mode);
if (res == -1)
{
perror("mkdir err");
}
return res;
}
static void* my_init(fuse_conn_info*)
{
std::cout << "init" << std::endl;
struct fuse_context* ctx = fuse_get_context();
ctx->private_data = &success;
return &success;
}
static struct fuse_operations my_operations = {
.mkdir = my_mkdir,
.init = my_init
};
int main(int argc, char* argv[])
{
struct fuse_args args = FUSE_ARGS_INIT(0, nullptr);
struct fuse_chan* ch = fuse_mount(mount_point, &args);
if (ch == nullptr)
{
std::cerr << "Failed to mount FUSE filesystem" << std::endl;
return 1;
}
struct fuse* session = fuse_new(ch, &args, &my_operations, sizeof(my_operations), nullptr);
int res = fuse_loop(session);
fuse_unmount(mount_point, ch);
fuse_destroy(session);
fuse_opt_free_args(&args);
return 0;
}
The 'my_init' works fine, logs in console unlike 'my_mkdir'.
Installed 'libfuse-dev' and 'libfuse3-dev' packages.
I also tried writing it in Rust and the message was "input/output error" and functions of Filesystem trait were probably not executed (fuse crate, newest version).
First using curlftpfs - got error and do not know why it is not working, may just because FTP server is running under Windows and not Linux? (so that LIST -a ftp command either does not work or is not supported?)
Then writing simplified version in Rust - again, not working but at the level of fuse crate.
Then moved to C++ as it is lower-level and closer to kernel, so may it will be fine - again, not working properly.
You can enable "debug" option in your fuse mount to see exactly which internal file operation is failing.
I would guess you need to implement some minimal set of operations such as .getattr
. I recommend for you to take a fuse example program from libfuse, compile and run it, and start modifying in small steps to implement your desired fs.