ext2: slightly clean up indirect read/alloc
This commit is contained in:
parent
f8d84c7780
commit
0a1b73edc2
4 changed files with 275 additions and 169 deletions
14
fs/vfs.c
14
fs/vfs.c
|
|
@ -64,6 +64,20 @@ int read(int fd, void *buf, size_t count)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int statfd(int fd, struct statbuf *statbuf)
|
||||
{
|
||||
struct rbnode *fdnode = rbt_search(kfd, fd);
|
||||
|
||||
if (!fdnode)
|
||||
return -EBADF;
|
||||
|
||||
struct file_descriptor *fdesc = (struct file_descriptor *)fdnode->value;
|
||||
|
||||
statbuf->size = fdesc->file.size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open(const char *pathname, int flags)
|
||||
{
|
||||
/* allocate a file descriptor */
|
||||
|
|
|
|||
Loading…
Reference in a new issue