fs/ufs/namei.c
Source file repositories/reference/linux-study-clean/fs/ufs/namei.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ufs/namei.c- Extension
.c- Size
- 7586 bytes
- Lines
- 331
- 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
linux/time.hlinux/fs.hufs_fs.hufs.hutil.h
Detected Declarations
function Copyrightfunction d_instantiatefunction ufs_mknodfunction ufs_symlinkfunction ufs_linkfunction ufs_unlinkfunction ufs_rmdirfunction ufs_rename
Annotated Snippet
if (!err) {
inode->i_size = 0;
inode_dec_link_count(inode);
inode_dec_link_count(dir);
}
}
return err;
}
static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry);
struct folio *dir_folio = NULL;
struct ufs_dir_entry * dir_de = NULL;
struct folio *old_folio;
struct ufs_dir_entry *old_de;
int err;
if (flags & ~RENAME_NOREPLACE)
return -EINVAL;
old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_folio);
if (!old_de)
return -ENOENT;
if (S_ISDIR(old_inode->i_mode)) {
err = -EIO;
dir_de = ufs_dotdot(old_inode, &dir_folio);
if (!dir_de)
goto out_old;
}
if (new_inode) {
struct folio *new_folio;
struct ufs_dir_entry *new_de;
err = -ENOTEMPTY;
if (dir_de && !ufs_empty_dir(new_inode))
goto out_dir;
err = -ENOENT;
new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_folio);
if (!new_de)
goto out_dir;
err = ufs_set_link(new_dir, new_de, new_folio, old_inode, 1);
folio_release_kmap(new_folio, new_de);
if (err)
goto out_dir;
inode_set_ctime_current(new_inode);
if (dir_de)
drop_nlink(new_inode);
inode_dec_link_count(new_inode);
} else {
err = ufs_add_link(new_dentry, old_inode);
if (err)
goto out_dir;
if (dir_de)
inode_inc_link_count(new_dir);
}
/*
* Like most other Unix systems, set the ctime for inodes on a
* rename.
*/
inode_set_ctime_current(old_inode);
mark_inode_dirty(old_inode);
err = ufs_delete_entry(old_dir, old_de, old_folio);
if (!err && dir_de) {
if (old_dir != new_dir)
err = ufs_set_link(old_inode, dir_de, dir_folio,
new_dir, 0);
inode_dec_link_count(old_dir);
}
out_dir:
if (dir_de)
folio_release_kmap(dir_folio, dir_de);
out_old:
folio_release_kmap(old_folio, old_de);
return err;
}
const struct inode_operations ufs_dir_inode_operations = {
.create = ufs_create,
.lookup = ufs_lookup,
.link = ufs_link,
.unlink = ufs_unlink,
Annotation
- Immediate include surface: `linux/time.h`, `linux/fs.h`, `ufs_fs.h`, `ufs.h`, `util.h`.
- Detected declarations: `function Copyright`, `function d_instantiate`, `function ufs_mknod`, `function ufs_symlink`, `function ufs_link`, `function ufs_unlink`, `function ufs_rmdir`, `function ufs_rename`.
- 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.