Example #1
0
static int
fuse_xfs_statfs(const char *path, struct statvfs *stbuf) {
    xfs_mount_t *mount = current_xfs_mount();
    
    memset(stbuf, 0, sizeof(*stbuf));
    stbuf->f_bsize = mount->m_sb.sb_blocksize;
    stbuf->f_frsize = mount->m_sb.sb_blocksize;
    stbuf->f_blocks =  mount->m_sb.sb_dblocks;
    stbuf->f_bfree =  mount->m_sb.sb_fdblocks;
    stbuf->f_files = mount->m_maxicount;
    stbuf->f_ffree = mount->m_sb.sb_ifree + mount->m_maxicount - mount->m_sb.sb_icount;
    stbuf->f_favail = stbuf->f_ffree;
    stbuf->f_namemax = MAXNAMELEN;
    stbuf->f_fsid = *((unsigned long*)mount->m_sb.sb_uuid);
    log_debug("f_bsize=%ld\n", stbuf->f_bsize);
    log_debug("f_frsize=%ld\n", stbuf->f_frsize);
    log_debug("f_blocks=%d\n", stbuf->f_blocks);
    log_debug("f_bfree=%d\n", stbuf->f_bfree);
    log_debug("f_files=%d\n", stbuf->f_files);
    log_debug("f_ffree=%d\n", stbuf->f_ffree);
    log_debug("f_favail=%d\n", stbuf->f_favail);
    log_debug("f_namemax=%ld\n", stbuf->f_namemax);
    log_debug("f_fsid=%ld\n", stbuf->f_fsid);
    return 0;
}
Example #2
0
int fuse_xfs_opendir(const char *path, struct fuse_file_info *fi) {
    int r;
    xfs_inode_t *inode=NULL;
    log_debug("opendir %s\n", path); 
    
    r = find_path(current_xfs_mount(), path, &inode);
    if (r) {
        return -ENOENT;
    }
    
    libxfs_iput(inode, 0);
    return 0;
}
Example #3
0
static int
fuse_xfs_open(const char *path, struct fuse_file_info *fi) {
    int r;
    xfs_inode_t *inode=NULL;
    
    log_debug("open %s\n", path); 
    
    r = find_path(current_xfs_mount(), path, &inode);
    if (r) {
        return -ENOENT;
    }
    
    fi->fh = (uint64_t)inode;
    return 0;
}
Example #4
0
static int fuse_xfs_readdir(const char *path, void *buf, //fuse_fill_dir_t filler,
                 off_t offset, struct fuse_file_info *fi) {
    log_debug("readdir %s\n", path);
    int r;
    struct filler_info_struct filler_info;
    xfs_inode_t *inode=NULL;
    
    r = find_path(current_xfs_mount(), path, &inode);
    if (r) {
        return -ENOENT;
    }
    
    filler_info.buf = buf;
    //filler_info.filler = filler;
    xfs_readdir(inode, (void *)&filler_info, 1024000, &offset, fuse_xfs_filldir);
    libxfs_iput(inode, 0);
    return 0;
}
Example #5
0
static int
fuse_xfs_readlink(const char *path, char *buf, size_t size) {
    int r;
    xfs_inode_t *inode=NULL;

    log_debug("readlink %s\n", path); 
    
    r = find_path(current_xfs_mount(), path, &inode);
    if (r) {
        return -ENOENT;
    }
    
    r = xfs_readlink(inode, buf, 0, size, NULL);
    if (r < 0) {
        return r;
    }
    libxfs_iput(inode, 0);
    return 0;
}
Example #6
0
static int
fuse_xfs_fgetattr(const char *path, struct stat *stbuf,
                  struct fuse_file_info *fi) {
    log_debug("fgetattr %s\n", path);
    
    int r;
    xfs_inode_t *inode=NULL;
    
    r = find_path(current_xfs_mount(), path, &inode);
    if (r) {
        return -ENOENT;
    }
    xfs_stat(inode, stbuf);

    if (xfs_is_dir(inode)) {
        log_debug("directory %s\n", path);
    }
    
    return 0;
}
Example #7
0
int fuse_xfs_filldir(void *filler_info, const char *name, int namelen, off_t offset, uint64_t inumber, unsigned flags) {
    int r;
    char dir_entry[256];
    xfs_inode_t *inode=NULL;    
    struct stat stbuf;
    struct stat *stats = NULL;
    struct filler_info_struct *filler_data = (struct filler_info_struct *) filler_info;
    
    memcpy(dir_entry, name, namelen);
    dir_entry[namelen] = '\0';
    if (libxfs_iget(current_xfs_mount(), NULL, inumber, 0, &inode, 0)) {
        return 0;
    }
    if (!xfs_stat(inode, &stbuf)) {
        stats = &stbuf;
    }
    log_debug("Direntry %s\n", dir_entry);
    r = filler_data->filler(filler_data->buf, dir_entry, stats, 0);
    libxfs_iput(inode, 0);
    return r;
}