All of lore.kernel.org
 help / color / mirror / Atom feed
* default quota limits in linux (via quotactl())
@ 2003-01-27 14:41 Stefan (metze) Metzmacher
  2003-01-27 16:22 ` Stephen C. Tweedie
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan (metze) Metzmacher @ 2003-01-27 14:41 UTC (permalink / raw)
  To: viro
  Cc: linux-fsdevel, sct, akpm, adilger, ext2-devel, jfs-discussion,
	linux-xfs

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

Hi Alexander and *,

I would like linux to handle default quota limits like NTFS 5 do it.

So if a new user is added to the system and start to own disk space on a 
filesystem he
should get the default quotas for the specified FS as his own quotas.

Now a new user has unlimited disk space until root explicit sets quota 
limits for this user.

I have searched in google to find another unix witch allready implements 
this feature,
but I didn't find any. So I decided to add two (four) new cmd's to quotactl(),

Q_SETDEFQUOTA
Q_GETDEFQUOTA

and for the XFS Quotas

Q_XSETDEFQLIM
Q_XGETDEFQUOTA

this call should take the same paramter's as the Q_GETQUOTA /Q_XGETQUOTA ..
cmd's but the uid/gid should be ignored here and the filesystem defaults 
should be get or set.

I think this should be an easy task to be implemented in the filesystems 
witch allready support quotas.


I attach a patch witch modify the quotactl system call for this.

the implemetation inside the filesystems, should be done by the maintainers:-)

PS: I'm currently using XFS and it would be very cool if the default quota 
limits could implemented very fast...:-)

I hope I will get feedback :)

thanks anyway...

please cc me: in all replies:-)


metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <metze@metzemix.de> 

[-- Attachment #2: 2.5.59-defquota.diff --]
[-- Type: application/octet-stream, Size: 5785 bytes --]

diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/include/linux/dqblk_xfs.h linux-2.5.59-MX/include/linux/dqblk_xfs.h
--- linux-2.5.59/include/linux/dqblk_xfs.h	Fri Jan 17 03:22:26 2003
+++ linux-2.5.59-MX/include/linux/dqblk_xfs.h	Thu Jan 23 12:57:31 2003
@@ -46,7 +46,8 @@
 #define Q_XSETQLIM	XQM_CMD(0x4)	/* set disk limits */
 #define Q_XGETQSTAT	XQM_CMD(0x5)	/* get quota subsystem status */
 #define Q_XQUOTARM	XQM_CMD(0x6)	/* free disk space used by dquots */
-
+#define Q_XGETDEFQUOTA	XQM_CMD(0x7)	/* get default disk limits and usage */
+#define Q_XSETDEFQLIM	XQM_CMD(0x8)	/* set default disk limits */
 /*
  * fs_disk_quota structure:
  *
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/include/linux/quota.h linux-2.5.59-MX/include/linux/quota.h
--- linux-2.5.59/include/linux/quota.h	Fri Jan 17 03:22:25 2003
+++ linux-2.5.59-MX/include/linux/quota.h	Thu Jan 23 12:56:23 2003
@@ -80,14 +80,16 @@ extern spinlock_t dq_data_lock;
 #define SUBCMDSHIFT 8
 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
 
-#define Q_SYNC     0x800001	/* sync disk copy of a filesystems quotas */
-#define Q_QUOTAON  0x800002	/* turn quotas on */
-#define Q_QUOTAOFF 0x800003	/* turn quotas off */
-#define Q_GETFMT   0x800004	/* get quota format used on given filesystem */
-#define Q_GETINFO  0x800005	/* get information about quota files */
-#define Q_SETINFO  0x800006	/* set information about quota files */
-#define Q_GETQUOTA 0x800007	/* get user quota structure */
-#define Q_SETQUOTA 0x800008	/* set user quota structure */
+#define Q_SYNC		0x800001	/* sync disk copy of a filesystems quotas */
+#define Q_QUOTAON	0x800002	/* turn quotas on */
+#define Q_QUOTAOFF	0x800003	/* turn quotas off */
+#define Q_GETFMT	0x800004	/* get quota format used on given filesystem */
+#define Q_GETINFO	0x800005	/* get information about quota files */
+#define Q_SETINFO	0x800006	/* set information about quota files */
+#define Q_GETQUOTA	0x800007	/* get user quota structure */
+#define Q_SETQUOTA	0x800008	/* set user quota structure */
+#define Q_GETDEFQUOTA	0x800009	/* get default user quota structure */
+#define Q_SETDEFQUOTA	0x80000A	/* set default user quota structure */
 
 /*
  * Quota structure used for communication with userspace via quotactl
@@ -261,10 +263,14 @@ struct quotactl_ops {
 	int (*set_info)(struct super_block *, int, struct if_dqinfo *);
 	int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *);
 	int (*set_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *);
+	int (*get_defdqblk)(struct super_block *, int, struct if_dqblk *);
+	int (*set_defdqblk)(struct super_block *, int, struct if_dqblk *);
 	int (*get_xstate)(struct super_block *, struct fs_quota_stat *);
 	int (*set_xstate)(struct super_block *, unsigned int, int);
 	int (*get_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *);
 	int (*set_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *);
+	int (*get_xdefquota)(struct super_block *, int, struct fs_disk_quota *);
+	int (*set_xdefquota)(struct super_block *, int, struct fs_disk_quota *);
 };
 
 struct quota_format_type {
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/fs/quota.c linux-2.5.59-MX/fs/quota.c
--- linux-2.5.59/fs/quota.c	Fri Jan 17 03:22:48 2003
+++ linux-2.5.59-MX/fs/quota.c	Thu Jan 23 12:43:40 2003
@@ -50,6 +50,14 @@ static int check_quotactl_valid(struct s
 			if (!sb->s_qcop->get_dqblk)
 				return -ENOSYS;
 			break;
+		case Q_SETDEFQUOTA:
+			if (!sb->s_qcop->set_defdqblk)
+				return -ENOSYS;
+			break;
+		case Q_GETDEFQUOTA:
+			if (!sb->s_qcop->get_defdqblk)
+				return -ENOSYS;
+			break;
 		case Q_SYNC:
 			if (!sb->s_qcop->quota_sync)
 				return -ENOSYS;
@@ -72,6 +80,14 @@ static int check_quotactl_valid(struct s
 			if (!sb->s_qcop->get_xquota)
 				return -ENOSYS;
 			break;
+		case Q_XSETDEFQLIM:
+			if (!sb->s_qcop->set_xdefquota)
+				return -ENOSYS;
+			break;
+		case Q_XGETDEFQUOTA:
+			if (!sb->s_qcop->get_xdefquota)
+				return -ENOSYS;
+			break;
 		default:
 			return -EINVAL;
 	}
@@ -84,6 +100,8 @@ static int check_quotactl_valid(struct s
 		case Q_SETINFO:
 		case Q_SETQUOTA:
 		case Q_GETQUOTA:
+		case Q_SETDEFQUOTA:
+		case Q_GETDEFQUOTA:
 			/* This is just informative test so we are satisfied without a lock */
 			if (!sb_has_quota_enabled(sb, type))
 				return -ESRCH;
@@ -166,6 +184,22 @@ static int do_quotactl(struct super_bloc
 				return -EFAULT;
 			return sb->s_qcop->set_dqblk(sb, type, id, &idq);
 		}
+		case Q_GETDEFQUOTA: {
+			struct if_dqblk idq;
+
+			if ((ret = sb->s_qcop->get_defdqblk(sb, type, &idq)))
+				return ret;
+			if (copy_to_user(addr, &idq, sizeof(idq)))
+				return -EFAULT;
+			return 0;
+		}
+		case Q_SETDEFQUOTA: {
+			struct if_dqblk idq;
+
+			if (copy_from_user(&idq, addr, sizeof(idq)))
+				return -EFAULT;
+			return sb->s_qcop->set_defdqblk(sb, type, &idq);
+		}
 		case Q_SYNC:
 			return sb->s_qcop->quota_sync(sb, type);
 
@@ -198,6 +232,22 @@ static int do_quotactl(struct super_bloc
 			struct fs_disk_quota fdq;
 
 			if ((ret = sb->s_qcop->get_xquota(sb, type, id, &fdq)))
+				return ret;
+			if (copy_to_user(addr, &fdq, sizeof(fdq)))
+				return -EFAULT;
+			return 0;
+		}
+		case Q_XSETDEFQLIM: {
+			struct fs_disk_quota fdq;
+
+			if (copy_from_user(&fdq, addr, sizeof(fdq)))
+				return -EFAULT;
+		       return sb->s_qcop->set_xdefquota(sb, type, &fdq);
+		}
+		case Q_XGETDEFQUOTA: {
+			struct fs_disk_quota fdq;
+
+			if ((ret = sb->s_qcop->get_xdefquota(sb, type, &fdq)))
 				return ret;
 			if (copy_to_user(addr, &fdq, sizeof(fdq)))
 				return -EFAULT;

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-01-29 16:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-27 14:41 default quota limits in linux (via quotactl()) Stefan (metze) Metzmacher
2003-01-27 16:22 ` Stephen C. Tweedie
2003-01-28  6:43   ` Stefan (metze) Metzmacher
2003-01-28  6:54   ` Stefan (metze) Metzmacher
2003-01-28  9:32     ` Jan Hudec
     [not found]       ` <20030128094014.GA23257@f00f.org>
2003-01-28  9:46         ` Jan Hudec
     [not found]           ` <20030128101310.GA23320@f00f.org>
2003-01-28 10:57             ` Jan Hudec
     [not found]               ` <20030128112034.GA23731@f00f.org>
2003-01-28 12:37                 ` Jan Hudec
2003-01-28 13:32                   ` Stefan (metze) Metzmacher
2003-01-28 15:18                     ` Walt H
2003-01-28 15:27                       ` Stefan Metzmacher
2003-01-29 16:34                     ` Juan Quintela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.