quotactl(2)

๐Ÿ’– quotactl(2) โ€” manipulate disk quotas ๐Ÿ’–

okay bestie, so this is the page for quotactl and quotactl_fd, the Linux system calls that mess with disk quotas โ€” like the whole thing where a filesystem says "you get THIS much space, and not one byte more, bestie." ๐Ÿฆ‹


๐Ÿ“š LIBRARY

Standard C library, aka libc, link it with -lc. ๐Ÿ’…


โœจ SYNOPSIS

#include <xfs/xqm.h> /* Definition of Q_X* and XFS_QUOTA_* constants
                        (or <linux/dqblk_xfs.h>; see NOTES) */
#include <sys/quota.h>

int quotactl(int op, const char *_Nullable special, int id,
             caddr_t addr);

#include <xfs/xqm.h> /* Definition of Q_X* and XFS_QUOTA_* constants
                        (or <linux/dqblk_xfs.h>; see NOTES) */
#include <sys/syscall.h>    /* Definition of SYS_* constants */
#include <unistd.h>

int syscall(SYS_quotactl_fd, int fd, int op, int id, caddr_t addr);

two entry points, one vibe ๐Ÿ’ซ


๐ŸŒธ DESCRIPTION

The quota system sets per-user, per-group, and per-project limits on how much disk space each of them can use on a filesystem. For every user and/or group you can set a soft limit and a hard limit on each filesystem. The hard limit can't be exceeded, periodt. The soft limit can be exceeded, but warnings will ensue (the audacity, honestly ๐Ÿ˜ญ). And here's the twist: you can't stay over the soft limit for longer than the grace period (one week by default). After that, the soft limit counts as a hard limit. no cap. ๐Ÿ”ฅ

The quotactl() and quotactl_fd() calls manipulate disk quotas. The difference between them is how you tell it which filesystem you mean, see the argument descriptions below. And if you're wondering which one to pick, the NOTES section has the tea. โ˜•

The op argument is the operation to apply to the user or group ID given in id. To build op, use the QCMD(subop, type) macro. The type value is either USRQUOTA (user quotas), GRPQUOTA (group quotas), or โ€” since Linux 4.1 โ€” PRJQUOTA (project quotas). The subop value is explained right below. ๐ŸŽ€

For quotactl(), special is a pointer to a null-terminated string holding the pathname of the (mounted) block special device for the filesystem you're manipulating. ๐Ÿงš

For quotactl_fd(), the fd argument is a file descriptor โ€” and yes it may be opened with the O_PATH flag โ€” pointing at a file or directory on the filesystem you're manipulating. ๐Ÿซถ

The addr argument is the address of an optional, operation-specific data structure that gets copied in or out of the system. What addr means depends on the operation, and it's spelled out for each one below. ๐Ÿ‘‘

So, subop is one of these operations:

But wait โ€” for XFS filesystems using the XFS Quota Manager (XQM), all of the above gets bypassed entirely and you use these instead:


๐ŸŽฏ RETURN VALUE

Slay = 0 is returned. ๐Ÿ˜Œ

Not slay = -1 is returned and errno is set to tell you what went wrong. ๐Ÿ’€


๐Ÿšจ ERRORS

  • EFAULT โ€” addr or special is invalid. ๐Ÿ™ˆ
  • EINVAL โ€” op or type is invalid. ๐Ÿ™ˆ
  • ENOENT โ€” the file specified by special or addr does not exist. ๐Ÿ˜ญ
  • ENOSYS โ€” the kernel was not compiled with the CONFIG_QUOTA option. ๐Ÿ’€
  • ENOTBLK โ€” special is not a block device. ๐Ÿ’€
  • EPERM โ€” the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified operation. ๐Ÿ‘‘ (respectfully, you need the crown for this one)
  • ESRCH โ€” no disk quota is found for the indicated user. Quotas have not been turned on for this filesystem. ๐Ÿ”

๐Ÿ“ NOTES

๐Ÿ—‚๏ธ Alternative XFS header

Instead of <xfs/xqm.h> you can use <linux/dqblk_xfs.h> โ€” just keep in mind there are several naming discrepancies, okurrr:

  • Quota enabling flags (of format XFS_QUOTA_[UGP]DQ_{ACCT,ENFD}) are defined without a leading "X", as FS_QUOTA_[UGP]DQ_{ACCT,ENFD}. ๐ŸŒˆ
  • Same energy for the XFS_{USER,GROUP,PROJ}_QUOTA quota type flags โ€” they're defined as FS_{USER,GROUP,PROJ}_QUOTA. ๐ŸŒˆ
  • The dqblk_xfs.h header file defines its own XQM_USRQUOTA, XQM_GRPQUOTA, and XQM_PRJQUOTA constants for the available quota types, but their values are the same as for the constants without the XQM_ prefix. ๐ŸŒˆ

โš”๏ธ quotactl() versus quotactl_fd()

The original quotactl() variant of this system call requires you to specify the block device containing the filesystem to operate on. Which is lowkey a problem: it makes it impossible to use in cases where the filesystem has no backing block device at all (e.g., tmpfs ๐Ÿ˜ญ). And even when the block device does exist, it might be a whole quest to find it โ€” it requires scanning /proc/self/mounts and even some filesystem-specific parsing in the case of, for example, bcachefs. ๐Ÿ˜ตโ€๐Ÿ’ซ

quotactl_fd() instead works on the mount point, which dodges that whole limitation and is simpler to use โ€” since the filesystem you want to manipulate is typically specified by its mount point anyway. main character energy honestly. ๐Ÿ‘‘


๐Ÿ“ STANDARDS

Linux. ๐Ÿง


๐Ÿ•ฐ๏ธ HISTORY

  • quotactl_fd() โ€” Linux 5.14. โœจ

๐Ÿ‘€ SEE ALSO

quota(1), getrlimit(2), quotacheck(8), quotaon(8) ๐Ÿซถ


okay that's the whole page bestie, go forth and quota responsibly ๐Ÿ’–โœจ

โ€” from Linux man-pages 6.20, dated 2026-06-05, signing off like the icon it is ๐ŸŽ€๐ŸŒŸ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms