When callinig libc functions, i chech if the retured type is -1 and if it is, get the errno and return syscall::Error.
The code is literally same everytime I call a libc function.
if unsafe { libc::fchmod(inner, new_mode as i32) } == -1 {
let errno = unsafe { *libc::__errno_location() };
return Err(syscall::Error::new(errno));
}The only difference is the actual function call. Maybe I can use a macro or regular function.
Aside from the unimplemented syscalls, these are the things that I haven't consider yet while implementing the overlayfs.
Linux OverlayFS documentation has this to say about the permission model.
I have just ignored the CallerCtx passed to the syscalls until now.
I have only checked a few flags (like the access flags) here and there hoping that the libc call will handle it for me and return the appropriate error incase something goes wrong.
I also have not taken performance into consideration (be it memory or space).
Linux has various options that can be passed when mounting overlay. Those options change the way overlayfs behaves. Again, I have not taken them into consideration at all.
I've used unwraps in various place. Mostly they are used when converting from PathBuf to CString to pass *i8 to libc functions. I probably need to remove them at some point.