diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go index 8bf7230a..0e17d78c 100644 --- a/cmd/earlyinit/main.go +++ b/cmd/earlyinit/main.go @@ -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 import ( diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index 16c2cf82..dea07ede 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -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 import ( diff --git a/cmd/sharefs/fuse.go b/cmd/sharefs/fuse.go index e1e16d1a..f14cc998 100644 --- a/cmd/sharefs/fuse.go +++ b/cmd/sharefs/fuse.go @@ -85,7 +85,10 @@ func destroySetup(private_data unsafe.Pointer) (ok bool) { } //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() priv := (*C.struct_sharefs_private)(ctx.private_data) 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 // 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) goto fail } 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. setgid *C.char - // Decimal string representation of open file descriptor to read setupState from. - // This is an internal detail for containerisation and must not be specified directly. + // Decimal string representation of open file descriptor to read + // setupState from. + // + // This is an internal detail for containerisation and must not be + // specified directly. setup *C.char } @@ -253,7 +263,8 @@ func parseOpts(args *fuseArgs, setup *setupState, log *log.Logger) (ok bool) { 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 { if len(s) == 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) } // unsafeAddArgument adds an argument to fuseArgs via fuse_opt_add_arg. +// // The last byte of arg must be 0. func unsafeAddArgument(args *fuseArgs, arg string) { 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...) defer freeArgs(&args) - // this causes the kernel to enforce access control based on - // struct stat populated by sharefs_getattr + // this causes the kernel to enforce access control based on struct stat + // populated by sharefs_getattr unsafeAddArgument(&args, "-odefault_permissions\x00") 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.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 if fd, w, err := container.Setup(&z.ExtraFiles); err != nil { diff --git a/cmd/sharefs/main.go b/cmd/sharefs/main.go index c9fe9f2f..0e3072a5 100644 --- a/cmd/sharefs/main.go +++ b/cmd/sharefs/main.go @@ -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 import (