Rev 1655 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
*
*
*
*/
#include <kernel/func.h>
#include <kernel/model.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <semaphore.h>
#include <stdio.h>
#include "common.h"
#define FROMDIR "/TEMP"
char pathname
[8192];
int noscroll
=1;
static int counter
=0;
void viewdir
(int prof
)
{
struct dirent
*den
;
struct stat st
;
char *str
;
DIR
*d
;
int res
;
int x
;
//int i;
//static int flag=0;
str
=pathname
+(x
=strlen(pathname
));
d
=opendir
(pathname
);
if (d
==NULL
) {
cprintf
("ERR: can't open dir %s (errno: %i)\n",pathname
,errno
);
return;
}
while ((den
=readdir
(d
))!=NULL
) {
{
//int c='p';
//c = keyb_getchar();
//if (c=='z') inode_stats();
}
if (x
==1&&*pathname
=='/')
strcat(pathname
,den
->d_name
);
else
strcat(strcat(pathname
,"/"),den
->d_name
);
/*
if (!strcmp(den->d_name,"eport.ror")) {
if (flag==0) debug_info_show(1);
flag++;
// inode_stats();
}
*/
if (counter
==22100) noscroll
=0;
if (noscroll
) {
place
(0,10);
cprintf
(" ");
place
(0,10);
}
cprintf
("%05i %s\n",++counter
,pathname
);
//dcache_stats();
if (!strcmp(den
->d_name
,".")) goto SKIP
;
if (!strcmp(den
->d_name
,"..")) goto SKIP
;
//goto SKIP;
/*
if (!strcmp("MSINH.C",den->d_name)) {
//if (!strcmp("WDIN32.OBJ",den->d_name)) {
cprintf(">>>START SHOWING DEBUG INFO<<<\n");
noscroll=0;
//inode_stats();
debug_info_show(1);
}
*/
res
=stat
(pathname
,&st
);
if (res
!=0) {
cprintf
("can't stat %s\n",pathname
);
cprintf
("errno: %i '%s'\n",errno
,strerror(errno
));
sys_end
();
l1_exit
(0);
} else {
if (S_ISDIR
(st.
st_mode)) {
viewdir
(prof
+1);
}
}
SKIP
:
*str
='\0';
}
closedir
(d
);
}
int main
(int argc
,char *argv
[])
{
// int res;
//if (noscroll) clear();
//strcpy(pathname,"/");
//viewdir(0);
showmessage
("Try to show all filenames from a directory recursively\n"
"using one NRT task.\n");
noscroll
=0;
strcpy(pathname
,FROMDIR
);
viewdir
(0);
//dump_dentry_tree();
/*
*
*/
/*
res=umount(temp_device);
//dump_dentry_tree();
if (res!=0) {
cprintf("can't unmount XXX on /TEMP\n");
cprintf("errno: %i '%s'\n",errno,strerror(errno));
//sys_end();
return -1;
}
*/
//bdev_dump_status();
sys_end
();
return 0;
}