fs/f2fs/namei.c

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

File Facts

System
Linux kernel
Corpus path
fs/f2fs/namei.c
Extension
.c
Size
34190 bytes
Lines
1403
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 (!strncasecmp(s + i + 1, sub, sublen)) {
			if (!tmp_dot)
				return true;
			if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.')
				return true;
		}
	}

	return false;
}

static inline bool is_temperature_extension(const unsigned char *s, const char *sub)
{
	return is_extension_exist(s, sub, true, false);
}

static inline bool is_compress_extension(const unsigned char *s, const char *sub)
{
	return is_extension_exist(s, sub, true, true);
}

int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
							bool hot, bool set)
{
	__u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list;
	int cold_count = le32_to_cpu(sbi->raw_super->extension_count);
	int hot_count = sbi->raw_super->hot_ext_count;
	int total_count = cold_count + hot_count;
	int start, count;
	int i;

	if (set) {
		if (total_count == F2FS_MAX_EXTENSION)
			return -EINVAL;

		if (hot) {
			start = 0;
			count = cold_count;
		} else {
			start = cold_count;
			count = total_count;
		}
		for (i = start; i < count; i++) {
			if (!strcmp(name, extlist[i])) {
				f2fs_warn(sbi, "extension '%s' already exists in %s list",
					  name, hot ? "cold" : "hot");
				return -EINVAL;
			}
		}
	} else {
		if (!hot && !cold_count)
			return -EINVAL;
		if (hot && !hot_count)
			return -EINVAL;
	}

	if (hot) {
		start = cold_count;
		count = total_count;
	} else {
		start = 0;
		count = cold_count;
	}

	for (i = start; i < count; i++) {
		if (strcmp(name, extlist[i]))
			continue;

		if (set)
			return -EINVAL;

		memcpy(extlist[i], extlist[i + 1],
				F2FS_EXTENSION_LEN * (total_count - i - 1));
		memset(extlist[total_count - 1], 0, F2FS_EXTENSION_LEN);
		if (hot)
			sbi->raw_super->hot_ext_count = hot_count - 1;
		else
			sbi->raw_super->extension_count =
						cpu_to_le32(cold_count - 1);
		return 0;
	}

	if (!set)
		return -EINVAL;

	if (hot) {
		memcpy(extlist[count], name, strlen(name));
		sbi->raw_super->hot_ext_count = hot_count + 1;
	} else {
		char buf[F2FS_MAX_EXTENSION][F2FS_EXTENSION_LEN];

Annotation

Implementation Notes