You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
836 B
31 lines
836 B
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;
|
|
}
|