mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
fix portable build
This commit is contained in:
committed by
Aiden McClelland
parent
2384e60d0f
commit
1ef6099ab5
@@ -13,10 +13,27 @@ use tracing::instrument;
|
|||||||
|
|
||||||
use super::FileSystem;
|
use super::FileSystem;
|
||||||
use crate::disk::mount::guard::TmpMountGuard;
|
use crate::disk::mount::guard::TmpMountGuard;
|
||||||
use crate::net::mdns::resolve_mdns;
|
|
||||||
use crate::util::Invoke;
|
use crate::util::Invoke;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
|
async fn resolve_hostname(hostname: &str) -> Result<IpAddr, Error> {
|
||||||
|
#[cfg(feature = "avahi")]
|
||||||
|
if hostname.ends_with(".local") {
|
||||||
|
return Ok(crate::net::mdns::resolve_mdns(hostname).await?);
|
||||||
|
}
|
||||||
|
Ok(String::from_utf8(
|
||||||
|
Command::new("nmblookup")
|
||||||
|
.arg(hostname)
|
||||||
|
.invoke(crate::ErrorKind::Network)
|
||||||
|
.await?,
|
||||||
|
)?
|
||||||
|
.split(" ")
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.trim()
|
||||||
|
.parse()?)
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip(path, password, mountpoint))]
|
#[instrument(skip(path, password, mountpoint))]
|
||||||
pub async fn mount_cifs(
|
pub async fn mount_cifs(
|
||||||
hostname: &str,
|
hostname: &str,
|
||||||
@@ -26,21 +43,7 @@ pub async fn mount_cifs(
|
|||||||
mountpoint: impl AsRef<Path>,
|
mountpoint: impl AsRef<Path>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
tokio::fs::create_dir_all(mountpoint.as_ref()).await?;
|
tokio::fs::create_dir_all(mountpoint.as_ref()).await?;
|
||||||
let ip: IpAddr = if hostname.ends_with(".local") {
|
let ip: IpAddr = resolve_hostname(hostname).await?;
|
||||||
resolve_mdns(hostname).await?
|
|
||||||
} else {
|
|
||||||
String::from_utf8(
|
|
||||||
Command::new("nmblookup")
|
|
||||||
.arg(hostname)
|
|
||||||
.invoke(crate::ErrorKind::Network)
|
|
||||||
.await?,
|
|
||||||
)?
|
|
||||||
.split(" ")
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.trim()
|
|
||||||
.parse()?
|
|
||||||
};
|
|
||||||
let absolute_path = Path::new("/").join(path.as_ref());
|
let absolute_path = Path::new("/").join(path.as_ref());
|
||||||
Command::new("mount")
|
Command::new("mount")
|
||||||
.arg("-t")
|
.arg("-t")
|
||||||
|
|||||||
Reference in New Issue
Block a user