Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1655 | giacomo | 1 | /* |
2 | * |
||
3 | * |
||
4 | * |
||
5 | */ |
||
6 | |||
7 | #include <kernel/func.h> |
||
8 | #include <kernel/model.h> |
||
9 | |||
10 | #include <sys/types.h> |
||
11 | #include <sys/stat.h> |
||
12 | #include <sys/mount.h> |
||
13 | #include <dirent.h> |
||
14 | #include <fcntl.h> |
||
15 | #include <unistd.h> |
||
16 | #include <errno.h> |
||
17 | #include <string.h> |
||
18 | #include <stdlib.h> |
||
19 | #include <semaphore.h> |
||
20 | #include <stdio.h> |
||
21 | |||
22 | #include "common.h" |
||
23 | |||
24 | #define FROMDIR "/TEMP" |
||
25 | |||
26 | char pathname[8192]; |
||
27 | |||
28 | int noscroll=1; |
||
29 | |||
30 | static int counter=0; |
||
31 | |||
32 | void viewdir(int prof) |
||
33 | { |
||
34 | struct dirent *den; |
||
35 | struct stat st; |
||
36 | char *str; |
||
37 | DIR *d; |
||
38 | int res; |
||
39 | int x; |
||
40 | //int i; |
||
41 | //static int flag=0; |
||
42 | |||
43 | str=pathname+(x=strlen(pathname)); |
||
44 | d=opendir(pathname); |
||
45 | |||
46 | if (d==NULL) { |
||
47 | cprintf("ERR: can't open dir %s (errno: %i)\n",pathname,errno); |
||
48 | return; |
||
49 | } |
||
50 | |||
51 | while ((den=readdir(d))!=NULL) { |
||
52 | |||
53 | { |
||
54 | //int c='p'; |
||
55 | //c = keyb_getchar(); |
||
56 | //if (c=='z') inode_stats(); |
||
57 | } |
||
58 | |||
59 | if (x==1&&*pathname=='/') |
||
60 | strcat(pathname,den->d_name); |
||
61 | else |
||
62 | strcat(strcat(pathname,"/"),den->d_name); |
||
63 | |||
64 | /* |
||
65 | if (!strcmp(den->d_name,"eport.ror")) { |
||
66 | if (flag==0) debug_info_show(1); |
||
67 | flag++; |
||
68 | // inode_stats(); |
||
69 | } |
||
70 | */ |
||
71 | |||
72 | if (counter==22100) noscroll=0; |
||
73 | |||
74 | if (noscroll) { |
||
75 | place(0,10); |
||
76 | cprintf(" "); |
||
77 | place(0,10); |
||
78 | } |
||
79 | cprintf("%05i %s\n",++counter,pathname); |
||
80 | //dcache_stats(); |
||
81 | |||
82 | if (!strcmp(den->d_name,".")) goto SKIP; |
||
83 | if (!strcmp(den->d_name,"..")) goto SKIP; |
||
84 | |||
85 | //goto SKIP; |
||
86 | |||
87 | /* |
||
88 | if (!strcmp("MSINH.C",den->d_name)) { |
||
89 | //if (!strcmp("WDIN32.OBJ",den->d_name)) { |
||
90 | cprintf(">>>START SHOWING DEBUG INFO<<<\n"); |
||
91 | noscroll=0; |
||
92 | //inode_stats(); |
||
93 | debug_info_show(1); |
||
94 | } |
||
95 | */ |
||
96 | |||
97 | res=stat(pathname,&st); |
||
98 | if (res!=0) { |
||
99 | cprintf("can't stat %s\n",pathname); |
||
100 | cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
||
101 | sys_end(); |
||
102 | l1_exit(0); |
||
103 | } else { |
||
104 | if (S_ISDIR(st.st_mode)) { |
||
105 | viewdir(prof+1); |
||
106 | } |
||
107 | |||
108 | } |
||
109 | |||
110 | SKIP: |
||
111 | *str='\0'; |
||
112 | } |
||
113 | |||
114 | closedir(d); |
||
115 | } |
||
116 | |||
117 | int main(int argc,char *argv[]) |
||
118 | { |
||
119 | // int res; |
||
120 | |||
121 | //if (noscroll) clear(); |
||
122 | |||
123 | //strcpy(pathname,"/"); |
||
124 | //viewdir(0); |
||
125 | |||
126 | showmessage("Try to show all filenames from a directory recursively\n" |
||
127 | "using one NRT task.\n"); |
||
128 | |||
129 | noscroll=0; |
||
130 | strcpy(pathname,FROMDIR); |
||
131 | viewdir(0); |
||
132 | |||
133 | //dump_dentry_tree(); |
||
134 | |||
135 | /* |
||
136 | * |
||
137 | */ |
||
138 | |||
139 | /* |
||
140 | res=umount(temp_device); |
||
141 | //dump_dentry_tree(); |
||
142 | if (res!=0) { |
||
143 | cprintf("can't unmount XXX on /TEMP\n"); |
||
144 | cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
||
145 | //sys_end(); |
||
146 | return -1; |
||
147 | } |
||
148 | */ |
||
149 | |||
150 | //bdev_dump_status(); |
||
151 | |||
152 | sys_end(); |
||
153 | return 0; |
||
154 | } |