summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2002-11-12 17:02:59 +0000
committerjkar8572 <jkar8572>2002-11-12 17:02:59 +0000
commit9bdd6236879ea379758f82ad5cec7033f0a751ac (patch)
tree87405ba01393a506d51f676766d0be96bc56d50a
parentf99565556d35c0a5800b39386e4b507ae3563bba (diff)
downloadlinuxquota-9bdd6236879ea379758f82ad5cec7033f0a751ac.tar.gz
Commited XFS patch by Christoph Hellwig
-rw-r--r--Changelog5
-rw-r--r--configure.in7
-rw-r--r--quotactl.28
-rw-r--r--quotaon.842
-rw-r--r--quotaon_xfs.c45
-rw-r--r--quotasys.c10
6 files changed, 73 insertions, 44 deletions
diff --git a/Changelog b/Changelog
index 77d8cb9..d43a756 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,8 @@
+Changes in quota-tools from 3.07 to 3.08
+* Fixed bug in convertquota(8) when quota was turned on during converting (Jan Kara)
+* Add support for XFS filesystems without root special casing (Christoph Hellwig)
+* XFS documentation updates (Nathan Scott)
+
Changes in quota-tools from 3.06 to 3.07
* Added creation of bin and sbin dir during make install; removed hardcoded
/sbin directory for some utilities. (Jan Kara)
diff --git a/configure.in b/configure.in
index 621608f..d46c318 100644
--- a/configure.in
+++ b/configure.in
@@ -93,6 +93,10 @@ AC_ARG_ENABLE(rpcsetquota,
[ --enable-rpcsetquota=[yes/no] Use RPC for setting quotas [default=no].],
,
enable_rpcsetquota="no")
+AC_ARG_ENABLE(xfs_roothack,
+ [ --enable-xfs_roothack=[yes/no] Support old XFS root filesystems [default=yes].],
+ ,
+ enable_xfs_roothack="yes")
AC_ARG_ENABLE(bsd_behaviour,
[ --enable-bsd_behaviour=[yes/no] Mimic BSD behaviour [default=yes].],
,
@@ -111,6 +115,9 @@ fi
if test "$enable_rpcsetquota" = "yes" ; then
CFLAGS="-DRPC_SETQUOTA $CFLAGS"
fi
+if test "$enable_xfs_roothack" = "yes" ; then
+ CFLAGS="-DXFS_ROOTHACK $CFLAGS"
+fi
if test "$enable_bsd_behaviour" = "yes" ; then
CFLAGS="-DBSD_BEHAVIOUR $CFLAGS"
fi
diff --git a/quotactl.2 b/quotactl.2
index 7b66f2e..b42a917 100644
--- a/quotactl.2
+++ b/quotactl.2
@@ -4,7 +4,7 @@ quotactl \- manipulate disk quotas
.SH SYNOPSIS
.nf
.B #include <linux/quota.h>
-.B #include <linux/xqm.h>
+.B #include <xfs/xqm.h>
.LP
.B long quotactl(int cmd, char \(**special, qid_t id, caddr_t addr)
.fi
@@ -166,7 +166,7 @@ Therefore, XFS expects the addr to be a pointer to an unsigned int
that contains either the flags XFS_QUOTA_UDQ_ACCT and/or
XFS_QUOTA_UDQ_ENFD (for user quota), or XFS_QUOTA_GDQ_ACCT and/or
XFS_QUOTA_GDQ_ENFD (for group quota), as defined in
-.BR <linux/xqm.h> .
+.BR <xfs/xqm.h> .
This call is restricted to the superuser.
.TP
.SB Q_XQUOTAOFF
@@ -183,7 +183,7 @@ Get disk quota limits and current usage for user
is a pointer to a
.B fs_disk_quota
structure (defined in
-.BR <linux/xqm.h> ).
+.BR <xfs/xqm.h> ).
Only the superuser may get the quotas of a user other than himself.
.TP
.SB Q_XSETQLIM
@@ -193,7 +193,7 @@ Set disk quota limits for user
is a pointer to a
.B fs_disk_quota
structure (defined in
-.BR <linux/xqm.h> ).
+.BR <xfs/xqm.h> ).
This call is restricted to the superuser.
.TP
.SB Q_XGETQSTAT
diff --git a/quotaon.8 b/quotaon.8
index 99f6401..1edfc79 100644
--- a/quotaon.8
+++ b/quotaon.8
@@ -60,9 +60,8 @@ information as filesystem metadata and uses journaling to provide
a higher level guarantee of consistency.
There are two components to the XFS disk quota system:
accounting and limit enforcement.
-Except in the case of the root filesystem, XFS filesystems require
-that quota accounting be turned on at mount time.
-It is possible to enable and disable limit enforcement on any XFS
+XFS filesystems require that quota accounting be turned on at mount time.
+It is possible to enable and disable limit enforcement on an XFS
filesystem after quota accounting is already turned on.
The default is to turn on both accounting and enforcement.
.PP
@@ -147,37 +146,30 @@ Switch off limit enforcement for XFS filesystems (perform
quota accounting only).
This option is only applicable to XFS, and is silently
ignored for other filesystem types.
-.LP
-.SH "XFS EXAMPLES"
-.TP 0
-.B "Turning on quotas on a non-root XFS filesystem"
-Use
+.SH "NOTES ON XFS FILESYSTEMS"
+To enable quotas on an XFS filesystem, use
.IR mount (8)
or
.B /etc/fstab
-option quota to enable both accounting and limit enforcement.
+quota option to enable both accounting and limit enforcement.
.B quotaon
utility cannot be used for this purpose.
-.TP
-.B "Turning on quotas on an XFS root filesystem"
-Use
-.BR "quotaon -v /" ,
-and
-.IR reboot (8).
-This procedure will enable both accounting and limit enforcement.
-.TP
-.B "Turning off quota limit enforcement on any XFS filesystem"
-Make sure that quota accounting and enforcement are both turned on using
+.PP
+Turning on quotas on an XFS root filesystem requires the quota mount
+options be passed into the kernel at boot time through the Linux
+.B rootflags
+boot option.
+.PP
+To turn off quota limit enforcement on any XFS filesystem, first make
+sure that quota accounting and enforcement are both turned on using
.BR "repquota -s" .
-Use
+Then, use
.B "quotaoff -vo"
to disable limit enforcement.
This may be done while the filesystem is mounted.
-.TP
-.BR "Turning on quota limit enforcement on any XFS filesystem"
-Make sure that quota accounting is turned on using
-.BR "repquota -s" .
-Use
+.PP
+Turning on quota limit enforcement on an XFS filesystem is
+achieved using
.BR "quotaon -v" .
This may be done while the filesystem is mounted.
.SH FILES
diff --git a/quotaon_xfs.c b/quotaon_xfs.c
index 70e9e75..a9aed6f 100644
--- a/quotaon_xfs.c
+++ b/quotaon_xfs.c
@@ -21,7 +21,7 @@
* Ensure we don't attempt to go into a dodgey state.
*/
-static int xfs_state_check(int qcmd, int type, int flags, char *dev, int root, int *xopts)
+static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothack, int *xopts)
{
struct xfs_mem_dqinfo info;
int state;
@@ -56,7 +56,7 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int root, i
case Q_XFS_QUOTARM:
return 1;
case Q_XFS_QUOTAON:
- if (root) {
+ if (roothack) {
*xopts |= (type == USRQUOTA) ?
XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT;
printf(_("Enabling %s quota on root filesystem"
@@ -78,7 +78,7 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int root, i
type2name(type), dev);
return -1;
case Q_XFS_QUOTAON:
- if (root) {
+ if (roothack) {
*xopts |= (type == USRQUOTA) ?
XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT;
printf(_("Enabling %s quota on root filesystem"
@@ -119,13 +119,13 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int root, i
return -1;
}
-static int xfs_onoff(char *dev, int type, int flags, int rootfs, int *xopts)
+static int xfs_onoff(char *dev, int type, int flags, int roothack, int *xopts)
{
int qoff, qcmd, check;
qoff = (flags & STATEFLAG_OFF);
qcmd = qoff ? Q_XFS_QUOTAOFF : Q_XFS_QUOTAON;
- check = xfs_state_check(qcmd, type, flags, dev, rootfs, xopts);
+ check = xfs_state_check(qcmd, type, flags, dev, roothack, xopts);
if (check != 1)
return (check < 0);
@@ -140,12 +140,12 @@ static int xfs_onoff(char *dev, int type, int flags, int rootfs, int *xopts)
return 0;
}
-static int xfs_delete(char *dev, int type, int flags, int rootfs, int *xopts)
+static int xfs_delete(char *dev, int type, int flags, int roothack, int *xopts)
{
int qcmd, check;
qcmd = Q_XFS_QUOTARM;
- check = xfs_state_check(qcmd, type, flags, dev, rootfs, xopts);
+ check = xfs_state_check(qcmd, type, flags, dev, roothack, xopts);
if (check != 1)
return (check < 0);
@@ -170,32 +170,51 @@ int xfs_newstate(struct mntent *mnt, int type, char *xarg, int flags)
{
int err = 1;
int xopts = 0;
- int rootfs = !strcmp(mnt->mnt_dir, "/");
+ int roothack = 0;
const char *dev = get_device_name(mnt->mnt_fsname);
if (!dev)
return err;
+#ifdef XFS_ROOTHACK
+ /*
+ * Old XFS filesystems (up to XFS 1.2 / Linux 2.5.47) had a
+ * hack to allow enabling quota on the root filesystem without
+ * having to specify it at mount time.
+ */
+ if ((strcmp(mnt->mnt_dir, "/") == 0)) {
+ struct xfs_mem_dqinfo info;
+ u_int16_t sbflags = 0;
+
+ if (!quotactl(QCMD(Q_XFS_GETQSTAT, type), dev, 0, (void *)&info))
+ sbflags = (info.qs_flags & 0xff00) >> 8;
+
+ if ((type == USRQUOTA && (sbflags & XFS_QUOTA_UDQ_ACCT)) &&
+ (type == GRPQUOTA && (sbflags & XFS_QUOTA_GDQ_ACCT)))
+ roothack = 1;
+ }
+#endif /* XFS_ROOTHACK */
+
if (xarg == NULL) { /* both acct & enfd on/off */
xopts |= (type == USRQUOTA) ?
(XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD) :
(XFS_QUOTA_GDQ_ACCT | XFS_QUOTA_GDQ_ENFD);
- err = xfs_onoff((char *)dev, type, flags, rootfs, &xopts);
+ err = xfs_onoff((char *)dev, type, flags, roothack, &xopts);
}
else if (strcmp(xarg, "account") == 0) {
/* only useful if we want root accounting only */
- if (!rootfs || !(flags & STATEFLAG_ON))
+ if (!roothack || !(flags & STATEFLAG_ON))
goto done;
xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT;
- err = xfs_onoff((char *)dev, type, flags, rootfs, &xopts);
+ err = xfs_onoff((char *)dev, type, flags, roothack, &xopts);
}
else if (strcmp(xarg, "enforce") == 0) {
xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ENFD : XFS_QUOTA_GDQ_ENFD;
- err = xfs_onoff((char *)dev, type, flags, rootfs, &xopts);
+ err = xfs_onoff((char *)dev, type, flags, roothack, &xopts);
}
else if (strcmp(xarg, "delete") == 0) {
xopts |= (type == USRQUOTA) ? XFS_USER_QUOTA : XFS_GROUP_QUOTA;
- err = xfs_delete((char *)dev, type, flags, rootfs, &xopts);
+ err = xfs_delete((char *)dev, type, flags, roothack, &xopts);
}
else
die(1, _("Invalid argument \"%s\"\n"), xarg);
diff --git a/quotasys.c b/quotasys.c
index 3272b70..7c51a1e 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -328,7 +328,6 @@ static int hasxfsquota(struct mntent *mnt, int type)
int ret = 0;
u_int16_t sbflags;
struct xfs_mem_dqinfo info;
- int nonrootfs = strcmp(mnt->mnt_dir, "/");
const char *dev = get_device_name(mnt->mnt_fsname);
if (!dev)
@@ -341,12 +340,19 @@ static int hasxfsquota(struct mntent *mnt, int type)
ret = 1;
else if (type == GRPQUOTA && (info.qs_flags & XFS_QUOTA_GDQ_ACCT))
ret = 1;
- else if (nonrootfs)
+#ifdef XFS_ROOTHACK
+ /*
+ * Old XFS filesystems (up to XFS 1.2 / Linux 2.5.47) had a
+ * hack to allow enabling quota on the root filesystem without
+ * having to specify it at mount time.
+ */
+ else if (strcmp(mnt->mnt_dir, "/"))
ret = 0;
else if (type == USRQUOTA && (sbflags & XFS_QUOTA_UDQ_ACCT))
ret = 1;
else if (type == GRPQUOTA && (sbflags & XFS_QUOTA_GDQ_ACCT))
ret = 1;
+#endif /* XFS_ROOTHACK */
}
free((char *)dev);
return ret;