comparison ffstools/tiffs-rd/ls.c @ 236:254de9560ef3

tiffs ls -v implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 19:03:33 +0000
parents e17bb8818318
children 317936902be4
comparison
equal deleted inserted replaced
235:e17bb8818318 236:254de9560ef3
35 iterate_seg_file(seghead_ino, segment_size_callback, (u_long) &accum, 35 iterate_seg_file(seghead_ino, segment_size_callback, (u_long) &accum,
36 deleted); 36 deleted);
37 return(accum); 37 return(accum);
38 } 38 }
39 39
40 static void
41 segment_ls_callback(inf, opaque)
42 struct inode_info *inf;
43 u_long opaque;
44 {
45 struct chunkinfo chi;
46
47 size_extra_chunk(inf, &chi);
48 printf("seg #%04x length=%lu\n", inf->ino, (u_long) chi.len);
49 }
50
51 ls_seg_file(seghead_ino, deleted)
52 {
53 struct inode_info *inf = inode_info[seghead_ino];
54 struct chunkinfo chi;
55
56 size_head_chunk(inf, &chi);
57 printf("%lu bytes in seghead\n", (u_long) chi.len);
58 iterate_seg_file(seghead_ino, segment_ls_callback, 0L, deleted);
59 }
60
40 void 61 void
41 ls_callback(pathname, ino, depth) 62 ls_callback(pathname, ino, depth)
42 char *pathname; 63 char *pathname;
43 { 64 {
44 struct inode_info *inf = inode_info[ino]; 65 struct inode_info *inf = inode_info[ino];
52 switch (inf->type) { 73 switch (inf->type) {
53 case 0xE1: 74 case 0xE1:
54 case 0xF1: 75 case 0xF1:
55 size = get_file_size(ino, 0); 76 size = get_file_size(ino, 0);
56 printf("f%c %7lu %s\n", readonly, size, pathname); 77 printf("f%c %7lu %s\n", readonly, size, pathname);
78 if (verbose2)
79 ls_seg_file(ino, 0);
57 return; 80 return;
58 case 0xE2: 81 case 0xE2:
59 case 0xF2: 82 case 0xF2:
60 printf("d%c %s\n", readonly, pathname); 83 printf("d%c %s\n", readonly, pathname);
61 return; 84 return;
69 inf->type); 92 inf->type);
70 exit(1); 93 exit(1);
71 } 94 }
72 } 95 }
73 96
74 cmd_ls() 97 ls_visible_tree()
75 { 98 {
76 read_ffs_image(); 99 read_ffs_image();
77 find_inode_block(); 100 find_inode_block();
78 alloc_inode_table(); 101 alloc_inode_table();
79 find_root_inode(); 102 find_root_inode();
80 traverse_visible_tree(ls_callback); 103 traverse_visible_tree(ls_callback);
81 exit(0); 104 exit(0);
82 } 105 }
106
107 cmd_ls(argc, argv)
108 char **argv;
109 {
110 char **ap;
111
112 ap = argv + 1;
113 if (*ap && !strcmp(*ap, "-v")) {
114 verbose2++;
115 ap++;
116 }
117 if (!*ap)
118 return ls_visible_tree();
119 fprintf(stderr, "ls of individual files not yet implemented\n");
120 exit(1);
121 }