Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

EX-1932 handle softlinks for llapi queries #2325

Merged
merged 4 commits into from
Oct 14, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion liblustreapi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
ffi::{CStr, CString},
fmt, io,
num::ParseIntError,
os::unix::ffi::OsStrExt,
path::PathBuf,
str::FromStr,
sync::Arc,
Expand Down Expand Up @@ -305,7 +306,13 @@ impl Llapi {
}

pub fn search_fsname(&self, pathname: &str) -> Result<String, LiblustreError> {
let fsc = CString::new(pathname.as_bytes())?;
let mut path = PathBuf::from(pathname);
let md = std::fs::symlink_metadata(&path)?;
if md.file_type().is_symlink() {
path.pop();
}

let fsc = CString::new(path.clone().into_os_string().as_bytes())?;
jgrund marked this conversation as resolved.
Show resolved Hide resolved
let mut fsname: Vec<u8> = vec![0; std::mem::size_of::<u8>() * MAXFSNAME + 1];
let ptr = fsname.as_mut_ptr() as *mut libc::c_char;

Expand Down