fs/quota/quota.c
Source file repositories/reference/linux-study-clean/fs/quota/quota.c
File Facts
- System
- Linux kernel
- Corpus path
fs/quota/quota.c- Extension
.c- Size
- 28249 bytes
- Lines
- 1011
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: syscall or user/kernel boundary
- Status
- core implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/namei.hlinux/slab.hasm/current.hlinux/blkdev.hlinux/uaccess.hlinux/kernel.hlinux/security.hlinux/syscalls.hlinux/capability.hlinux/quotaops.hlinux/types.hlinux/mount.hlinux/writeback.hlinux/nospec.hcompat.h../internal.h
Detected Declarations
syscall quotactlsyscall quotactl_fdfunction quotactlfunction quota_sync_onefunction quota_sync_allfunction qtype_enforce_flagfunction quota_quotaonfunction quota_quotaofffunction quota_getfmtfunction quota_getinfofunction quota_setinfofunction qbtosfunction stoqbfunction copy_to_if_dqblkfunction quota_getquotafunction quota_getnextquotafunction copy_from_if_dqblkfunction quota_setquotafunction quota_enablefunction quota_disablefunction quota_state_to_flagsfunction quota_getstatefunction compat_copy_fs_qfilestatfunction compat_copy_fs_quota_statfunction quota_getxstatefunction quota_getstatevfunction quota_getxstatevfunction quota_bbtobfunction quota_btobbfunction copy_from_xfs_dqblk_tsfunction copy_from_xfs_dqblkfunction copy_qcinfo_from_xfs_dqblkfunction quota_setxquotafunction copy_to_xfs_dqblk_tsfunction want_bigtimefunction copy_to_xfs_dqblkfunction quota_getxquotafunction quota_getnextxquotafunction quota_rmxquotafunction do_quotactlfunction quotactl_cmd_writefunction quotactl_cmd_onofffunction resolution
Annotated Snippet
SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
qid_t, id, void __user *, addr)
{
uint cmds, type;
struct super_block *sb = NULL;
struct path path, *pathp = NULL;
int ret;
cmds = cmd >> SUBCMDSHIFT;
type = cmd & SUBCMDMASK;
if (type >= MAXQUOTAS)
return -EINVAL;
/*
* As a special case Q_SYNC can be called without a specific device.
* It will iterate all superblocks that have quota enabled and call
* the sync action on each of them.
*/
if (!special) {
if (cmds == Q_SYNC)
return quota_sync_all(type);
return -ENODEV;
}
/*
* Path for quotaon has to be resolved before grabbing superblock
* because that gets s_umount sem which is also possibly needed by path
* resolution (think about autofs) and thus deadlocks could arise.
*/
if (cmds == Q_QUOTAON) {
ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
if (ret)
pathp = ERR_PTR(ret);
else
pathp = &path;
}
sb = quotactl_block(special, cmds);
if (IS_ERR(sb)) {
ret = PTR_ERR(sb);
goto out;
}
ret = do_quotactl(sb, type, cmds, id, addr, pathp);
if (!quotactl_cmd_onoff(cmds))
drop_super(sb);
else
drop_super_exclusive(sb);
out:
if (pathp && !IS_ERR(pathp))
path_put(pathp);
return ret;
}
SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd,
qid_t, id, void __user *, addr)
{
struct super_block *sb;
unsigned int cmds = cmd >> SUBCMDSHIFT;
unsigned int type = cmd & SUBCMDMASK;
CLASS(fd_raw, f)(fd);
int ret;
if (fd_empty(f))
return -EBADF;
if (type >= MAXQUOTAS)
return -EINVAL;
if (quotactl_cmd_write(cmds)) {
ret = mnt_want_write(fd_file(f)->f_path.mnt);
if (ret)
return ret;
}
sb = fd_file(f)->f_path.mnt->mnt_sb;
if (quotactl_cmd_onoff(cmds))
down_write(&sb->s_umount);
else
down_read(&sb->s_umount);
ret = do_quotactl(sb, type, cmds, id, addr, ERR_PTR(-EINVAL));
if (quotactl_cmd_onoff(cmds))
up_write(&sb->s_umount);
else
up_read(&sb->s_umount);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/namei.h`, `linux/slab.h`, `asm/current.h`, `linux/blkdev.h`, `linux/uaccess.h`, `linux/kernel.h`, `linux/security.h`.
- Detected declarations: `syscall quotactl`, `syscall quotactl_fd`, `function quotactl`, `function quota_sync_one`, `function quota_sync_all`, `function qtype_enforce_flag`, `function quota_quotaon`, `function quota_quotaoff`, `function quota_getfmt`, `function quota_getinfo`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: core implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.