Skip to content

Instantly share code, notes, and snippets.

@durka
Created July 28, 2017 16:02
Show Gist options
  • Save durka/fb0ff64d8aabb82f0bc81c4102ded8ab to your computer and use it in GitHub Desktop.
Save durka/fb0ff64d8aabb82f0bc81c4102ded8ab to your computer and use it in GitHub Desktop.
fn remote_df2(SshInfo { user, pass, host, dir }: SshInfo) -> Result<Bytes> {
let (tcp, sess) = ssh(user, pass, host)?;
let sftp = sess.sftp()?;
let file = sftp.open(Path::new(dir))?;
unsafe {
let mut handle = mem::transmute_copy::<ssh2::File, *mut LIBSSH2_SFTP_HANDLE>(&file);
let mut attrs: LIBSSH2_SFTP_STATVFS = mem::zeroed();
sftp.rc(libssh2_sftp_fstatvfs(handle, &mut attrs))?;
Ok(Bytes(attrs.f_bavail * attrs.f_bsize))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment