ERROR:“fuse_operations_compat2”有一个名为“READDIR”没有非静态数据成员

问题描述 投票:1回答:2

我想建立使用保险丝2.9.7存储的AVIFILE中有一个简单的文件系统。但我有找到这些错误的解决方案的麻烦。

‘fuse_operations_compat2’ has no non-static data member named ‘readdir’

我有这样的main.cpp

#include<iostream>
#include<fuse.h>

#include "include/AVIContainer.h"
#include "include/Fuse.h"

using namespace std;

int main(int argc, char* argv[])
{
  AVIContainer *avi = new AVIContainer(320, 240, 30, 90);
  avi->WriteToFile("test.avi");


struct fuse_operations oper = {
    .getattr    = getattr_callback,
    .readdir    = readdir_callback,
    .open       = open_callback,
    .read       = read_callback,
};

   return fuse_main(argc, argv , &oper);

}

而这些都是头文件(的.cpp)

#define FUSE_USE_VERSION 30

#include<fuse.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>

#include "Fuse.h"


char filename[30] = "/avifile";
char filename2[30] = "avifile"; 


int getattr_callback(const char *path, struct stat *st)
{

      st->st_uid = getuid();
      st->st_gid = getgid();
      st->st_atime = time(NULL);
      st->st_mtime = time(NULL);

      if(strcmp(path, "/") == 0)
      {
          st->st_mode = S_IFDIR | 0755;
          st->st_nlink = 2;
      }

      if(strcmp(path,filename) == 0)
      {  
          st->st_mode = S_IFREG | 0644;
          st->st_nlink = 1;
          st->st_size = datasize;
      }

      return 0;       
}


int readdir_callback(const char *path, void *buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi)
{

       filler(buffer, ".", NULL, 0);
       filler(buffer, "..", NULL, 0);

       if(strcmp(path, "/") == 0)
       {
           filler(buffer, filename2, NULL, 0);           
       }

       return 0;
}

int read_callback(const char *path, char *buffer, size_t size, off_t offset, struct fuse_file_info *fi)
{

       unsigned int SizetoRead = size;

       if(  (offset + size) > datasize)
       {
            SizetoRead = datasize - offset;
       }

       memcpy(buffer, databuffer + offset, SizetoRead);      

       return SizetoRead;
}

int open_callback(const char *path, fuse_file_info *fi)
{        

    return 0;
}

这是.h文件中

#ifndef FUSE
#define FUSE


#include <fuse.h>

uint8_t* get_data();

unsigned int get_size();

int getattr_callback(const char *path, struct stat *st);

int read_callback(const char *path, char *buffer, size_t size, off_t offset, struct fuse_file_info *fi);

int readdir_callback(const char *path, void *buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi);

int open_callback(const char *path, fuse_file_info *fi);

#endif 

我认为这个问题是导火索的版本,虽然不能肯定。请大家帮忙,在此先感谢

编辑:

c++ fuse
2个回答
0
投票

您使用的是高层次的保险丝OPS(VS低级别的)。这里是你可以用它做什么(fuse_compat.h)

struct fuse_operations_compat2 {
    int (*getattr)     (const char *, struct stat *);
    int (*readlink)    (const char *, char *, size_t);
    int (*getdir)      (const char *, fuse_dirh_t, fuse_dirfil_t_compat);
    int (*mknod)       (const char *, mode_t, dev_t);
    int (*mkdir)       (const char *, mode_t);
    int (*unlink)      (const char *);
    int (*rmdir)       (const char *);
    int (*symlink)     (const char *, const char *);
    int (*rename)      (const char *, const char *);
    int (*link)    (const char *, const char *);
    int (*chmod)       (const char *, mode_t);
    int (*chown)       (const char *, uid_t, gid_t);
    int (*truncate)    (const char *, off_t);
    int (*utime)       (const char *, struct utimbuf *);
    int (*open)    (const char *, int);
    int (*read)    (const char *, char *, size_t, off_t);
    int (*write)       (const char *, const char *, size_t, off_t);
    int (*statfs)      (const char *, struct statfs *);
    int (*flush)       (const char *);
    int (*release)     (const char *, int);
    int (*fsync)       (const char *, int);
    int (*setxattr)    (const char *, const char *, const char *, size_t, int);
    int (*getxattr)    (const char *, const char *, char *, size_t);
    int (*listxattr)   (const char *, char *, size_t);
    int (*removexattr) (const char *, const char *);

};

尝试有版本为32


0
投票

在你main.cpp,设置之前的版本包括在fuse.h头,所以当你的主文件编译(其中READDIR应该进行设置),导火索是在兼容模式下加载。从你的主文件中删除#include<fuse.h>应该解决的问题,因为FUSE然后通过你的头文件,它设置了正确的版本包括在内。

© www.soinside.com 2019 - 2024. All rights reserved.