fs/hpfs/dnode.c
Source file repositories/reference/linux-study-clean/fs/hpfs/dnode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hpfs/dnode.c- Extension
.c- Size
- 31134 bytes
- Lines
- 1096
- 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.
- 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
hpfs_fn.h
Detected Declarations
function Patockafunction hpfs_add_posfunction hpfs_del_posfunction for_all_possfunction hpfs_pos_substfunction hpfs_pos_insfunction hpfs_pos_delfunction set_last_pointerfunction hpfs_delete_defunction fix_up_ptrsfunction hpfs_add_to_dnodefunction hpfs_add_direntfunction fromfunction delete_empty_dnodefunction hpfs_remove_direntfunction hpfs_count_dnodesfunction hpfs_de_as_down_as_possiblefunction hpfs_remove_dtree
Annotated Snippet
if (!ppos) {
pr_err("out of memory for position list\n");
return -ENOMEM;
}
if (hpfs_inode->i_rddir_off) {
memcpy(ppos, hpfs_inode->i_rddir_off, i * sizeof(loff_t));
kfree(hpfs_inode->i_rddir_off);
}
hpfs_inode->i_rddir_off = ppos;
}
hpfs_inode->i_rddir_off[i] = pos;
hpfs_inode->i_rddir_off[i + 1] = NULL;
return 0;
}
void hpfs_del_pos(struct inode *inode, loff_t *pos)
{
struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
loff_t **i, **j;
if (!hpfs_inode->i_rddir_off) goto not_f;
for (i = hpfs_inode->i_rddir_off; *i; i++) if (*i == pos) goto fnd;
goto not_f;
fnd:
for (j = i + 1; *j; j++) ;
*i = *(j - 1);
*(j - 1) = NULL;
if (j - 1 == hpfs_inode->i_rddir_off) {
kfree(hpfs_inode->i_rddir_off);
hpfs_inode->i_rddir_off = NULL;
}
return;
not_f:
/*pr_warn("position pointer %p->%08x not found\n",
pos, (int)*pos);*/
return;
}
static void for_all_poss(struct inode *inode, void (*f)(loff_t *, loff_t, loff_t),
loff_t p1, loff_t p2)
{
struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
loff_t **i;
if (!hpfs_inode->i_rddir_off) return;
for (i = hpfs_inode->i_rddir_off; *i; i++) (*f)(*i, p1, p2);
return;
}
static void hpfs_pos_subst(loff_t *p, loff_t f, loff_t t)
{
if (*p == f) *p = t;
}
/*void hpfs_hpfs_pos_substd(loff_t *p, loff_t f, loff_t t)
{
if ((*p & ~0x3f) == (f & ~0x3f)) *p = (t & ~0x3f) | (*p & 0x3f);
}*/
static void hpfs_pos_ins(loff_t *p, loff_t d, loff_t c)
{
if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) {
int n = (*p & 0x3f) + c;
if (n > 0x3f)
pr_err("%s(): %08x + %d\n",
__func__, (int)*p, (int)c >> 8);
else
*p = (*p & ~0x3f) | n;
}
}
static void hpfs_pos_del(loff_t *p, loff_t d, loff_t c)
{
if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) {
int n = (*p & 0x3f) - c;
if (n < 1)
pr_err("%s(): %08x - %d\n",
__func__, (int)*p, (int)c >> 8);
else
*p = (*p & ~0x3f) | n;
}
}
static struct hpfs_dirent *dnode_pre_last_de(struct dnode *d)
{
struct hpfs_dirent *de, *de_end, *dee = NULL, *deee = NULL;
de_end = dnode_end_de(d);
for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) {
deee = dee; dee = de;
}
Annotation
- Immediate include surface: `hpfs_fn.h`.
- Detected declarations: `function Patocka`, `function hpfs_add_pos`, `function hpfs_del_pos`, `function for_all_poss`, `function hpfs_pos_subst`, `function hpfs_pos_ins`, `function hpfs_pos_del`, `function set_last_pointer`, `function hpfs_delete_de`, `function fix_up_ptrs`.
- 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.