- Timestamp:
- 11/04/07 00:19:11 (1 year ago)
- Files:
-
- tarfs/tarfs.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tarfs/tarfs.c
r20 r25 10 10 11 11 #include <fuse.h> 12 13 #include "zlib.h"14 #include "bzlib.h"15 12 16 13 #include "tar.h" … … 196 193 197 194 /* Create a root directory of the tree */ 198 new=file_tree=create_dir(NULL);195 file_tree=create_dir(NULL); 199 196 200 197 while(true){ … … 238 235 else 239 236 return NULL; 240 241 /* Add inode attributes */ 242 int name_size=strlen(result); 243 memmove(new->file_name, result, name_size); 244 new->file_name[name_size]='\0'; 237 /* Add inode attributes */ int name_size=strlen(result); memmove(new->file_name, result, name_size); new->file_name[name_size]='\0'; 245 238 246 239 switch(header.typeflag){ … … 264 257 /* Jump to the next header */ 265 258 fseek(file, new->block_length, SEEK_CUR); 259 266 260 } 267 261 fflush(file); … … 313 307 int main(int argc, char **argv){ 314 308 /* Parse filepath and initialize the file tree */ 315 /* 316 int c; 317 while( (c=getopt(argc, argv, "f:")) != -1 ){ 318 switch(c){ 319 case 'f': 320 { 321 tar_file = fopen(optarg, "r"); 322 if( !tar_file ){ 323 eprintf("Invalid filename: %s\n", optarg); 324 return 1; 325 } 326 file_tree=tarfs_init(tar_file); 327 if( !file_tree ){ 328 eprintf("Invalid file: %s\n", optarg); 329 return 1; 330 } 331 break; 332 } 333 case '?': 334 default: 335 break; 336 } 337 } 338 309 if( argc != 3 ){ 310 eprintf("Use: %s directory filepath\n", argv[0]); 311 return 1; 312 } 313 314 tar_file = fopen(argv[2], "r"); 315 if( !tar_file ){ 316 eprintf("Invalid filename: %s\n", argv[2]); 317 return 1; 318 } 319 320 file_tree=tarfs_init(tar_file); 339 321 if( !file_tree ){ 340 eprintf(" Use: %s -f filepath\n", argv[0]);322 eprintf("Invalid filetype: %s\n", argv[2]); 341 323 return 1; 342 }*/ 343 tar_file = fopen("./contrib.tar", "r"); 344 345 file_tree=tarfs_init(tar_file); 346 347 if( !file_tree ){ 348 eprintf("A fatal error occoured...\n"); 349 return 1; 350 } 351 else{ 352 return fuse_main(argc, argv, &tarfs_oper); 353 } 354 } 324 } 325 326 return fuse_main(argc-1, argv, &tarfs_oper); 327 }
