parent
372c5bf2c1
commit
b5532eb4bc
@ -1,47 +0,0 @@
|
||||
#define __LIBRARY__
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdarg.h>
|
||||
#define O_RDONLY 00
|
||||
struct linux_dirent {
|
||||
long d_ino;
|
||||
off_t d_off;
|
||||
unsigned short d_reclen;
|
||||
char d_name[1024];
|
||||
};
|
||||
char buf[512];
|
||||
_syscall3(int,getdents, int,fd,struct linux_dirent *,dirp,unsigned long,len)
|
||||
_syscall3(int ,open,const char *,filename,int, flag,int, mode)
|
||||
_syscall1(int,close,int,fildes)
|
||||
_syscall3(int,write,int ,fd,const char *, buf, off_t ,count)
|
||||
#define MAX_NUMBER_BYTES 1024
|
||||
#define MSG_LEN 256
|
||||
|
||||
|
||||
int printf(const char *fmt,...)
|
||||
{
|
||||
write(2,fmt,strlen(fmt));
|
||||
}
|
||||
void test_getdents(void){
|
||||
int fd, nread, bpos;
|
||||
struct linux_dirent *dirp, *tmp;
|
||||
dirp = (struct linux_dirent *)buf;
|
||||
fd = open(".", O_RDONLY,0);
|
||||
nread = getdents(fd, dirp, 512);
|
||||
for(bpos = 0; bpos < nread;){
|
||||
printf("gasdg");
|
||||
tmp = (struct linux_dirent *)(buf + bpos);
|
||||
printf( tmp->d_name);
|
||||
bpos += tmp->d_reclen;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
test_getdents();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue