After trying to port vsftpd, I realized I was on the wrong way. It would be a messy work. And Samba would even be much larger. So another change of plan. Why not making a new file system? Then all servers could just write to the PRFS file system (Protected Revertible File System) without having to modify the server software!
The ‘easiest’ way is to make a kernel module. This can be loaded on the fly.
After reading and compiling some tutorials and compiling https://blog.sourcerer.io/writing-a-simple-linux-kernel-module-d9dc3762c234, I was ready for the real work.
I have taken a file system which (transparently) reads a TAR file, as was it a file system: https://github.com/Papierkorb/tarfs
Raspbian OS seems to bit a little ‘off’. So I had to change a few things (with a lot of Googling and a little logical thinking):
- The way to install the header files is: sudo apt-get install raspberrypi-kernel-headers
- In tar.h and tar.c
- timespec -> timespec64
- kstrtoul -> kstrtoll
- In driver.c
- MS_RDONLY | MS_NOATIME -> SB_RDONLY | SB_NOATIME
- Adding struct timespec64 CURRENT_TIME; and ktime_get_real_ts64(&CURRENT_TIME);
- First parameter added: inode_init_owner(sb->s_user_ns, root, NULL, ROOT_INO_MODE);
- Last parameter added: static struct posix_acl *tarfs_get_acl(struct inode *inode, int flags, bool rcu)
- .readlink = generic_readlink -> .readlink = vfs_readlink
I have mounted the kernel module and it works!
Next step is to make it read from a normal (mounted) file system.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.