fs/nilfs2/ioctl.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/ioctl.c- Extension
.c- Size
- 38706 bytes
- Lines
- 1400
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/wait.hlinux/slab.hlinux/capability.hlinux/uaccess.hlinux/vmalloc.hlinux/compat.hlinux/mount.hlinux/buffer_head.hlinux/fileattr.hlinux/string.hnilfs.hsegment.hbmap.hcpfile.hsufile.hdat.h
Detected Declarations
function Copyrightfunction nilfs_fileattr_getfunction nilfs_fileattr_setfunction nilfs_ioctl_getversionfunction nilfs_ioctl_change_cpmodefunction nilfs_ioctl_delete_checkpointfunction nilfs_ioctl_do_get_cpinfofunction nilfs_ioctl_get_cpstatfunction nilfs_ioctl_do_get_suinfofunction nilfs_ioctl_get_sustatfunction nilfs_ioctl_do_get_vinfofunction nilfs_ioctl_do_get_bdescsfunction nilfs_ioctl_get_bdescsfunction nilfs_ioctl_move_inode_blockfunction nilfs_ioctl_move_blocksfunction list_for_each_entry_safefunction nilfs_ioctl_delete_checkpointsfunction nilfs_ioctl_free_vblocknrsfunction nilfs_ioctl_mark_blocks_dirtyfunction nilfs_ioctl_prepare_clean_segmentsfunction nilfs_ioctl_clean_segmentsfunction nilfs_ioctl_move_blocksfunction nilfs_ioctl_syncfunction nilfs_ioctl_resizefunction nilfs_ioctl_trim_fsfunction nilfs_ioctl_set_alloc_rangefunction dofuncfunction nilfs_ioctl_set_suinfofunction nilfs_ioctl_get_fslabelfunction nilfs_ioctl_set_fslabelfunction nilfs_ioctlfunction nilfs_compat_ioctl
Annotated Snippet
if (nr < 0) {
ret = nr;
break;
}
if ((dir & _IOC_READ) &&
copy_to_user(base + argv->v_size * i, buf,
argv->v_size * nr)) {
ret = -EFAULT;
break;
}
total += nr;
if ((size_t)nr < n)
break;
if (pos == ppos)
pos += n;
}
argv->v_nmembs = total;
kfree(buf);
return ret;
}
/**
* nilfs_fileattr_get - retrieve miscellaneous file attributes
* @dentry: the object to retrieve from
* @fa: fileattr pointer
*
* Return: always 0 as success.
*/
int nilfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
fileattr_fill_flags(fa, NILFS_I(inode)->i_flags & FS_FL_USER_VISIBLE);
return 0;
}
/**
* nilfs_fileattr_set - change miscellaneous file attributes
* @idmap: idmap of the mount
* @dentry: the object to change
* @fa: fileattr pointer
*
* Return: 0 on success, or a negative error code on failure.
*/
int nilfs_fileattr_set(struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
struct nilfs_transaction_info ti;
unsigned int flags, oldflags;
int ret;
if (fileattr_has_fsx(fa))
return -EOPNOTSUPP;
flags = nilfs_mask_flags(inode->i_mode, fa->flags);
ret = nilfs_transaction_begin(inode->i_sb, &ti, 0);
if (ret)
return ret;
oldflags = NILFS_I(inode)->i_flags & ~FS_FL_USER_MODIFIABLE;
NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
nilfs_set_inode_flags(inode);
inode_set_ctime_current(inode);
if (IS_SYNC(inode))
nilfs_set_transaction_flag(NILFS_TI_SYNC);
nilfs_mark_inode_dirty(inode);
return nilfs_transaction_commit(inode->i_sb);
}
/**
* nilfs_ioctl_getversion - get info about a file's version (generation number)
* @inode: inode object
* @argp: userspace memory where the generation number of @inode is stored
*
* Return: 0 on success, or %-EFAULT on error.
*/
static int nilfs_ioctl_getversion(struct inode *inode, void __user *argp)
{
return put_user(inode->i_generation, (int __user *)argp);
}
/**
* nilfs_ioctl_change_cpmode - change checkpoint mode (checkpoint/snapshot)
* @inode: inode object
Annotation
- Immediate include surface: `linux/fs.h`, `linux/wait.h`, `linux/slab.h`, `linux/capability.h`, `linux/uaccess.h`, `linux/vmalloc.h`, `linux/compat.h`, `linux/mount.h`.
- Detected declarations: `function Copyright`, `function nilfs_fileattr_get`, `function nilfs_fileattr_set`, `function nilfs_ioctl_getversion`, `function nilfs_ioctl_change_cpmode`, `function nilfs_ioctl_delete_checkpoint`, `function nilfs_ioctl_do_get_cpinfo`, `function nilfs_ioctl_get_cpstat`, `function nilfs_ioctl_do_get_suinfo`, `function nilfs_ioctl_get_sustat`.
- 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.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.