fs/efs/inode.c
Source file repositories/reference/linux-study-clean/fs/efs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/efs/inode.c- Extension
.c- Size
- 8637 bytes
- Lines
- 316
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/buffer_head.hlinux/module.hlinux/fs.hefs.hlinux/efs_fs_sb.h
Detected Declarations
function Copyrightfunction _efs_bmapfunction extent_copyfunction efs_extent_checkfunction efs_map_block
Annotated Snippet
static inline void extent_copy(efs_extent *src, efs_extent *dst) {
/*
* this is slightly evil. it doesn't just copy
* efs_extent from src to dst, it also mangles
* the bits so that dst ends up in cpu byte-order.
*/
dst->cooked.ex_magic = (unsigned int) src->raw[0];
dst->cooked.ex_bn = ((unsigned int) src->raw[1] << 16) |
((unsigned int) src->raw[2] << 8) |
((unsigned int) src->raw[3] << 0);
dst->cooked.ex_length = (unsigned int) src->raw[4];
dst->cooked.ex_offset = ((unsigned int) src->raw[5] << 16) |
((unsigned int) src->raw[6] << 8) |
((unsigned int) src->raw[7] << 0);
return;
}
struct inode *efs_iget(struct super_block *super, unsigned long ino)
{
int i, inode_index;
dev_t device;
u32 rdev;
struct buffer_head *bh;
struct efs_sb_info *sb = SUPER_INFO(super);
struct efs_inode_info *in;
efs_block_t block, offset;
struct efs_dinode *efs_inode;
struct inode *inode;
inode = iget_locked(super, ino);
if (!inode)
return ERR_PTR(-ENOMEM);
if (!(inode_state_read_once(inode) & I_NEW))
return inode;
in = INODE_INFO(inode);
/*
** EFS layout:
**
** | cylinder group | cylinder group | cylinder group ..etc
** |inodes|data |inodes|data |inodes|data ..etc
**
** work out the inode block index, (considering initially that the
** inodes are stored as consecutive blocks). then work out the block
** number of that inode given the above layout, and finally the
** offset of the inode within that block.
*/
inode_index = inode->i_ino /
(EFS_BLOCKSIZE / sizeof(struct efs_dinode));
block = sb->fs_start + sb->first_block +
(sb->group_size * (inode_index / sb->inode_blocks)) +
(inode_index % sb->inode_blocks);
offset = (inode->i_ino %
(EFS_BLOCKSIZE / sizeof(struct efs_dinode))) *
sizeof(struct efs_dinode);
bh = sb_bread(inode->i_sb, block);
if (!bh) {
pr_warn("%s() failed at block %d\n", __func__, block);
goto read_inode_error;
}
efs_inode = (struct efs_dinode *) (bh->b_data + offset);
inode->i_mode = be16_to_cpu(efs_inode->di_mode);
set_nlink(inode, be16_to_cpu(efs_inode->di_nlink));
i_uid_write(inode, (uid_t)be16_to_cpu(efs_inode->di_uid));
i_gid_write(inode, (gid_t)be16_to_cpu(efs_inode->di_gid));
inode->i_size = be32_to_cpu(efs_inode->di_size);
inode_set_atime(inode, be32_to_cpu(efs_inode->di_atime), 0);
inode_set_mtime(inode, be32_to_cpu(efs_inode->di_mtime), 0);
inode_set_ctime(inode, be32_to_cpu(efs_inode->di_ctime), 0);
/* this is the number of blocks in the file */
if (inode->i_size == 0) {
inode->i_blocks = 0;
} else {
inode->i_blocks = ((inode->i_size - 1) >> EFS_BLOCKSIZE_BITS) + 1;
}
rdev = be16_to_cpu(efs_inode->di_u.di_dev.odev);
if (rdev == 0xffff) {
rdev = be32_to_cpu(efs_inode->di_u.di_dev.ndev);
if (sysv_major(rdev) > 0xfff)
device = 0;
Annotation
- Immediate include surface: `linux/buffer_head.h`, `linux/module.h`, `linux/fs.h`, `efs.h`, `linux/efs_fs_sb.h`.
- Detected declarations: `function Copyright`, `function _efs_bmap`, `function extent_copy`, `function efs_extent_check`, `function efs_map_block`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.