blob: cbe95eac49835220b46044598669111199fce3cc [file] [log] [blame]
// Copyright 2023 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::vfs::FsString;
use starnix_sync::RwLock;
use std::sync::Arc;
const DEFAULT_HOST_NAME: &str = "localhost";
const DEFAULT_DOMAIN_NAME: &str = "localdomain";
pub type UtsNamespaceHandle = Arc<RwLock<UtsNamespace>>;
// Unix Time-sharing Namespace (UTS) information.
// Stores the hostname and domainname for a specific process.
//
// See https://man7.org/linux/man-pages/man7/uts_namespaces.7.html
#[derive(Clone)]
pub struct UtsNamespace {
pub hostname: FsString,
pub domainname: FsString,
}
impl UtsNamespace {
pub fn fork(&self) -> UtsNamespaceHandle {
Arc::new(RwLock::new(self.clone()))
}
}
impl Default for UtsNamespace {
fn default() -> Self {
Self { hostname: DEFAULT_HOST_NAME.into(), domainname: DEFAULT_DOMAIN_NAME.into() }
}
}