Implement fpath in initfs

This commit is contained in:
Jeremy Soller 2016-09-22 21:13:17 -06:00
parent d5ac1a70bd
commit 0d762918e2
4 changed files with 65 additions and 12 deletions

View file

@ -98,6 +98,24 @@ pub fn dup(fd: usize) -> Result<usize> {
scheme.dup(file.number)
}
/// Get the canonical path of the file
pub fn fpath(fd: usize, buf: &mut [u8]) -> Result<usize> {
let file = {
let contexts = context::contexts();
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
let context = context_lock.read();
let file = context.get_file(fd).ok_or(Error::new(EBADF))?;
file
};
let scheme = {
let schemes = scheme::schemes();
let scheme = schemes.get(file.scheme).ok_or(Error::new(EBADF))?;
scheme.clone()
};
scheme.fpath(file.number, buf)
}
/// Get information about the file
pub fn fstat(fd: usize, stat: &mut Stat) -> Result<usize> {
let file = {