ADD file via upload

master
pm8fuclqg 2 years ago
parent 99391e49bf
commit 01df2eb619

@ -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;k<inode->i_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;i<NAME_LEN;i++)m.d_name[i]=dir->name[i];
m.d_off=0;
m.d_reclen=sizeof(struct linux_dirent);
buf=&m;
for(i=0;i<m.d_reclen;i++)
put_fs_byte(*(buf+i),(char*)(dirp)+n+i);
n+=sizeof(struct linux_dirent);
}
else continue;
}
brelse(bh);
return n;
}
Loading…
Cancel
Save