resolve_at_path_with_flags

Function resolve_at_path_with_flags 

Source
pub fn resolve_at_path_with_flags(
    dirfd: i32,
    path: &str,
    follow_symlink: bool,
) -> Result<Arc<Dentry>, FsError>
Expand description

根据 dirfd 和路径解析 dentry,支持符号链接控制

这是对 resolve_at_path 的扩展,支持控制是否跟随最后一个符号链接。

§参数

  • dirfd - 目录文件描述符(AT_FDCWD 表示当前目录)
  • path - 文件路径
  • follow_symlink - 是否跟随最后一个符号链接

§返回值

  • Ok(Arc<Dentry>) - 成功找到文件
  • Err(FsError) - 查找失败

§示例

// 跟随符号链接(默认行为)
let dentry = resolve_at_path_with_flags(AT_FDCWD, "/path/to/file", true)?;

// 不跟随符号链接(用于 lstat, lchown 等)
let dentry = resolve_at_path_with_flags(AT_FDCWD, "/path/to/symlink", false)?;