fs/exfat/namei.c

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

File Facts

System
Linux kernel
Corpus path
fs/exfat/namei.c
Extension
.c
Size
35316 bytes
Lines
1337
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 (u_a <= 0xFFFF && u_b <= 0xFFFF) {
			if (exfat_toupper(sb, u_a) != exfat_toupper(sb, u_b))
				return 1;
		} else {
			if (u_a != u_b)
				return 1;
		}
	}

	return 0;
}

const struct dentry_operations exfat_utf8_dentry_ops = {
	.d_revalidate	= exfat_d_revalidate,
	.d_hash		= exfat_utf8_d_hash,
	.d_compare	= exfat_utf8_d_cmp,
};

/* search EMPTY CONTINUOUS "num_entries" entries */
static int exfat_search_empty_slot(struct super_block *sb,
		struct exfat_hint_femp *hint_femp, struct exfat_chain *p_dir,
		int num_entries, struct exfat_entry_set_cache *es)
{
	int i, dentry, ret;
	int dentries_per_clu;
	struct exfat_chain clu;
	struct exfat_sb_info *sbi = EXFAT_SB(sb);
	unsigned int total_entries = exfat_cluster_to_dentries(sbi, p_dir->size);

	dentries_per_clu = sbi->dentries_per_clu;

	if (hint_femp->eidx != EXFAT_HINT_NONE) {
		dentry = hint_femp->eidx;

		/*
		 * If hint_femp->count is enough, it is needed to check if
		 * there are actual empty entries.
		 * Otherwise, and if "dentry + hint_famp->count" is also equal
		 * to "p_dir->size * dentries_per_clu", it means ENOSPC.
		 */
		if (dentry + hint_femp->count == total_entries &&
		    num_entries > hint_femp->count)
			return -ENOSPC;

		hint_femp->eidx = EXFAT_HINT_NONE;
		exfat_chain_dup(&clu, &hint_femp->cur);
	} else {
		exfat_chain_dup(&clu, p_dir);
		dentry = 0;
	}

	while (dentry + num_entries <= total_entries &&
	       clu.dir != EXFAT_EOF_CLUSTER) {
		i = dentry & (dentries_per_clu - 1);

		ret = exfat_get_empty_dentry_set(es, sb, &clu, i, num_entries);
		if (ret < 0)
			return ret;
		else if (ret == 0)
			return dentry;

		dentry += ret;
		i += ret;

		while (i >= dentries_per_clu) {
			if (exfat_chain_advance(sb, &clu, 1))
				return -EIO;

			i -= dentries_per_clu;
		}
	}

	hint_femp->eidx = dentry;
	hint_femp->count = 0;
	if (dentry == total_entries || clu.dir == EXFAT_EOF_CLUSTER)
		exfat_chain_set(&hint_femp->cur, EXFAT_EOF_CLUSTER, 0,
				clu.flags);
	else
		hint_femp->cur = clu;

	return -ENOSPC;
}

static int exfat_check_max_dentries(struct inode *inode)
{
	if (exfat_bytes_to_dentries(i_size_read(inode)) >= MAX_EXFAT_DENTRIES) {
		/*
		 * exFAT spec allows a dir to grow up to 8388608(256MB)
		 * dentries
		 */

Annotation

Implementation Notes