tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Trying to write a kernel module for (un)mounting tmpfs



Hi,

I'm trying to write a kernel module as example for mounting and unmounting tmpfs. For that, I read the mount_tmpfs code and in line 247 I found the call for mount() syscall here:
https://nxr.netbsd.org/xref/src/sbin/mount_tmpfs/mount_tmpfs.c#247

Then I looked for how the kernel mounts file systems and found there are _mount() function for every file system:
https://nxr.netbsd.org/xref/src/sys/sys/mount.h#254

Now, I just needed to know how to use tmpfs_mount() and find it here:
https://nxr.netbsd.org/xref/src/sys/fs/tmpfs/tmpfs_vfsops.c#86
but I still don't know how to use it. I created the struct tmpfs_args args and size_t args_len = sizeof args variables to pass to data and data_len arguments in tmpfs_mount(). And the directory I'm mounting is "/tmp". So, I have 3 of 4 arguments needed to tmpfs_mount(), the last one is the struct mount *mp.

I know the mount() syscall takes MOUNT_TMPFS as first argument, but I'm not understanding the magic behind struct mount mp and what I need to assign to the struct mount variable to pass it to that argument. Any hint?

Thanks for the help,

Bruno Melo.





Home | Main Index | Thread Index | Old Index