fs/affs/amigaffs.c
Source file repositories/reference/linux-study-clean/fs/affs/amigaffs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/affs/amigaffs.c- Extension
.c- Size
- 12576 bytes
- Lines
- 544
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/math64.hlinux/iversion.haffs.h
Detected Declarations
function affs_insert_hashfunction affs_remove_hashfunction affs_fix_dcachefunction affs_remove_linkfunction affs_empty_dirfunction affs_remove_headerfunction affs_checksum_blockfunction affs_fix_checksumfunction affs_secs_to_datestampfunction affs_prot_to_modefunction affs_mode_to_protfunction affs_errorfunction affs_warningfunction affs_nofilenametruncatefunction affs_check_namefunction affs_check_name
Annotated Snippet
if (hash_ino == rem_ino) {
ino = AFFS_TAIL(sb, rem_bh)->hash_chain;
if (dir->i_ino == bh->b_blocknr)
AFFS_HEAD(bh)->table[offset] = ino;
else
AFFS_TAIL(sb, bh)->hash_chain = ino;
affs_adjust_checksum(bh, be32_to_cpu(ino) - hash_ino);
mmb_mark_buffer_dirty(bh, &AFFS_I(dir)->i_metadata_bhs);
AFFS_TAIL(sb, rem_bh)->parent = 0;
retval = 0;
break;
}
affs_brelse(bh);
bh = affs_bread(sb, hash_ino);
if (!bh)
return -EIO;
hash_ino = be32_to_cpu(AFFS_TAIL(sb, bh)->hash_chain);
}
affs_brelse(bh);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
inode_inc_iversion(dir);
mark_inode_dirty(dir);
return retval;
}
static void
affs_fix_dcache(struct inode *inode, u32 entry_ino)
{
struct dentry *dentry;
spin_lock(&inode->i_lock);
for_each_alias(dentry, inode) {
if (entry_ino == (u32)(long)dentry->d_fsdata) {
dentry->d_fsdata = (void *)(unsigned long)inode->i_ino;
break;
}
}
spin_unlock(&inode->i_lock);
}
/* Remove header from link chain */
static int
affs_remove_link(struct dentry *dentry)
{
struct inode *dir, *inode = d_inode(dentry);
struct super_block *sb = inode->i_sb;
struct buffer_head *bh, *link_bh = NULL;
u32 link_ino, ino;
int retval;
pr_debug("%s(key=%llu)\n", __func__, inode->i_ino);
retval = -EIO;
bh = affs_bread(sb, inode->i_ino);
if (!bh)
goto done;
link_ino = (u32)(long)dentry->d_fsdata;
if (inode->i_ino == link_ino) {
/* we can't remove the head of the link, as its blocknr is still used as ino,
* so we remove the block of the first link instead.
*/
link_ino = be32_to_cpu(AFFS_TAIL(sb, bh)->link_chain);
link_bh = affs_bread(sb, link_ino);
if (!link_bh)
goto done;
dir = affs_iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent));
if (IS_ERR(dir)) {
retval = PTR_ERR(dir);
goto done;
}
affs_lock_dir(dir);
/*
* if there's a dentry for that block, make it
* refer to inode itself.
*/
affs_fix_dcache(inode, link_ino);
retval = affs_remove_hash(dir, link_bh);
if (retval) {
affs_unlock_dir(dir);
goto done;
}
mmb_mark_buffer_dirty(link_bh, &AFFS_I(inode)->i_metadata_bhs);
memcpy(AFFS_TAIL(sb, bh)->name, AFFS_TAIL(sb, link_bh)->name, 32);
Annotation
- Immediate include surface: `linux/math64.h`, `linux/iversion.h`, `affs.h`.
- Detected declarations: `function affs_insert_hash`, `function affs_remove_hash`, `function affs_fix_dcache`, `function affs_remove_link`, `function affs_empty_dir`, `function affs_remove_header`, `function affs_checksum_block`, `function affs_fix_checksum`, `function affs_secs_to_datestamp`, `function affs_prot_to_mode`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- 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.