From b5532eb4bca97c308b4854f5a052e08384542812 Mon Sep 17 00:00:00 2001 From: prnmxfqg4 Date: Thu, 7 Jul 2022 12:47:20 +0800 Subject: [PATCH] Delete 'myls.c' --- myls.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 myls.c diff --git a/myls.c b/myls.c deleted file mode 100644 index 1946ddc..0000000 --- a/myls.c +++ /dev/null @@ -1,47 +0,0 @@ -#define __LIBRARY__ -#include -#include -#include -#include -#include -#include -#include -#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; -}