ext2: copy dirents to fixed-size array
This commit is contained in:
parent
78c3474c10
commit
82fca21452
1 changed files with 8 additions and 1 deletions
|
|
@ -700,10 +700,17 @@ static int ext2_readdir(struct vnode *vnode, struct dirent **out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy to a fixed-size array */
|
||||||
|
struct dirent *dirents = kmalloc(num_entries * sizeof(struct dirent), ALLOC_KERN);
|
||||||
|
for(int i = 0; i < num_entries; i++) {
|
||||||
|
dirents[i] = dir_arr[i];
|
||||||
|
}
|
||||||
|
kfree(dir_arr);
|
||||||
|
|
||||||
kfree(inode);
|
kfree(inode);
|
||||||
kfree(oentry);
|
kfree(oentry);
|
||||||
|
|
||||||
*out = dir_arr;
|
*out = dirents;
|
||||||
return num_entries;
|
return num_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue