linux/fs/f2fs/xattr.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * fs/f2fs/xattr.h
 *
 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
 *             http://www.samsung.com/
 *
 * Portions of this code from linux/fs/ext2/xattr.h
 *
 * On-disk format of extended attributes for the ext2 filesystem.
 *
 * (C) 2001 Andreas Gruenbacher, <[email protected]>
 */
#ifndef __F2FS_XATTR_H__
#define __F2FS_XATTR_H__

#include <linux/init.h>
#include <linux/xattr.h>

/* Magic value in attribute blocks */
#define F2FS_XATTR_MAGIC

/* Maximum number of references to one attribute block */
#define F2FS_XATTR_REFCOUNT_MAX

/* Name indexes */
#define F2FS_SYSTEM_ADVISE_NAME
#define F2FS_XATTR_INDEX_USER
#define F2FS_XATTR_INDEX_POSIX_ACL_ACCESS
#define F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT
#define F2FS_XATTR_INDEX_TRUSTED
#define F2FS_XATTR_INDEX_LUSTRE
#define F2FS_XATTR_INDEX_SECURITY
#define F2FS_XATTR_INDEX_ADVISE
/* Should be same as EXT4_XATTR_INDEX_ENCRYPTION */
#define F2FS_XATTR_INDEX_ENCRYPTION
#define F2FS_XATTR_INDEX_VERITY

#define F2FS_XATTR_NAME_ENCRYPTION_CONTEXT
#define F2FS_XATTR_NAME_VERITY

struct f2fs_xattr_header {};

struct f2fs_xattr_entry {};

#define XATTR_HDR(ptr)
#define XATTR_ENTRY(ptr)
#define XATTR_FIRST_ENTRY(ptr)
#define XATTR_ROUND

#define XATTR_ALIGN(size)

#define ENTRY_SIZE(entry)

#define XATTR_NEXT_ENTRY(entry)

#define IS_XATTR_LAST_ENTRY(entry)

#define list_for_each_xattr(entry, addr)
#define VALID_XATTR_BLOCK_SIZE
#define XATTR_PADDING_SIZE
#define XATTR_SIZE(i)
#define MIN_OFFSET(i)

#define MAX_VALUE_LEN(i)

#define MIN_INLINE_XATTR_SIZE
#define MAX_INLINE_XATTR_SIZE

/*
 * On-disk structure of f2fs_xattr
 * We use inline xattrs space + 1 block for xattr.
 *
 * +--------------------+
 * | f2fs_xattr_header  |
 * |                    |
 * +--------------------+
 * | f2fs_xattr_entry   |
 * | .e_name_index = 1  |
 * | .e_name_len = 3    |
 * | .e_value_size = 14 |
 * | .e_name = "foo"    |
 * | "value_of_xattr"   |<- value_offs = e_name + e_name_len
 * +--------------------+
 * | f2fs_xattr_entry   |
 * | .e_name_index = 4  |
 * | .e_name = "bar"    |
 * +--------------------+
 * |                    |
 * |        Free        |
 * |                    |
 * +--------------------+<- MIN_OFFSET
 * |   node_footer      |
 * | (nid, ino, offset) |
 * +--------------------+
 *
 **/

#ifdef CONFIG_F2FS_FS_XATTR
extern const struct xattr_handler f2fs_xattr_user_handler;
extern const struct xattr_handler f2fs_xattr_trusted_handler;
extern const struct xattr_handler f2fs_xattr_advise_handler;
extern const struct xattr_handler f2fs_xattr_security_handler;

extern const struct xattr_handler * const f2fs_xattr_handlers[];

extern int f2fs_setxattr(struct inode *, int, const char *,
				const void *, size_t, struct page *, int);
extern int f2fs_getxattr(struct inode *, int, const char *, void *,
						size_t, struct page *);
extern ssize_t f2fs_listxattr(struct dentry *, char *, size_t);
extern int f2fs_init_xattr_caches(struct f2fs_sb_info *);
extern void f2fs_destroy_xattr_caches(struct f2fs_sb_info *);
#else

#define f2fs_xattr_handlers
#define f2fs_listxattr
static inline int f2fs_setxattr(struct inode *inode, int index,
		const char *name, const void *value, size_t size,
		struct page *page, int flags)
{
	return -EOPNOTSUPP;
}
static inline int f2fs_getxattr(struct inode *inode, int index,
			const char *name, void *buffer,
			size_t buffer_size, struct page *dpage)
{
	return -EOPNOTSUPP;
}
static inline int f2fs_init_xattr_caches(struct f2fs_sb_info *sbi) { return 0; }
static inline void f2fs_destroy_xattr_caches(struct f2fs_sb_info *sbi) { }
#endif

#ifdef CONFIG_F2FS_FS_SECURITY
extern int f2fs_init_security(struct inode *, struct inode *,
				const struct qstr *, struct page *);
#else
static inline int f2fs_init_security(struct inode *inode, struct inode *dir,
				const struct qstr *qstr, struct page *ipage)
{
	return 0;
}
#endif
#endif /* __F2FS_XATTR_H__ */