skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. It seems that you are facing issues with both curlftpfs and your own FUSE implementation in C++. Let’s address each of them separately.

    Regarding curlftpfs:
    The "function not implemented" error you encounter with the mkdir command and other commands like ls, rm could be due to limitations or compatibility issues with the FTP server (FileZilla) and curlftpfs. It’s possible that certain FTP commands like LIST are not supported or properly handled by the FTP server, resulting in the errors you observe.

    To investigate further, you can check the documentation or support resources for curlftpfs to see if there are any known compatibility issues with FileZilla FTP Server. Additionally, you can try connecting to the FTP server using different FTP clients to confirm if the issue is specific to curlftpfs or if it persists with other clients as well.

    Regarding your own FUSE implementation in C++:
    In your code, the my_mkdir function is not being called because you’re using the mkdir function from the standard library instead of the FUSE library. To create directories using FUSE, you need to use the fuse_mkdir function instead.

    Update the my_mkdir function in your code as follows:

    static int my_mkdir(const char* path, mode_t mode)
    {
        std::cout << "called mkdir" << std::endl;
    
        int res = fuse_mkdir(path, mode);
    
        if (res == -1)
        {
            perror("mkdir err");
        }
    
        return res;
    }
    

    By using fuse_mkdir instead of mkdir, your custom my_mkdir function will be invoked correctly when creating directories.

    After making this change, try running your FUSE implementation again and verify if the my_mkdir function is called as expected.

    Remember to ensure that you have the necessary FUSE development libraries installed (libfuse-dev or libfuse3-dev) to compile and link against the FUSE headers and libraries successfully.

    If you continue to encounter issues with your FUSE implementation, you may need to investigate further by examining error codes, checking the FUSE documentation, and potentially debugging your code to identify any other potential issues.

    Overall, it’s important to carefully investigate the compatibility and limitations of the FTP server (FileZilla) for curlftpfs and ensure that you’re using the appropriate FUSE functions in your own implementation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search