Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Nov 2009 17:05:03 +0100
From:      "Merijn Verstraaten" <merijn@inconsistent.nl>
To:        freebsd-hackers@freebsd.org, freebsd-rc@freebsd.org
Subject:   [patch] Improved jail fstab functionality inside rc.d (needs testers and review)
Message-ID:  <op.u35yya1v4534sa@localhost>

next in thread | raw e-mail | index | archive | help
------------Tq9rcKATAuiMEk3Wt5nWRG
Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit

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@.

Kind regards,
Merijn Verstraaten
------------Tq9rcKATAuiMEk3Wt5nWRG
Content-Disposition: attachment; filename=jail.diff
Content-Type: application/octet-stream; name=jail.diff
Content-Transfer-Encoding: Base64

LS0tIC9ldGMvcmMuZC9qYWlsCTIwMDktMTEtMjkgMTQ6NTc6NTEuOTAzODQwNDg4
ICswMTAwCisrKyBqYWlsCTIwMDktMTEtMjkgMTY6Mjg6NTAuNDcxMzU0MjM2ICsw
MTAwCkBAIC0zMDIsMTQgKzMwMiwxNyBAQAogCQlmaQogCWZpCiAJaWYgY2hlY2t5
ZXNubyBfbW91bnQ7IHRoZW4KLQkJWyAtZiAiJHtfZnN0YWJ9IiBdIHx8IHdhcm4g
IiR7X2ZzdGFifSBkb2VzIG5vdCBleGlzdCIKLQkJdGFpbCAtciAke19mc3RhYn0g
fCB3aGlsZSByZWFkIF9kZXZpY2UgX21vdW50cHQgX3Jlc3Q7IGRvCi0JCQljYXNl
ICI6JHtfZGV2aWNlfSIgaW4KLQkJCTojKiB8IDopCi0JCQkJY29udGludWUKLQkJ
CQk7OwotCQkJZXNhYwotCQkJc2VjdXJlX3Vtb3VudCAke19tb3VudHB0fQorCQlm
b3IgX2ZzdGFiX2ZpbGUgaW4gJHtfZnN0YWJ9OyBkbworCQkJWyAtZiAiJHtfZnN0
YWJfZmlsZX0iIF0gfHwgd2FybiAiJHtfZnN0YWJfZmlsZX0gZG9lcyBub3QgZXhp
c3QiCisJCQlzZWQgInMjUk9PVCMke19yb290ZGlyfSMiICR7X2ZzdGFiX2ZpbGV9
IHwKKwkJCSAgICB0YWlsIC1yIHwgd2hpbGUgcmVhZCBfZGV2aWNlIF9tb3VudHB0
IF9yZXN0OyBkbworCQkJCWNhc2UgIjoke19kZXZpY2V9IiBpbgorCQkJCTojKiB8
IDopCisJCQkJCWNvbnRpbnVlCisJCQkJCTs7CisJCQkJZXNhYworCQkJCXNlY3Vy
ZV91bW91bnQgJHtfbW91bnRwdH0KKw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n0iCisJZG9uZSA8JHtfZnN0YWJfZmlsZX0KKwlz
ZWQgInMjUk9PVCMke19yb290ZGlyfSMiICR7X2ZzdGFiX2ZpbGV9IHwgbW91bnQg
LWEgLUYgL2Rldi9zdGRpbgogfQogCiAjIGphaWxfc2hvd19hZGRyZXNzZXMgamFp
bApAQCAtNTc1LDEwICs1ODQsMTIgQEAKIAkJZmkKIAkJaWYgY2hlY2t5ZXNubyBf
bW91bnQ7IHRoZW4KIAkJCWluZm8gIk1vdW50aW5nIGZzdGFiIGZvciBqYWlsICR7
X2phaWx9ICgke19mc3RhYn0pIgotCQkJaWYgWyAhIC1mICIke19mc3RhYn0iIF07
IHRoZW4KLQkJCQllcnIgMyAiJG5hbWU6ICR7X2ZzdGFifSBkb2VzIG5vdCBleGlz
dCIKLQkJCWZpCi0JCQlqYWlsX21vdW50X2ZzdGFiCisJCQlmb3IgX2ZzdGFiX2Zp
bGUgaW4gJHtfZnN0YWJ9OyBkbworCQkJCWlmIFsgISAtZiAiJHtfZnN0YWJfZmls
ZX0iIF07IHRoZW4KKwkJCQkJZXJyIDMgIiRuYW1lOiAke19mc3RhYl9maWxlfSBk
b2VzIG5vdCBleGlzdCIKKwkJCQlmaQorCQkJCWphaWxfbW91bnRfZnN0YWIgJHtf
ZnN0YWJfZmlsZX0KKwkJCWRvbmUKIAkJZmkKIAkJaWYgY2hlY2t5ZXNubyBfZGV2
ZnM7IHRoZW4KIAkJCSMgSWYgZGV2ZnMgaXMgYWxyZWFkeSBtb3VudGVkIGhlcmUs
IHNraXAgaXQuCg==

------------Tq9rcKATAuiMEk3Wt5nWRG--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.u35yya1v4534sa>