1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
6 * Copyright (C) 2008 Oracle. All rights reserved.
9 * Lots of code in this file is taken from ext3.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public
22 * License along with this program; if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 021110-1307, USA.
27 #include <linux/init.h>
28 #include <linux/module.h>
29 #include <linux/string.h>
31 #define MLOG_MASK_PREFIX ML_INODE
32 #include <cluster/masklog.h>
41 #define XATTR_TRUSTED_PREFIX "trusted."
43 static size_t ocfs2_xattr_trusted_list(struct inode
*inode
, char *list
,
44 size_t list_size
, const char *name
,
47 const size_t prefix_len
= sizeof(XATTR_TRUSTED_PREFIX
) - 1;
48 const size_t total_len
= prefix_len
+ name_len
+ 1;
50 if (list
&& total_len
<= list_size
) {
51 memcpy(list
, XATTR_TRUSTED_PREFIX
, prefix_len
);
52 memcpy(list
+ prefix_len
, name
, name_len
);
53 list
[prefix_len
+ name_len
] = '\0';
58 static int ocfs2_xattr_trusted_get(struct inode
*inode
, const char *name
,
59 void *buffer
, size_t size
)
61 if (strcmp(name
, "") == 0)
63 return ocfs2_xattr_get(inode
, OCFS2_XATTR_INDEX_TRUSTED
, name
,
67 static int ocfs2_xattr_trusted_set(struct inode
*inode
, const char *name
,
68 const void *value
, size_t size
, int flags
)
70 if (strcmp(name
, "") == 0)
73 return ocfs2_xattr_set(inode
, OCFS2_XATTR_INDEX_TRUSTED
, name
, value
,
77 struct xattr_handler ocfs2_xattr_trusted_handler
= {
78 .prefix
= XATTR_TRUSTED_PREFIX
,
79 .list
= ocfs2_xattr_trusted_list
,
80 .get
= ocfs2_xattr_trusted_get
,
81 .set
= ocfs2_xattr_trusted_set
,