starnix_core/task/
uts_namespace.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::vfs::FsString;
6use starnix_sync::RwLock;
7use std::sync::Arc;
8
9const DEFAULT_HOST_NAME: &str = "localhost";
10const DEFAULT_DOMAIN_NAME: &str = "localdomain";
11
12pub type UtsNamespaceHandle = Arc<RwLock<UtsNamespace>>;
13
14// Unix Time-sharing Namespace (UTS) information.
15// Stores the hostname and domainname for a specific process.
16//
17// See https://man7.org/linux/man-pages/man7/uts_namespaces.7.html
18#[derive(Clone)]
19pub struct UtsNamespace {
20    pub hostname: FsString,
21    pub domainname: FsString,
22}
23
24impl UtsNamespace {
25    pub fn fork(&self) -> UtsNamespaceHandle {
26        Arc::new(RwLock::new(self.clone()))
27    }
28}
29
30impl Default for UtsNamespace {
31    fn default() -> Self {
32        Self { hostname: DEFAULT_HOST_NAME.into(), domainname: DEFAULT_DOMAIN_NAME.into() }
33    }
34}