MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / resolve_at

Function resolve_at

api/src/file/fs.rs:51–76  ·  view source on GitHub ↗
(dirfd: c_int, path: Option<&str>, flags: u32)

Source from the content-addressed store, hash-verified

49}
50
51pub 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
78pub fn metadata_to_kstat(metadata: &Metadata) -> Kstat {
79 let ty = metadata.node_type as u8;

Callers 7

sys_fstatatFunction · 0.85
sys_statxFunction · 0.85
sys_faccessat2Function · 0.85
sys_linkatFunction · 0.85
sys_fchownatFunction · 0.85
sys_fchmodatFunction · 0.85
update_timesFunction · 0.85

Calls 4

get_file_likeFunction · 0.85
FileClass · 0.85
with_fsFunction · 0.85
innerMethod · 0.45

Tested by

no test coverage detected