fs/exfat/inode.c

Source file repositories/reference/linux-study-clean/fs/exfat/inode.c

File Facts

System
Linux kernel
Corpus path
fs/exfat/inode.c
Extension
.c
Size
12411 bytes
Lines
461
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (clu_offset < num_clusters) {
			*clu += clu_offset;
			*count = min(num_clusters - clu_offset, *count);
		} else {
			*clu = EXFAT_EOF_CLUSTER;
			*count = 0;
		}
	} else {
		int err = exfat_get_cluster(inode, clu_offset,
				clu, count, &last_clu);
		if (err)
			return -EIO;
	}

	if (*clu == EXFAT_EOF_CLUSTER) {
		exfat_set_volume_dirty(sb);

		new_clu.dir = (last_clu == EXFAT_EOF_CLUSTER) ?
				EXFAT_EOF_CLUSTER : last_clu + 1;
		new_clu.size = 0;
		new_clu.flags = ei->flags;

		/* allocate a cluster */
		if (num_to_be_allocated < 1) {
			/* Broken FAT (i_sze > allocated FAT) */
			exfat_fs_error(sb, "broken FAT chain.");
			return -EIO;
		}

		ret = exfat_alloc_cluster(inode, num_to_be_allocated, &new_clu,
				inode_needs_sync(inode), true);
		if (ret)
			return ret;

		if (new_clu.dir == EXFAT_EOF_CLUSTER ||
		    new_clu.dir == EXFAT_FREE_CLUSTER) {
			exfat_fs_error(sb,
				"bogus cluster new allocated (last_clu : %u, new_clu : %u)",
				last_clu, new_clu.dir);
			return -EIO;
		}

		/* append to the FAT chain */
		if (last_clu == EXFAT_EOF_CLUSTER) {
			if (new_clu.flags == ALLOC_FAT_CHAIN)
				ei->flags = ALLOC_FAT_CHAIN;
			ei->start_clu = new_clu.dir;
		} else {
			if (new_clu.flags != ei->flags) {
				/* no-fat-chain bit is disabled,
				 * so fat-chain should be synced with
				 * alloc-bitmap
				 */
				if (exfat_chain_cont_cluster(sb, ei->start_clu,
						num_clusters))
					return -EIO;
				ei->flags = ALLOC_FAT_CHAIN;
			}
			if (new_clu.flags == ALLOC_FAT_CHAIN)
				if (exfat_ent_set(sb, last_clu, new_clu.dir))
					return -EIO;
		}

		*clu = new_clu.dir;
		*count = new_clu.size;

		inode->i_blocks += exfat_cluster_to_sectors(sbi, new_clu.size);
		if (balloc)
			*balloc = true;
	}

	/* hint information */
	ei->hint_bmap.off = local_clu_offset;
	ei->hint_bmap.clu = *clu;

	return 0;
}

static int exfat_read_folio(struct file *file, struct folio *folio)
{
	struct iomap_read_folio_ctx ctx = {
		.cur_folio = folio,
		.ops = &exfat_iomap_bio_read_ops,
	};

	iomap_read_folio(&exfat_iomap_ops, &ctx, NULL);
	return 0;
}

static void exfat_readahead(struct readahead_control *rac)

Annotation

Implementation Notes