fs/jffs2/file.c
Source file repositories/reference/linux-study-clean/fs/jffs2/file.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/file.c- Extension
.c- Size
- 9697 bytes
- Lines
- 337
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/kernel.hlinux/fs.hlinux/filelock.hlinux/time.hlinux/pagemap.hlinux/highmem.hlinux/crc32.hlinux/jffs2.hnodelist.h
Detected Declarations
function jffs2_fsyncfunction jffs2_do_readpage_nolockfunction __jffs2_read_foliofunction jffs2_read_foliofunction jffs2_write_beginfunction jffs2_write_end
Annotated Snippet
const struct file_operations jffs2_file_operations =
{
.llseek = generic_file_llseek,
.open = generic_file_open,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,
.unlocked_ioctl=jffs2_ioctl,
.mmap_prepare = generic_file_readonly_mmap_prepare,
.fsync = jffs2_fsync,
.splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.setlease = generic_setlease,
};
/* jffs2_file_inode_operations */
const struct inode_operations jffs2_file_inode_operations =
{
.get_inode_acl = jffs2_get_acl,
.set_acl = jffs2_set_acl,
.setattr = jffs2_setattr,
.listxattr = jffs2_listxattr,
};
const struct address_space_operations jffs2_file_address_operations =
{
.read_folio = jffs2_read_folio,
.write_begin = jffs2_write_begin,
.write_end = jffs2_write_end,
};
static int jffs2_do_readpage_nolock(struct inode *inode, struct folio *folio)
{
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
unsigned char *kaddr;
int ret;
jffs2_dbg(2, "%s(): ino #%llu, page at offset 0x%lx\n",
__func__, inode->i_ino, folio->index << PAGE_SHIFT);
BUG_ON(!folio_test_locked(folio));
kaddr = kmap_local_folio(folio, 0);
ret = jffs2_read_inode_range(c, f, kaddr, folio->index << PAGE_SHIFT,
PAGE_SIZE);
kunmap_local(kaddr);
if (!ret)
folio_mark_uptodate(folio);
flush_dcache_folio(folio);
jffs2_dbg(2, "readpage finished\n");
return ret;
}
int __jffs2_read_folio(struct file *file, struct folio *folio)
{
int ret = jffs2_do_readpage_nolock(folio->mapping->host, folio);
folio_unlock(folio);
return ret;
}
static int jffs2_read_folio(struct file *file, struct folio *folio)
{
struct jffs2_inode_info *f = JFFS2_INODE_INFO(folio->mapping->host);
int ret;
mutex_lock(&f->sem);
ret = __jffs2_read_folio(file, folio);
mutex_unlock(&f->sem);
return ret;
}
static int jffs2_write_begin(const struct kiocb *iocb,
struct address_space *mapping,
loff_t pos, unsigned len,
struct folio **foliop, void **fsdata)
{
struct folio *folio;
struct inode *inode = mapping->host;
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
pgoff_t index = pos >> PAGE_SHIFT;
int ret = 0;
jffs2_dbg(1, "%s()\n", __func__);
if (pos > inode->i_size) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/fs.h`, `linux/filelock.h`, `linux/time.h`, `linux/pagemap.h`, `linux/highmem.h`, `linux/crc32.h`, `linux/jffs2.h`.
- Detected declarations: `function jffs2_fsync`, `function jffs2_do_readpage_nolock`, `function __jffs2_read_folio`, `function jffs2_read_folio`, `function jffs2_write_begin`, `function jffs2_write_end`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.