9 #include <SUNRT/clock.h>
12 int main(
int argc,
char *argv[])
15 printf(
"fs_ex filename\n");
19 int fd = open(argv[1], O_RDONLY);
21 printf(
"Bad file...%s\n",argv[1]);
24 printf(
"Sizeof inode=%ld\n",
sizeof(
fs_inode));
29 lseek(fd, 0, SEEK_SET);
33 printf(
"SFS format input file...\n");
47 printf(
"Building index for file %s...\n",argv[1]);
49 idx->mount(argv[1],O_RDONLY);
51 printf(
"time to build index of %d inodes = %5.2lf seconds\n",idx->n_inodes,t);
55 fs_dir *dir = idx->opendir(
"/");
63 printf(
"First 10 elements in /\n");
65 while((entry = idx->readdir(dir))) {
67 printf(
"%lld %d (%s)(%s)%c\n",entry->offset, entry->sz, idx->cwd,entry->d_name,entry->has_child ?
'/' :
' ');
77 dirs[0] = idx->opendir(
"/");
85 entry = idx->readdir(dirs[i]);
86 if(entry->has_child) {
88 printf(
"i=%d entry->sz=%d, name=%s\n",i,entry->sz,entry->full_name);
89 dirs[i] = idx->opendir(entry->full_name);
101 idx->closedir(dirs[i]);
105 printf(
"%lld %d %s\n",entry->offset, entry->sz, entry->full_name);