fs/fat/misc.c
Source file repositories/reference/linux-study-clean/fs/fat/misc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/fat/misc.c- Extension
.c- Size
- 10100 bytes
- Lines
- 363
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fat.hlinux/iversion.h
Detected Declarations
function panicfunction _fat_msgfunction fat_clusters_flushfunction fat_chain_addfunction generic_write_syncfunction fat_tz_offsetfunction fat_time_fat2unixfunction fat_time_unix2fatfunction fat_timespec64_trunc_2secsfunction granularityfunction fat_truncate_timefunction fat_update_timefunction fat_sync_bhsexport __fat_fs_errorexport fat_time_fat2unixexport fat_time_unix2fatexport fat_truncate_atimeexport fat_truncate_timeexport fat_update_time
Annotated Snippet
else if (opts->errors == FAT_ERRORS_RO && !sb_rdonly(sb)) {
sb->s_flags |= SB_RDONLY;
fat_msg(sb, KERN_ERR, "Filesystem has been set read-only");
}
}
EXPORT_SYMBOL_GPL(__fat_fs_error);
/**
* _fat_msg() - Print a preformatted FAT message based on a superblock.
* @sb: A pointer to a &struct super_block
* @level: A Kernel printk level constant
* @fmt: The printf-style format string to print.
*
* Everything that is not fat_fs_error() should be fat_msg().
*
* fat_msg() wraps _fat_msg() for printk indexing.
*/
void _fat_msg(struct super_block *sb, const char *level, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
_printk(FAT_PRINTK_PREFIX "%pV\n", level, sb->s_id, &vaf);
va_end(args);
}
/* Flushes the number of free clusters on FAT32 */
/* XXX: Need to write one per FSINFO block. Currently only writes 1 */
int fat_clusters_flush(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
struct buffer_head *bh;
struct fat_boot_fsinfo *fsinfo;
if (!is_fat32(sbi))
return 0;
bh = sb_bread(sb, sbi->fsinfo_sector);
if (bh == NULL) {
fat_msg(sb, KERN_ERR, "bread failed in fat_clusters_flush");
return -EIO;
}
fsinfo = (struct fat_boot_fsinfo *)bh->b_data;
/* Sanity check */
if (!IS_FSINFO(fsinfo)) {
fat_msg(sb, KERN_ERR, "Invalid FSINFO signature: "
"0x%08x, 0x%08x (sector = %lu)",
le32_to_cpu(fsinfo->signature1),
le32_to_cpu(fsinfo->signature2),
sbi->fsinfo_sector);
} else {
if (sbi->free_clusters != -1)
fsinfo->free_clusters = cpu_to_le32(sbi->free_clusters);
if (sbi->prev_free != -1)
fsinfo->next_cluster = cpu_to_le32(sbi->prev_free);
mark_buffer_dirty(bh);
}
brelse(bh);
return 0;
}
/*
* fat_chain_add() adds a new cluster to the chain of clusters represented
* by inode.
*/
int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
{
struct super_block *sb = inode->i_sb;
struct msdos_sb_info *sbi = MSDOS_SB(sb);
int ret, new_fclus, last;
/*
* We must locate the last cluster of the file to add this new
* one (new_dclus) to the end of the link list (the FAT).
*/
last = new_fclus = 0;
if (MSDOS_I(inode)->i_start) {
int fclus, dclus;
ret = fat_get_cluster(inode, FAT_ENT_EOF, &fclus, &dclus);
if (ret < 0)
return ret;
new_fclus = fclus + 1;
last = dclus;
}
Annotation
- Immediate include surface: `fat.h`, `linux/iversion.h`.
- Detected declarations: `function panic`, `function _fat_msg`, `function fat_clusters_flush`, `function fat_chain_add`, `function generic_write_sync`, `function fat_tz_offset`, `function fat_time_fat2unix`, `function fat_time_unix2fat`, `function fat_timespec64_trunc_2secs`, `function granularity`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.