From e14a62e3dc5da1ae6b2379cbe90415e3780c1112 Mon Sep 17 00:00:00 2001 From: wenyuzifangtest001 Date: Fri, 12 Sep 2025 20:10:45 +0800 Subject: [PATCH] Update code from upstream --- ...Fix-error-handling-in-xfs_read_dquot.patch | 36 +++++++++++ ...0-quotaio_xfs-Fix-quota-tools-on-XFS.patch | 64 +++++++++++++++++++ quota.spec | 20 ++++-- 3 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch create mode 100644 quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch diff --git a/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch b/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch new file mode 100644 index 0000000..6adbfc1 --- /dev/null +++ b/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch @@ -0,0 +1,36 @@ +From dba8c5ca95516b9550fc44b2a476ceca60ee4b38 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Tue, 7 May 2024 12:55:30 +0200 +Subject: [PATCH] quotaio_xfs: Fix error handling in xfs_read_dquot() + +When quotactl(2) fails, xfs_read_dquot() will happily return zero-filled +structure. This is fine when the user structure does not exist but it is +wrong when there's other error (like EACCESS). Fix the error handling. + +Signed-off-by: Jan Kara +Signed-off-by: Pavel Reichl +--- + quotaio_xfs.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index d742f9c..040e7d8 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -176,7 +176,12 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id) + qcmd = QCMD(Q_XFS_GETQUOTA, h->qh_type); + if (do_quotactl(qcmd, h->qh_quotadev, h->qh_dir, + id, (void *)&xdqblk) < 0) { +- ; ++ /* ++ * ENOENT means the structure just does not exist - return all ++ * zeros. Otherwise return failure. ++ */ ++ if (errno != ENOENT) ++ return NULL; + } + else { + xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk); +-- +2.45.2 + diff --git a/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch b/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch new file mode 100644 index 0000000..13e6bed --- /dev/null +++ b/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch @@ -0,0 +1,64 @@ +From bd13b74e6d181638023d8a89316417643d9e7fd8 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Tue, 7 May 2024 14:21:45 +0200 +Subject: [PATCH] quotaio_xfs: Fix quota-tools on XFS + +Patches implementing tmpfs quota support, commit 00534e79856c ("Enable +support for tmpfs quotas") in particular, broke quota-tools on XFS +because quotactl(2) syscall got called with wrong arguments. Fix it. + +Signed-off-by: Jan Kara +Signed-off-by: Pavel Reichl +--- + quotaio_xfs.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index 040e7d8..c10534d 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -124,11 +124,9 @@ static inline int xfs_util2kerndqblk(struct xfs_kern_dqblk *k, struct util_dqblk + static int xfs_init_io(struct quota_handle *h) + { + struct xfs_mem_dqinfo info; +- int qcmd; + +- qcmd = QCMD(Q_XFS_GETQSTAT, h->qh_type); + memset(&info, 0, sizeof(struct xfs_mem_dqinfo)); +- if (quotactl_handle(qcmd, h, 0, (void *)&info) < 0) ++ if (quotactl_handle(Q_XFS_GETQSTAT, h, 0, (void *)&info) < 0) + return -1; + h->qh_info.dqi_bgrace = info.qs_btimelimit; + h->qh_info.dqi_igrace = info.qs_itimelimit; +@@ -142,7 +140,6 @@ static int xfs_init_io(struct quota_handle *h) + static int xfs_write_info(struct quota_handle *h) + { + struct xfs_kern_dqblk xdqblk; +- int qcmd; + + if (!XFS_USRQUOTA(h) && !XFS_GRPQUOTA(h) && !XFS_PRJQUOTA(h)) + return 0; +@@ -152,8 +149,7 @@ static int xfs_write_info(struct quota_handle *h) + xdqblk.d_btimer = h->qh_info.dqi_bgrace; + xdqblk.d_itimer = h->qh_info.dqi_igrace; + xdqblk.d_fieldmask |= FS_DQ_TIMER_MASK; +- qcmd = QCMD(Q_XFS_SETQLIM, h->qh_type); +- if (quotactl_handle(qcmd, h, 0, (void *)&xdqblk) < 0) ++ if (quotactl_handle(Q_XFS_SETQLIM, h, 0, (void *)&xdqblk) < 0) + return -1; + return 0; + } +@@ -180,8 +176,9 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id) + * ENOENT means the structure just does not exist - return all + * zeros. Otherwise return failure. + */ +- if (errno != ENOENT) ++ if (errno != ENOENT) { + return NULL; ++ } + } + else { + xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk); +-- +2.45.2 + diff --git a/quota.spec b/quota.spec index b49529c..a1969f4 100644 --- a/quota.spec +++ b/quota.spec @@ -1,4 +1,4 @@ -%define anolis_release 2 +%define anolis_release 3 # Scan ext file systems directly to increase the performace of a quota # initialization and check @@ -14,17 +14,19 @@ Name: quota Epoch: 1 -Version: 4.09 +Version: 4.09 Release: %{anolis_release}%{?dist} Summary: System administration tools for monitoring users disk usage License: GPLv2 and GPLv2+ URL: http://sourceforge.net/projects/linuxquota/ -Source0: http://downloads.sourceforge.net/linuxquota/%{name}-%{version}.tar.gz -Source1: quota_nld.service -Source2: quota_nld.sysconfig -Source3: rpc-rquotad.service -Source4: rpc-rquotad.sysconfig +Source0: http://downloads.sourceforge.net/linuxquota/quota-4.09.tar.gz +Source1: quota_nld.service +Source2: quota_nld.sysconfig +Source3: rpc-rquotad.service +Source4: rpc-rquotad.sysconfig +Patch1: quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch +Patch2: quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch BuildRequires: autoconf automake bash coreutils gcc make BuildRequires: pkgconfig(ext2fs) pkgconfig(ldap) gettext-devel @@ -40,6 +42,8 @@ BuildRequires: pkgconfig(libnl-3.0) >= 3.1 pkgconfig(libnl-genl-3.0) BuildRequires: rpcgen pkgconfig(libtirpc) systemd-rpm-macros %if %{with quota_enables_tcpwrappers} BuildRequires: tcp_wrappers-devel +BuildRequires: e2fsprogs-devel +BuildRequires: openldap-devel %endif %endif @@ -262,6 +266,8 @@ make check %doc Changelog README.ldap-support README.mailserver %changelog +* Fri Sep 12 2025 wenyuzifangtest001 - 1:4.09-3 +- Ensure accurate error handling and prevent misreporting of quota status. * Thu Apr 13 2023 yuanhui - 4.09-2 - Optimize the spec file -- Gitee