.Dd May 21, 2024 .Dt MOUNT 2 .Os Camellia .Sh NAME .Nm mount .Nd mount a filesystem .Sh SYNOPSIS .In camellia/syscalls.h .In camellia/types.h .Ft long .Fo _sys_mount .Fa "hid_t hid" .Fa "const char *mpoint" .Fa "long len" .Fc .Sh DESCRIPTION .Nm mounts the filesystem pointed to by .Fa hid at .Fa mpoint , which is a string of length .Fa len . Unless overridden by a future .Nm mount , all .Xr open 2 calls under that path in the current process will be handled by the chosen filesystem. Other processes are unaffected \(em in particular, children forked off before the mount call retain their old view of the filesystem. .Pp The filesystem handle, .Fa hid , can come from a .Xr fork 2 call with the .Dv FORK_NEWFS flag, or from .Xr getprocfs 2 . If the handle isn't a valid filesystem, all .Xr open 2 calls under .Fa mpoint will fail. This can be used to deny access to a path \(em for that purpose, you can use a .Fa hid of -1, which will never be a valid handle. .Sh EXAMPLES To mount a child under a path: .Bd -literal -offset indent #include #include #include #include hid_t h; if (_sys_fork(FORK_NEWFS, &h) == 0) { // lacks error checking! do_child_stuff(); exit(1); } _sys_mount(h, "/path/", strlen("/path")); .Ed .Pp However, ideally you'd use the .Xr MOUNT_AT 3 macro instead: .Bd -literal -offset indent #include MOUNT_AT("/path/") { do_child_stuff(); // will automatically exit() if do_child_stuff() returns } .Ed .Pp To deny access to a path, you can run .Bd -literal -offset indent _sys_mount(-1, path, strlen(path)); .Ed .Sh SEE ALSO .Xr fork 2 , .Xr getprocfs 2 , .Xr open 2 , .Xr path 7