From 01df2eb619b29802116b5f3b88212374c8b8ad92 Mon Sep 17 00:00:00 2001 From: pm8fuclqg <2672033573@qq.com> Date: Sun, 26 Jun 2022 20:31:46 +0800 Subject: [PATCH] ADD file via upload --- getdents.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 getdents.c diff --git a/getdents.c b/getdents.c new file mode 100644 index 0000000..0f7ed2e --- /dev/null +++ b/getdents.c @@ -0,0 +1,30 @@ +int sys_getdents(unsigned int fd,struct linux_dirent *dirp,unsigned int count) +{ + struct buffer_head *bh; + struct m_inode*inode=current->filp[fd]->f_inode; + struct linux_dirent m; + struct dir_entry *dir; + char *buf; + int k,n=0,i; + if(count<=0)return -1; + bh=bread(inode->i_dev,inode->i_zone[0]); + for(k=0;ki_size;k+=sizeof(struct linux_dirent)) + { + if(n+sizeof(struct linux_dirent)>count)return 0; + dir=(struct dir_entry*)(bh->b_data+k); + if(dir->inode) + { + m.d_ino=dir->inode; + for(i=0;iname[i]; + m.d_off=0; + m.d_reclen=sizeof(struct linux_dirent); + buf=&m; + for(i=0;i