From: Donald Douwsma Date: Wed, 15 Aug 2007 16:22:27 +0000 (+0000) Subject: Fix xfs_quota disable, enable, off and remove commands X-Git-Tag: v2.10.0~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79ac1ae4;p=thirdparty%2Fxfsprogs-dev.git Fix xfs_quota disable, enable, off and remove commands Merge of master-melb:xfs-cmds:29395a by kenmcd. --- diff --git a/doc/CHANGES b/doc/CHANGES index 023ad1adc..b73f1e4ff 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +xfsprogs-2.9.4 (15 AUG 2007) + - Fixed xfs_quota disable, enable, off and remove commands. + Thanks to Utako Kusaka for this. + xfsprogs-2.9.3 (23 July 2007) - Make xfs_repair support > 512 byte sector sizes. - Fixed include Makefile for new common header (xfs_metadump.h). diff --git a/quota/state.c b/quota/state.c index 49e31aa79..dd1eeece1 100644 --- a/quota/state.c +++ b/quota/state.c @@ -250,10 +250,6 @@ enable_enforcement( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = { 0 }; - - qstat.qs_version = FS_QSTAT_VERSION; - qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -261,7 +257,7 @@ enable_enforcement( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qstat) < 0) + if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qflags) < 0) perror("XFS_QUOTAON"); else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); @@ -275,10 +271,6 @@ disable_enforcement( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = { 0 }; - - qstat.qs_version = FS_QSTAT_VERSION; - qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -286,7 +278,7 @@ disable_enforcement( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qstat) < 0) + if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) perror("XFS_QUOTAOFF"); else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); @@ -300,10 +292,6 @@ quotaoff( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = { 0 }; - - qstat.qs_version = FS_QSTAT_VERSION; - qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -311,24 +299,31 @@ quotaoff( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qstat) < 0) + if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) perror("XFS_QUOTAOFF"); else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); } +static int +remove_qtype_extents( + char *dir, + uint type) +{ + int error = 0; + + if ((error = xfsquotactl(XFS_QUOTARM, dir, type, 0, (void *)&type)) < 0) + perror("XFS_QUOTARM"); + return error; +} + static void remove_extents( char *dir, uint type, - uint qflags, uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = { 0 }; - - qstat.qs_version = FS_QSTAT_VERSION; - qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -336,9 +331,18 @@ remove_extents( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTARM, dir, type, 0, (void *)&qstat) < 0) - perror("XFS_QUOTARM"); - else if (flags & VERBOSE_FLAG) + if (type & XFS_USER_QUOTA) { + if (remove_qtype_extents(dir, XFS_USER_QUOTA) < 0) + return; + } + if (type & XFS_GROUP_QUOTA) { + if (remove_qtype_extents(dir, XFS_GROUP_QUOTA) < 0) + return; + } else if (type & XFS_PROJ_QUOTA) { + if (remove_qtype_extents(dir, XFS_PROJ_QUOTA) < 0) + return; + } + if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); } @@ -374,7 +378,7 @@ enable_f( if (argc != optind) return command_usage(&enable_cmd); - if (!flags) { + if (!type) { type |= XFS_USER_QUOTA; qflags |= XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD; } @@ -395,15 +399,15 @@ disable_f( switch (c) { case 'g': type |= XFS_GROUP_QUOTA; - qflags |= XFS_QUOTA_GDQ_ACCT; + qflags |= XFS_QUOTA_GDQ_ENFD; break; case 'p': type |= XFS_PROJ_QUOTA; - qflags |= XFS_QUOTA_PDQ_ACCT; + qflags |= XFS_QUOTA_PDQ_ENFD; break; case 'u': type |= XFS_USER_QUOTA; - qflags |= XFS_QUOTA_UDQ_ACCT; + qflags |= XFS_QUOTA_UDQ_ENFD; break; case 'v': flags |= VERBOSE_FLAG; @@ -416,9 +420,9 @@ disable_f( if (argc != optind) return command_usage(&disable_cmd); - if (!flags) { + if (!type) { type |= XFS_USER_QUOTA; - qflags |= XFS_QUOTA_UDQ_ACCT; + qflags |= XFS_QUOTA_UDQ_ENFD; } if (fs_path->fs_flags & FS_MOUNT_POINT) @@ -458,7 +462,7 @@ off_f( if (argc != optind) return command_usage(&off_cmd); - if (!flags) { + if (!type) { type |= XFS_USER_QUOTA; qflags |= XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD; } @@ -473,21 +477,18 @@ remove_f( int argc, char **argv) { - int c, flags = 0, qflags = 0, type = 0; + int c, flags = 0, type = 0; while ((c = getopt(argc, argv, "gpuv")) != EOF) { switch (c) { case 'g': type |= XFS_GROUP_QUOTA; - qflags |= XFS_QUOTA_GDQ_ACCT | XFS_QUOTA_GDQ_ENFD; break; case 'p': type |= XFS_PROJ_QUOTA; - qflags |= XFS_QUOTA_PDQ_ACCT | XFS_QUOTA_PDQ_ENFD; break; case 'u': type |= XFS_USER_QUOTA; - qflags |= XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD; break; case 'v': flags |= VERBOSE_FLAG; @@ -500,13 +501,12 @@ remove_f( if (argc != optind) return command_usage(&remove_cmd); - if (!flags) { + if (!type) { type |= XFS_USER_QUOTA; - qflags |= XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD; } if (fs_path->fs_flags & FS_MOUNT_POINT) - remove_extents(fs_path->fs_dir, type, qflags, flags); + remove_extents(fs_path->fs_dir, type, flags); return 0; }