Changeset 7

Show
Ignore:
Timestamp:
10/28/07 16:45:16 (1 year ago)
Author:
nlawren2
Message:

Start coding now

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tarfs/tarfs.c

    r6 r7  
    33#include <string.h> 
    44 
    5 //#include <fuse/fuse.h> 
    6 //#include <fuse.h> 
     5#include <fuse/fuse.h> 
     6#include <fuse.h> 
    77 
    88#include "tar.h" 
     
    3333        bool special; // if . or .. 
    3434}; 
     35 
     36FILE  *tar_file; 
     37inode *file_tree; 
    3538 
    3639inode *create_dir(inode *parent){ 
     
    5356} 
    5457 
    55 inode *read_file(FILE *file, inode *file_tree, char *file_path){ 
     58static int tarfs_open(const char *file_path, struct fuse_file_info *fi); 
     59 
     60static int tarfs_readdir(const char *file_path, void *buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi); 
     61 
     62static int tarfs_getattr(const char*, struct stat*); 
     63 
     64static int tarfs_read(const char *file_path, void *buffer, size_t size, off_t offset, struct fuse_file_info *fi); 
     65//(FILE *file, inode *file_tree, char *file_path){ 
    5666        char buffer[BLOCK_SIZE]; 
    5767        char *result; 
    58         char delims[]="/\n"; 
     68        char delims[]="/"; 
    5969        inode *i=file_tree, *node; 
    6070        int size; 
     
    8898        for(; size > BLOCK_SIZE; size -=BLOCK_SIZE){ 
    8999                fread(buffer, sizeof(char), BLOCK_SIZE, file); 
    90                 fwrite(buffer, sizeof(char), BLOCK_SIZE, stdout); 
     100                fwrite(buffer, sizeof(char), BLOCK_SIZE, stdout); // <<< 
    91101        } 
    92102 
    93103        fread(buffer, sizeof(char), size, file); 
    94         fwrite(buffer, sizeof(char), size, stdout); 
     104        fwrite(buffer, sizeof(char), size, stdout); // <<< 
    95105 
    96106        fflush(file); 
     
    99109} 
    100110 
    101 inode *create_file_tree(FILE *file){ 
     111inode *tarfs_init(FILE *file){ 
    102112        char buffer[BLOCK_SIZE]; 
    103113        char *result; 
     
    170180} 
    171181 
    172 void destroy_file_tree(inode *file_tree){ 
     182void tarfs_destroy(inode *file_tree){ 
    173183        inode *i=file_tree, *j; 
    174184 
     
    184194 
    185195 
    186 void print_tree(inode *file_tree, int tab){ 
     196void tarfs_print(inode *file_tree, int tab){ 
    187197        inode *i=file_tree; 
    188198 
     
    202212 
    203213int main(int argc, char **argv){ 
    204         FILE *tar_file; 
     214        // Getopts to parse -f filepath 
     215         
    205216        char filepath[NAME_SIZE]; 
    206         inode *file_tree; 
    207217        if(argc < 2){ 
    208218                eprintf("Use %s filename", argv[0]); 
     
    222232        } 
    223233         
    224         print_tree(file_tree,0); 
    225  
    226         printf("Please enter the name of the file you would like to read:"); 
    227         fgets(filepath,NAME_SIZE,stdin); 
    228          
    229234        inode *i=read_file(tar_file, file_tree, filepath); 
     235         
    230236        if( i == NULL ){ 
    231237                eprintf("Invalid filename: %s", filepath); 
    232238                return 1; 
    233239        } 
     240 
     241        // fuse_main 
    234242         
    235243        destroy_file_tree(file_tree);