(dirfd: c_int, path: Option<&str>, flags: u32)
| 49 | } |
| 50 | |
| 51 | pub fn resolve_at(dirfd: c_int, path: Option<&str>, flags: u32) -> AxResult<ResolveAtResult> { |
| 52 | match path { |
| 53 | Some("") | None => { |
| 54 | if flags & AT_EMPTY_PATH == 0 { |
| 55 | return Err(AxError::NotFound); |
| 56 | } |
| 57 | let file_like = get_file_like(dirfd)?; |
| 58 | let f = file_like.clone(); |
| 59 | Ok(if let Some(file) = f.downcast_ref::<File>() { |
| 60 | ResolveAtResult::File(file.inner().backend()?.location().clone()) |
| 61 | } else if let Some(dir) = f.downcast_ref::<Directory>() { |
| 62 | ResolveAtResult::File(dir.inner().clone()) |
| 63 | } else { |
| 64 | ResolveAtResult::Other(file_like) |
| 65 | }) |
| 66 | } |
| 67 | Some(path) => with_fs(dirfd, |fs| { |
| 68 | if flags & AT_SYMLINK_NOFOLLOW != 0 { |
| 69 | fs.resolve_no_follow(path) |
| 70 | } else { |
| 71 | fs.resolve(path) |
| 72 | } |
| 73 | .map(ResolveAtResult::File) |
| 74 | }), |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | pub fn metadata_to_kstat(metadata: &Metadata) -> Kstat { |
| 79 | let ty = metadata.node_type as u8; |
no test coverage detected