FUSE在默认系统调用中引发数值结果超出范围错误

时间:2018-07-15 09:28:43

标签: c file directory filesystems fuse

我正在尝试学习保险丝。我尝试制作仅调用默认系统调用的默认文件系统。我当前的代码如下:

#define FUSE_USE_VERSION 26

#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>


static int dfs_open(const char *path, struct fuse_file_info * info){
    return 1;
}

static int dfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info * info) {
    return 1;
}

static int dfs_write (const char * a, const char * b, size_t c, off_t d, struct fuse_file_info * info){
    return 1;
}

static int dfs_release (const char * a, struct fuse_file_info * info){
    return 1;
}

static int dfs_rename (const char * a, const char * b){
    return 1;
}


static int dfs_unlink (const char * a){
    return 1;
}

static int dfs_rmdir (const char * pathname){
    printf("Removing Directory With Name: %s\n", pathname);
    return rmdir(pathname);
}

static int dfs_mkdir (const char * pathname, mode_t mode){
    printf("Creating Directory With Name: %s\n", pathname);
    return mkdir(pathname, mode);
}

static int dfs_opendir (const char * name, struct fuse_file_info * info){
    printf("Opening Directory With Name: %s\n", name);
    return opendir(name);
}

static int dfs_releasedir (const char * name, struct fuse_file_info * info){
    printf("Closing Directory With Name: %s\n", name);
    DIR * dirp = opendir(name);
    return closedir(dirp);
}

static int dfs_truncate (const char * path, off_t length){
    return truncate(path, length);
}

static int dfs_create (const char * pathname, mode_t mode, struct fuse_file_info * info){
    return creat(pathname, mode);
}

static int dfs_getattr(const char * path, struct stat * stbuf){
    return 1;
}

static struct fuse_operations dfs_oper = {
    .open       = dfs_open,
    .read       = dfs_read,
    .write      = dfs_write,
    .release    = dfs_release,
    .rename     = dfs_rename,
    .unlink     = dfs_unlink,
    .rmdir      = dfs_rmdir,
    .mkdir      = dfs_mkdir,
    .opendir    = dfs_opendir,
    .releasedir = dfs_releasedir,
    .create     = dfs_create,
    .getattr    = dfs_getattr,
    .truncate   = dfs_truncate,
};

int main(int argc, char *argv[])
{
    return fuse_main(argc, argv, &dfs_oper, NULL);
}

如您所见,唯一实现的调用是mkdirrmdiropendirreleasedirtruncatecreate。当我挂载此文件系统,然后尝试在其中创建目录时,调用mkdir test_name会出现以下错误:

  

mkdir:无法创建目录“ test_name”:数字结果出自   范围

你能告诉我是什么问题吗?

0 个答案:

没有答案