[patch] Improved jail fstab functionality inside rc.d (needs testers and review)

Merijn Verstraaten merijn at inconsistent.nl
Sun Nov 29 16:05:52 UTC 2009


My apologies if these are the wrong lists for this sort of thing but it  
was unclear to me where else to go with additions like this.

I just finished hacking /etc/rc.d/jail to fix my two pet peeves, currently  
the rc framework only accepts a single fstab file per jail and (worse!)  
there is no way to specify the mountpoints in these fstab files relative  
to the jails root. This makes sharing of mounts (for example all my jails  
nullfs mounting the same ports tree) very cumbersome.

This patch should allow you to specify multiple fstab files in the  
jail_fstab and jail_<name>_fstab variables and mount these in order. In  
addition the patch mangles the fstab files in such a way that any  
mountpoint in the fstab files starting with the text "ROOT" will have  
"ROOT" replaced with the jails rootdir. For example the following  
situation:
rc.conf:
jail_test_rootdir="/usr/jails/test"
jail_test_fstab="/usr/jails/fstab /usr/jails/fstab.test"

/usr/jails/fstab:
/usr/ports	ROOT/usr/ports	nullfs	ro	0	0

/usr/jails/fstab.test
/path/to/some/folder	ROOT/folder	nullfs	rw	0	0

This should result in /path/to/some/folder being mounted into  
/usr/jails/test/folder and /usr/ports into /usr/jails/test/usr/ports.  
Normal mountpoints (i.e. not prefixed with ROOT) should still be mounted  
as normal.

Todo:
The code probably needs cleaning up, it tried to confirm to the style of  
the surrounding code, but I didn't know how to handle stuff which resulted  
in either lines longer then 80 chars or very ugly line wrapping. Someone  
more at home in the rc.d framework should probably clean the patch up a  
little to conform to the style. In addition the "ROOT" prefix is now  
hardcoded, perhaps this should be a configurable option (jail_prefix) or  
something instead.

If people have the time to review and/or test this patch I'd be grateful  
any comments/critiques are welcome. Please CC me when replying to this  
e-mail as I'm not currently subscribed to hackers@ or rc at .

Kind regards,
Merijn Verstraaten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jail.diff
Type: application/octet-stream
Size: 2122 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20091129/350c389d/jail.obj


More information about the freebsd-hackers mailing list