fs/jfs/ioctl.c
Source file repositories/reference/linux-study-clean/fs/jfs/ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jfs/ioctl.c- Extension
.c- Size
- 3094 bytes
- Lines
- 146
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/ctype.hlinux/capability.hlinux/mount.hlinux/time.hlinux/sched.hlinux/blkdev.hasm/current.hlinux/uaccess.hlinux/fileattr.hjfs_filsys.hjfs_debug.hjfs_incore.hjfs_dinode.hjfs_inode.hjfs_dmap.hjfs_discard.h
Detected Declarations
function jfs_map_ext2function jfs_fileattr_getfunction jfs_fileattr_setfunction jfs_ioctl
Annotated Snippet
if (from) {
if (jfs_map[index].ext2_flag & flags)
mapped |= jfs_map[index].jfs_flag;
} else {
if (jfs_map[index].jfs_flag & flags)
mapped |= jfs_map[index].ext2_flag;
}
index++;
}
return mapped;
}
int jfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
{
struct jfs_inode_info *jfs_inode = JFS_IP(d_inode(dentry));
unsigned int flags = jfs_inode->mode2 & JFS_FL_USER_VISIBLE;
if (d_is_special(dentry))
return -ENOTTY;
fileattr_fill_flags(fa, jfs_map_ext2(flags, 0));
return 0;
}
int jfs_fileattr_set(struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
struct jfs_inode_info *jfs_inode = JFS_IP(inode);
unsigned int flags;
if (d_is_special(dentry))
return -ENOTTY;
if (fileattr_has_fsx(fa))
return -EOPNOTSUPP;
flags = jfs_map_ext2(fa->flags, 1);
if (!S_ISDIR(inode->i_mode))
flags &= ~JFS_DIRSYNC_FL;
/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode))
return -EPERM;
flags = flags & JFS_FL_USER_MODIFIABLE;
flags |= jfs_inode->mode2 & ~JFS_FL_USER_MODIFIABLE;
jfs_inode->mode2 = flags;
jfs_set_inode_flags(inode);
inode_set_ctime_current(inode);
mark_inode_dirty(inode);
return 0;
}
long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(filp);
switch (cmd) {
case FITRIM:
{
struct super_block *sb = inode->i_sb;
struct fstrim_range range;
s64 ret = 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (!bdev_max_discard_sectors(sb->s_bdev)) {
jfs_warn("FITRIM not supported on device");
return -EOPNOTSUPP;
}
if (copy_from_user(&range, (struct fstrim_range __user *)arg,
sizeof(range)))
return -EFAULT;
range.minlen = max_t(unsigned int, range.minlen,
bdev_discard_granularity(sb->s_bdev));
ret = jfs_ioc_trim(inode, &range);
if (ret < 0)
return ret;
if (copy_to_user((struct fstrim_range __user *)arg, &range,
sizeof(range)))
return -EFAULT;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/ctype.h`, `linux/capability.h`, `linux/mount.h`, `linux/time.h`, `linux/sched.h`, `linux/blkdev.h`, `asm/current.h`.
- Detected declarations: `function jfs_map_ext2`, `function jfs_fileattr_get`, `function jfs_fileattr_set`, `function jfs_ioctl`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.