00001 #include <stdio.h>
00002 #include <sys/types.h>
00003 #include <sys/stat.h>
00004 #include <fcntl.h>
00005 #include <errno.h>
00006 #include <string.h>
00007 #include <stdlib.h>
00008 #include <unistd.h>
00009 #include <time.h>
00010 #include <ctype.h>
00011 #include "sfs_index.h"
00012
00013
00014 void printittr(SFS_ittr *ittr, int ctr) {
00015
00016 char attr[5];
00017 attr[0] = (ittr->entry.attr == SFS_ATTR_CD) ? 'C' : '-';
00018 attr[1] = (ittr->entry.attr & SFS_ATTR_NOCD) ? 'N' : '-';
00019 attr[2] = (ittr->entry.attr & SFS_ATTR_STICKY_CD) ? 'S' : '-';
00020 attr[3] = (ittr->entry.attr & SFS_ATTR_POPSTICKY) ? 'P' : '-';
00021 attr[4] = '\0';
00022 char type[5];
00023 memcpy(type, ittr->entry.type, 4);
00024 type[4] = '\0';
00025 printf("#%05d@%12lld: %s %s %s [S:%s] [P:%s] [F:%s]\n",
00026 ctr,ittr->fileoffset,
00027 type,
00028 attr,
00029 ittr->entry.name,
00030 ittr->stickypath,
00031 ittr->ppath,
00032 ittr->fullpath);
00033 }
00034
00035 int main(int argc, char *argv[])
00036 {
00037 if(argc < 2) {
00038 printf("sfs_headers filename\n");
00039 return -1;
00040 }
00041
00042 char *fn = argv[1];
00043
00044 SFS_ittr ittr;
00045 wrapfile file;
00046
00047 if(file.opendisk(fn, O_RDONLY) < 0) {
00048 printf("Error openeing file %s (%s)\n",fn,strerror(errno));
00049 return -1;
00050 }
00051
00052 int ctr=1;
00053
00054 ittr.get(&file);
00055
00056 while(ittr.next() >=0) {
00057 printittr(&ittr,ctr);
00058 ctr++;
00059 }
00060 }
00061
00062