diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-28 22:43:25 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-28 22:43:25 +0900 |
| commit | 19c76e08315118b8595abb2d598658b04cf87f78 (patch) | |
| tree | d518f9954cb153de4730ff2fd0eba540515381a6 /cmd/sharefs | |
| parent | 71fcc972bad6abcd6282f7a80ef5935cdfcf172d (diff) | |
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>
Diffstat (limited to 'cmd/sharefs')
| -rw-r--r-- | cmd/sharefs/fuse.go | 31 | ||||
| -rw-r--r-- | cmd/sharefs/main.go | 7 |
2 files changed, 30 insertions, 8 deletions
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 ( |
