forked from rosa/hakurei
cmd: document Rosa OS programs
The earlyinit and mbf program are not covered by the compatibility promise, so specify that here. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
// The earlyinit is part of the Rosa OS initramfs and serves as the system init.
|
||||||
|
//
|
||||||
|
// This program is an internal detail of Rosa OS and is not usable on its own.
|
||||||
|
// It is not covered by the compatibility promise.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
// The mbf program is a frontend for [hakurei.app/internal/rosa].
|
||||||
|
//
|
||||||
|
// This program is not covered by the compatibility promise. The command line
|
||||||
|
// interface, available packages and their behaviour, and even the on-disk
|
||||||
|
// format, may change at any time.
|
||||||
|
//
|
||||||
|
// # Name
|
||||||
|
//
|
||||||
|
// The name mbf stands for maiden's best friend, as a tribute to the DOOM source
|
||||||
|
// port of [the same name]. This name is a placeholder and is subject to change.
|
||||||
|
//
|
||||||
|
// [the same name]: https://www.doomwiki.org/wiki/MBF
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -85,7 +85,10 @@ func destroySetup(private_data unsafe.Pointer) (ok bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export sharefs_init
|
//export sharefs_init
|
||||||
func sharefs_init(_ *C.struct_fuse_conn_info, cfg *C.struct_fuse_config) unsafe.Pointer {
|
func sharefs_init(
|
||||||
|
_ *C.struct_fuse_conn_info,
|
||||||
|
cfg *C.struct_fuse_config,
|
||||||
|
) unsafe.Pointer {
|
||||||
ctx := C.fuse_get_context()
|
ctx := C.fuse_get_context()
|
||||||
priv := (*C.struct_sharefs_private)(ctx.private_data)
|
priv := (*C.struct_sharefs_private)(ctx.private_data)
|
||||||
setup := cgo.Handle(priv.setup).Value().(*setupState)
|
setup := cgo.Handle(priv.setup).Value().(*setupState)
|
||||||
@@ -103,7 +106,11 @@ func sharefs_init(_ *C.struct_fuse_conn_info, cfg *C.struct_fuse_config) unsafe.
|
|||||||
cfg.negative_timeout = 0
|
cfg.negative_timeout = 0
|
||||||
|
|
||||||
// all future filesystem operations happen through this dirfd
|
// all future filesystem operations happen through this dirfd
|
||||||
if fd, err := syscall.Open(setup.Source.String(), syscall.O_DIRECTORY|syscall.O_RDONLY|syscall.O_CLOEXEC, 0); err != nil {
|
if fd, err := syscall.Open(
|
||||||
|
setup.Source.String(),
|
||||||
|
syscall.O_DIRECTORY|syscall.O_RDONLY|syscall.O_CLOEXEC,
|
||||||
|
0,
|
||||||
|
); err != nil {
|
||||||
log.Printf("cannot open %q: %v", setup.Source, err)
|
log.Printf("cannot open %q: %v", setup.Source, err)
|
||||||
goto fail
|
goto fail
|
||||||
} else if err = syscall.Fchdir(fd); err != nil {
|
} else if err = syscall.Fchdir(fd); err != nil {
|
||||||
@@ -169,8 +176,11 @@ func parseOpts(args *fuseArgs, setup *setupState, log *log.Logger) (ok bool) {
|
|||||||
// Decimal string representation of gid to set when running as root.
|
// Decimal string representation of gid to set when running as root.
|
||||||
setgid *C.char
|
setgid *C.char
|
||||||
|
|
||||||
// Decimal string representation of open file descriptor to read setupState from.
|
// Decimal string representation of open file descriptor to read
|
||||||
// This is an internal detail for containerisation and must not be specified directly.
|
// setupState from.
|
||||||
|
//
|
||||||
|
// This is an internal detail for containerisation and must not be
|
||||||
|
// specified directly.
|
||||||
setup *C.char
|
setup *C.char
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +263,8 @@ func parseOpts(args *fuseArgs, setup *setupState, log *log.Logger) (ok bool) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyArgs returns a heap allocated copy of an argument slice in fuse_args representation.
|
// copyArgs returns a heap allocated copy of an argument slice in fuse_args
|
||||||
|
// representation.
|
||||||
func copyArgs(s ...string) fuseArgs {
|
func copyArgs(s ...string) fuseArgs {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return fuseArgs{argc: 0, argv: nil, allocated: 0}
|
return fuseArgs{argc: 0, argv: nil, allocated: 0}
|
||||||
@@ -269,6 +280,7 @@ func copyArgs(s ...string) fuseArgs {
|
|||||||
func freeArgs(args *fuseArgs) { C.fuse_opt_free_args(args) }
|
func freeArgs(args *fuseArgs) { C.fuse_opt_free_args(args) }
|
||||||
|
|
||||||
// unsafeAddArgument adds an argument to fuseArgs via fuse_opt_add_arg.
|
// unsafeAddArgument adds an argument to fuseArgs via fuse_opt_add_arg.
|
||||||
|
//
|
||||||
// The last byte of arg must be 0.
|
// The last byte of arg must be 0.
|
||||||
func unsafeAddArgument(args *fuseArgs, arg string) {
|
func unsafeAddArgument(args *fuseArgs, arg string) {
|
||||||
C.fuse_opt_add_arg(args, (*C.char)(unsafe.Pointer(unsafe.StringData(arg))))
|
C.fuse_opt_add_arg(args, (*C.char)(unsafe.Pointer(unsafe.StringData(arg))))
|
||||||
@@ -288,8 +300,8 @@ func _main(s ...string) (exitCode int) {
|
|||||||
args := copyArgs(s...)
|
args := copyArgs(s...)
|
||||||
defer freeArgs(&args)
|
defer freeArgs(&args)
|
||||||
|
|
||||||
// this causes the kernel to enforce access control based on
|
// this causes the kernel to enforce access control based on struct stat
|
||||||
// struct stat populated by sharefs_getattr
|
// populated by sharefs_getattr
|
||||||
unsafeAddArgument(&args, "-odefault_permissions\x00")
|
unsafeAddArgument(&args, "-odefault_permissions\x00")
|
||||||
|
|
||||||
var priv C.struct_sharefs_private
|
var priv C.struct_sharefs_private
|
||||||
@@ -453,7 +465,10 @@ func _main(s ...string) (exitCode int) {
|
|||||||
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
}
|
}
|
||||||
z.Bind(z.Path, z.Path, 0)
|
z.Bind(z.Path, z.Path, 0)
|
||||||
setup.Fuse = int(proc.ExtraFileSlice(&z.ExtraFiles, os.NewFile(uintptr(C.fuse_session_fd(se)), "fuse")))
|
setup.Fuse = int(proc.ExtraFileSlice(
|
||||||
|
&z.ExtraFiles,
|
||||||
|
os.NewFile(uintptr(C.fuse_session_fd(se)), "fuse"),
|
||||||
|
))
|
||||||
|
|
||||||
var setupWriter io.WriteCloser
|
var setupWriter io.WriteCloser
|
||||||
if fd, w, err := container.Setup(&z.ExtraFiles); err != nil {
|
if fd, w, err := container.Setup(&z.ExtraFiles); err != nil {
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
// The sharefs FUSE filesystem is a permissionless shared filesystem.
|
||||||
|
//
|
||||||
|
// This filesystem is the primary means of file sharing between hakurei
|
||||||
|
// application containers. It serves the same purpose in Rosa OS as /sdcard
|
||||||
|
// does in AOSP.
|
||||||
|
//
|
||||||
|
// See help message for all available options.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user