@@ -38,6 +38,11 @@ Major new features:
hints) of a file, which were previously only available through the
FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR ioctls.
+* On Linux, the quotactl_fd function has been added to <sys/quota.h>. It
+ is a variant of quotactl which operates on the filesystem containing an
+ open file, so it can be used for filesystems without a backing block
+ device such as tmpfs.
+
Deprecated and removed features, and other changes affecting compatibility:
* The posix_spawn_file_actions_addchdir and posix_spawn_file_actions_addfchdir
@@ -232,6 +232,7 @@ tests += \
tst-prctl \
tst-process_mrelease \
tst-quota \
+ tst-quotactl_fd \
tst-rlimit-infinity \
tst-sched-affinity-inheritance \
tst-sched_setattr \
@@ -352,6 +352,7 @@ libc {
listxattrat;
membarrier;
open_tree_attr;
+ quotactl_fd;
removexattrat;
setxattrat;
statmount;
@@ -2785,6 +2785,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3132,6 +3132,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2546,6 +2546,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2838,6 +2838,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2835,6 +2835,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2822,6 +2822,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2859,6 +2859,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3042,6 +3042,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2297,6 +2297,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2306,6 +2306,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2818,6 +2818,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2985,6 +2985,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2871,6 +2871,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2868,6 +2868,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2948,6 +2948,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2946,6 +2946,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2954,6 +2954,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2856,6 +2856,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2296,6 +2296,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3175,6 +3175,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3220,6 +3220,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2929,6 +2929,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3005,6 +3005,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2549,6 +2549,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2749,6 +2749,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2966,6 +2966,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2865,6 +2865,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2862,6 +2862,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -3196,6 +3196,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2832,6 +2832,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -130,6 +130,10 @@ __BEGIN_DECLS
extern int quotactl (int __cmd, const char *__special, int __id,
__caddr_t __addr) __THROW;
+/* Same as quotactl, but operate on the filesystem containing the file
+ referred to by FD instead of a block device. */
+extern int quotactl_fd (int __fd, int __cmd, int __id, void *__addr) __THROW;
+
__END_DECLS
#endif /* sys/quota.h */
@@ -61,6 +61,7 @@ process_madvise EXTRA process_madvise i:iPniU process_madvise
process_mrelease EXTRA process_mrelease i:iU process_mrelease
query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23
quotactl EXTRA quotactl i:isip quotactl
+quotactl_fd EXTRA quotactl_fd i:iiia quotactl_fd
remap_file_pages - remap_file_pages i:pUiUi __remap_file_pages remap_file_pages
sched_getp - sched_getparam i:ip __sched_getparam sched_getparam
sched_gets - sched_getscheduler i:i __sched_getscheduler sched_getscheduler
new file mode 100644
@@ -0,0 +1,52 @@
+/* Basic tests for Linux quotactl_fd.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/quota.h>
+#include <support/check.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+
+/* Enabling quotas requires privileges (the kernel does not support them for
+ tmpfs mounts in a user namespace), so only use basic tests. */
+
+static int
+do_test (void)
+{
+ uint32_t fmt;
+
+ /* The file descriptor is checked first. */
+ TEST_COMPARE (quotactl_fd (-1, QCMD (Q_GETFMT, USRQUOTA), 0, &fmt), -1);
+ if (errno == ENOSYS)
+ FAIL_UNSUPPORTED ("quotactl_fd is not supported by the kernel");
+ TEST_COMPARE (errno, EBADF);
+
+ char *dir = support_create_temp_directory ("tst-quotactl_fd.");
+ int fd = xopen (dir, O_RDONLY | O_DIRECTORY, 0);
+ TEST_COMPARE (quotactl_fd (fd, QCMD (Q_GETFMT, MAXQUOTAS), 0, &fmt), -1);
+ TEST_COMPARE (errno, EINVAL);
+ xclose (fd);
+
+ free (dir);
+ return 0;
+}
+
+#include <support/test-driver.c>
@@ -2781,6 +2781,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F
@@ -2800,6 +2800,7 @@ GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 quotactl_fd F
GLIBC_2.45 removexattrat F
GLIBC_2.45 setxattrat F
GLIBC_2.45 statmount F