162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * linux/fs/ext4/xattr_hurd.c
462306a36Sopenharmony_ci * Handler for extended gnu attributes for the Hurd.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
762306a36Sopenharmony_ci * Copyright (C) 2020 by Jan (janneke) Nieuwenhuizen, <janneke@gnu.org>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/init.h>
1162306a36Sopenharmony_ci#include <linux/string.h>
1262306a36Sopenharmony_ci#include "ext4.h"
1362306a36Sopenharmony_ci#include "xattr.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistatic bool
1662306a36Sopenharmony_ciext4_xattr_hurd_list(struct dentry *dentry)
1762306a36Sopenharmony_ci{
1862306a36Sopenharmony_ci	return test_opt(dentry->d_sb, XATTR_USER);
1962306a36Sopenharmony_ci}
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_cistatic int
2262306a36Sopenharmony_ciext4_xattr_hurd_get(const struct xattr_handler *handler,
2362306a36Sopenharmony_ci		    struct dentry *unused, struct inode *inode,
2462306a36Sopenharmony_ci		    const char *name, void *buffer, size_t size)
2562306a36Sopenharmony_ci{
2662306a36Sopenharmony_ci	if (!test_opt(inode->i_sb, XATTR_USER))
2762306a36Sopenharmony_ci		return -EOPNOTSUPP;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	return ext4_xattr_get(inode, EXT4_XATTR_INDEX_HURD,
3062306a36Sopenharmony_ci			      name, buffer, size);
3162306a36Sopenharmony_ci}
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cistatic int
3462306a36Sopenharmony_ciext4_xattr_hurd_set(const struct xattr_handler *handler,
3562306a36Sopenharmony_ci		    struct mnt_idmap *idmap,
3662306a36Sopenharmony_ci		    struct dentry *unused, struct inode *inode,
3762306a36Sopenharmony_ci		    const char *name, const void *value,
3862306a36Sopenharmony_ci		    size_t size, int flags)
3962306a36Sopenharmony_ci{
4062306a36Sopenharmony_ci	if (!test_opt(inode->i_sb, XATTR_USER))
4162306a36Sopenharmony_ci		return -EOPNOTSUPP;
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci	return ext4_xattr_set(inode, EXT4_XATTR_INDEX_HURD,
4462306a36Sopenharmony_ci			      name, value, size, flags);
4562306a36Sopenharmony_ci}
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciconst struct xattr_handler ext4_xattr_hurd_handler = {
4862306a36Sopenharmony_ci	.prefix	= XATTR_HURD_PREFIX,
4962306a36Sopenharmony_ci	.list	= ext4_xattr_hurd_list,
5062306a36Sopenharmony_ci	.get	= ext4_xattr_hurd_get,
5162306a36Sopenharmony_ci	.set	= ext4_xattr_hurd_set,
5262306a36Sopenharmony_ci};
53