fs/hfsplus/attributes.c

Source file repositories/reference/linux-study-clean/fs/hfsplus/attributes.c

File Facts

System
Linux kernel
Corpus path
fs/hfsplus/attributes.c
Extension
.c
Size
11460 bytes
Lines
500
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 (err == -ENOENT) {
			/* file exists but xattr is absent */
			err = -ENODATA;
			goto failed_find_attr;
		} else if (err)
			goto failed_find_attr;
	} else {
		err = hfsplus_attr_build_key(sb, fd->search_key, cnid, NULL);
		if (err)
			goto failed_find_attr;
		err = hfs_brec_find(fd, hfs_find_1st_rec_by_cnid);
		if (err == -ENOENT) {
			/* file exists but xattr is absent */
			err = -ENODATA;
			goto failed_find_attr;
		} else if (err)
			goto failed_find_attr;
	}

failed_find_attr:
	return err;
}

int hfsplus_attr_exists(struct inode *inode, const char *name)
{
	int err = 0;
	struct super_block *sb = inode->i_sb;
	struct hfs_find_data fd;

	hfs_dbg("name %s, ino %llu\n",
		name ? name : NULL, inode->i_ino);

	if (!HFSPLUS_SB(sb)->attr_tree)
		return 0;

	err = hfs_find_init(HFSPLUS_SB(sb)->attr_tree, &fd);
	if (err)
		return 0;

	err = hfsplus_find_attr(sb, inode->i_ino, name, &fd);
	if (err)
		goto attr_not_found;

	hfs_find_exit(&fd);
	return 1;

attr_not_found:
	hfs_find_exit(&fd);
	return 0;
}

static
int hfsplus_create_attr_nolock(struct inode *inode, const char *name,
				const void *value, size_t size,
				struct hfs_find_data *fd,
				hfsplus_attr_entry *entry_ptr)
{
	struct super_block *sb = inode->i_sb;
	int entry_size;
	int err;

	hfs_dbg("name %s, ino %llu\n",
		name ? name : NULL, inode->i_ino);

	if (name) {
		err = hfsplus_attr_build_key(sb, fd->search_key,
						inode->i_ino, name);
		if (err)
			return err;
	} else
		return -EINVAL;

	/* Mac OS X supports only inline data attributes. */
	entry_size = hfsplus_attr_build_record(entry_ptr,
					HFSPLUS_ATTR_INLINE_DATA,
					inode->i_ino,
					value, size);
	if (entry_size == HFSPLUS_INVALID_ATTR_RECORD) {
		if (size > HFSPLUS_MAX_INLINE_DATA_SIZE)
			err = -E2BIG;
		else
			err = -EINVAL;
		hfs_dbg("unable to store value: err %d\n", err);
		return err;
	}

	err = hfs_brec_find(fd, hfs_find_rec_by_key);
	if (err != -ENOENT) {
		if (!err)
			err = -EEXIST;

Annotation

Implementation Notes