use std::io::{Read, Write};
use tracing::debug;
use crate::protocol::rpc;
use crate::protocol::xdr::{self, deserialize, nfs3, Serialize};
pub async fn nfsproc3_pathconf(
xid: u32,
input: &mut impl Read,
output: &mut impl Write,
context: &rpc::Context,
) -> Result<(), anyhow::Error> {
let handle = deserialize::<nfs3::nfs_fh3>(input)?;
debug!("nfsproc3_pathconf({:?},{:?})", xid, handle);
let id = context.vfs.fh_to_id(&handle);
if let Err(stat) = id {
xdr::rpc::make_success_reply(xid).serialize(output)?;
stat.serialize(output)?;
nfs3::post_op_attr::None.serialize(output)?;
return Ok(());
}
let id = id.unwrap();
let obj_attr = context.vfs.getattr(id).await.ok();
let res = nfs3::fs::PATHCONF3resok {
obj_attributes: obj_attr,
linkmax: context.vfs.pathconf_linkmax(),
name_max: context.vfs.pathconf_name_max(),
no_trunc: context.vfs.pathconf_no_trunc(),
chown_restricted: context.vfs.pathconf_chown_restricted(),
case_insensitive: context.vfs.pathconf_case_insensitive(),
case_preserving: context.vfs.pathconf_case_preserving(),
};
debug!(" {:?} ---> {:?}", xid, res);
xdr::rpc::make_success_reply(xid).serialize(output)?;
nfs3::nfsstat3::NFS3_OK.serialize(output)?;
res.serialize(output)?;
Ok(())
}