mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-19 05:31:14 +02:00
This change aims to make installations more unified and reliable. It introduces the concept of a mountpoint manager that is capable of mounting, unmounting, and moving a set of mountpoints in the correct order. Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
33 lines
915 B
Go
33 lines
915 B
Go
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package sysctl
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
// SystemProperty represents a kernel system property.
|
|
type SystemProperty struct {
|
|
Key string
|
|
Value string
|
|
}
|
|
|
|
// WriteSystemProperty writes a value to a key under /proc/sys.
|
|
func WriteSystemProperty(prop *SystemProperty) error {
|
|
return ioutil.WriteFile(prop.Path(), []byte(prop.Value), 0644)
|
|
}
|
|
|
|
// ReadSystemProperty reads a value from a key under /proc/sys.
|
|
func ReadSystemProperty(prop *SystemProperty) ([]byte, error) {
|
|
return ioutil.ReadFile(prop.Path())
|
|
}
|
|
|
|
// Path returns the path to the systctl file under /proc/sys.
|
|
func (prop *SystemProperty) Path() string {
|
|
return path.Join("/proc/sys", strings.Replace(prop.Key, ".", "/", -1))
|
|
}
|