[PATCH] Root squash option for quotas

From: Topi Miettinen (Topi.Miettinen@nic.fi)
Date: Wed May 24 2000 - 13:29:31 EST


(Please cc: me, I'm not subscribed.)

It's possible to use quotas also for root account using "rsquash" mount option
(actually parsed by quotaon). It seems that some tweaks are still needed:
correcting the id check and properly ignoring the mount option. The patch
should be obvious. It's against 2.2.15, but seems to apply to 2.3.99 with
little fuzz.

With the patch:
# quota -v
Disk quotas for user root (uid 0):
     Filesystem blocks quota limit grace files quota limit grace
/dev/ide/host0/bus0/target0/lun0/part3
                      0 1 1 0 1 1
# ls > quotatest
ls: write error: Disk quota exceeded

Note that this shell doesn't have CAP_SYS_RESOURCE, otherwise write would
succeed. It's unfortunate that the capability to setup quotas and the
capability to override them are the same. The former is needed for boot
sequence, the latter can be removed from production systems.

-Topi

diff -ru fs/dquot.c.orig fs/dquot.c
--- fs/dquot.c.orig Mon May 8 23:39:53 2000
+++ fs/dquot.c Mon May 8 23:40:09 2000
@@ -953,7 +953,7 @@
         if ((dquot = dqget(dev, id, type)) != NODQUOT) {
                 lock_dquot(dquot);
 
- if (id > 0 && ((flags & SET_QUOTA) || (flags & SET_QLIMIT))) {
+ if (id >= 0 && ((flags & SET_QUOTA) || (flags & SET_QLIMIT))) {
                         dquot->dq_bhardlimit = dq_dqblk.dqb_bhardlimit;
                         dquot->dq_bsoftlimit = dq_dqblk.dqb_bsoftlimit;
                         dquot->dq_ihardlimit = dq_dqblk.dqb_ihardlimit;
diff -ru fs/ext2/super.c.orig fs/ext2/super.c
--- fs/ext2/super.c.orig Mon Aug 9 22:04:41 1999
+++ fs/ext2/super.c Mon May 8 23:41:35 2000
@@ -263,7 +263,8 @@
                 else if (!strcmp (this_char, "grpquota")
                          || !strcmp (this_char, "noquota")
                          || !strcmp (this_char, "quota")
- || !strcmp (this_char, "usrquota"))
+ || !strcmp (this_char, "usrquota")
+ || !strcmp (this_char, "rsquash"))
                         /* Don't do anything ;-) */ ;
                 else {
                         printk ("EXT2-fs: Unrecognized mount option %s\n", this_char);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:12 EST