Пример #1
0
int copy_filldir(void *dirents, const char *name, int namelen, off_t offset, uint64_t inumber, unsigned flags) {
    char dname[256];
    char lname[256];
    int r;
    xfs_inode_t *inode=NULL;
    struct stat fstats;
    char mode[]="rwxrwxrwx";
    int tests[]={S_IRUSR,S_IWUSR,S_IXUSR,S_IRGRP,S_IWGRP,S_IXGRP,S_IROTH,S_IWOTH,S_IXOTH};

    struct filldir_data *data = (struct filldir_data *) dirents;

    strcpy(dname, data->base);
    strcat(dname, "/");
    strncat(dname, name, namelen);

    strcpy(lname, data->local);
    strcat(lname, "/");
    strncat(lname, name, namelen);

    r = libxfs_iget(data->mp, NULL, inumber, 0, &inode, 0);
    if (r) printf("Panic! %d\n", r);
    r = xfs_stat(inode, &fstats);
    if (r) printf("Panic! stats %d\n", r);
    if (xfs_is_dir(inode)) {
        printf("d");
    } else if (xfs_is_link(inode)) {
        printf("l");
    } else printf("-");

    for (r=0; r<9; r++) {
        if (fstats.st_mode & tests[r]) {
            printf("%c", mode[r]);
        } else {
            printf("-");
        }
    }
    
    printf(" %s -> %s\n", dname, lname);
    if (strncmp(name, ".", namelen) == 0)
        libxfs_iput(inode, 0);
    else if (strncmp(name, "..", namelen) == 0)
        libxfs_iput(inode, 0);
    else {
        copy_tree(data->mp, dname, lname, inode);
        libxfs_iput(inode, 0);
    }
    return 0;
}
Пример #2
0
int cli_ls_xfs_filldir(void *dirents, const char *name, int namelen, off_t offset, uint64_t inumber, unsigned flags) {
    char dname[256];
    char symlink[256];
    int r;
    xfs_inode_t *inode=NULL;
    struct stat fstats;
    char mode[]="rwxrwxrwx";
    int tests[]={S_IRUSR,S_IWUSR,S_IXUSR,S_IRGRP,S_IWGRP,S_IXGRP,S_IROTH,S_IWOTH,S_IXOTH};

    struct filldir_data *data = (struct filldir_data *) dirents;
    memcpy(dname, name, namelen);
    dname[namelen] = '\0';
    r = libxfs_iget(data->mp, NULL, inumber, 0, &inode, 0);
    if (r) printf("Panic! %d\n", r);
    r = xfs_stat(inode, &fstats);
    if (r) printf("Panic! stats %d\n", r);
    if (xfs_is_dir(inode)) {
        printf("d");
    } else if (xfs_is_link(inode)) {
        printf("l");
    } else printf("-");

    for (r=0; r<9; r++) {
        if (fstats.st_mode & tests[r]) {
            printf("%c", mode[r]);
        } else {
            printf("-");
        }
    }
    
    print_int(fstats.st_uid, 6);
    print_int(fstats.st_gid, 6);
    print_int(fstats.st_size, 12);
    
    printf(" %s", dname);
    if (xfs_is_link(inode)) {
        r = xfs_readlink(inode, symlink, 0, 255, NULL);
        if (r > 0) {
            symlink[r] = '\0';
            printf("->%s", symlink);
        }
    }
    printf("\n");
    libxfs_iput(inode, 0);
    return 0;
}
Пример #3
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;
}
Пример #4
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;
}