From 8bf2f2a1e65935f1672e9cbce2b65c304654c966 Mon Sep 17 00:00:00 2001 From: mse5gj3yn <780736178@qq.com> Date: Fri, 9 Jul 2021 00:10:27 +0800 Subject: [PATCH] ADD file via upload --- getdents_1.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 getdents_1.c diff --git a/getdents_1.c b/getdents_1.c new file mode 100644 index 0000000..ac64261 --- /dev/null +++ b/getdents_1.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +struct linux_dirent { + long d_ino; + off_t d_off; + unsigned short d_reclen; + char d_name[14]; +}; + +int sys_getdents(unsigned int fd, struct linux_dirent *d, unsigned int count) +{ + struct file *f; + struct m_inode * m; + struct buffer_head * b; + struct dir_entry * dir; + int i,j,k,res; + struct linux_dirent usrd; + i=0; + res=0; + f=current->filp[fd]; + m=f->f_inode; + b=bread(m->i_dev,m->i_zone[0]); + dir=(struct dir_entry*)b->b_data; + while(dir[i].inode>0) + { + if(res+sizeof(struct linux_dirent)>count) + break; + usrd.d_ino=dir[i].inode; + usrd.d_off=0; + usrd.d_reclen=sizeof(struct linux_dirent); + for(j=0;j<14;j++) + usrd.d_name[j]=dir[i].name[j]; + for(k=0;k