master
forever-learner 2 years ago
parent 5c511e5d91
commit 8e2f60b4e7

@ -110,14 +110,14 @@ int sys_getdents(unsigned int fd,struct linux_dirent *dirp,unsigned int count)
struct linux_dirent *initmp,*temp; struct linux_dirent *initmp,*temp;
char *foruse; char *foruse;
if(!(temp=(struct linux_dirent *)malloc(count+64))) if(!(temp=(struct linux_dirent *)malloc(count+64)))
return NULL; return -1;
initmp=temp; initmp=temp;
int size=sizeof(long)+sizeof(off_t)+sizeof(unsigned short); int size=sizeof(long)+sizeof(off_t)+sizeof(unsigned short);
if (!(block = filenode->i_zone[0])) if (!(block = filenode->i_zone[0]))
return NULL; return -1;
if (!(bh = bread(filenode->i_dev,block))) if (!(bh = bread(filenode->i_dev,block)))
return NULL; return -1;
de = (struct dir_entry *) bh->b_data; de = (struct dir_entry *) bh->b_data;
entries=filenode->i_size/(sizeof(struct dir_entry)); entries=filenode->i_size/(sizeof(struct dir_entry));
i=0; i=0;
@ -132,13 +132,13 @@ int sys_getdents(unsigned int fd,struct linux_dirent *dirp,unsigned int count)
i += DIR_ENTRIES_PER_BLOCK; i += DIR_ENTRIES_PER_BLOCK;
continue; continue;
} }
pos+=((struct dir_entry *) bh->b_data-(de-1))*sizdir; pos+=((char*) bh->b_data-(char*)(de-1));
de = (struct dir_entry *) bh->b_data; de = (struct dir_entry *) bh->b_data;
} }
temp->d_ino=de->inode; temp->d_ino=de->inode;
temp->d_off=pos; temp->d_off=pos;
strcpy(temp->d_name,de->name); strcpy(temp->d_name,de->name);
temp->d_reclen=size+sizeof(de->name); temp->d_reclen=size+strlen(de->name)+1;
nread+=temp->d_reclen; nread+=temp->d_reclen;
foruse=(char*)temp; foruse=(char*)temp;
foruse+=temp->d_reclen; foruse+=temp->d_reclen;
@ -151,7 +151,7 @@ int sys_getdents(unsigned int fd,struct linux_dirent *dirp,unsigned int count)
{ {
errno=ERANGE; errno=ERANGE;
return -1; return -1;
} }//printk("%d",nread);
i=nread; i=nread;
char *p1=dirp; char *p1=dirp;
char *p2=initmp; char *p2=initmp;

Binary file not shown.
Loading…
Cancel
Save