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_USER_PREFIX "user."
43 static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
44 size_t list_size, const char *name,
47 const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1;
48 const size_t total_len = prefix_len + name_len + 1;
49 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
51 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
54 if (list && total_len <= list_size) {
55 memcpy(list, XATTR_USER_PREFIX, prefix_len);
56 memcpy(list + prefix_len, name, name_len);
57 list[prefix_len + name_len] = '\0';
62 static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
63 void *buffer, size_t size)
65 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
67 if (strcmp(name, "") == 0)
69 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
71 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
75 static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
76 const void *value, size_t size, int flags)
78 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
80 if (strcmp(name, "") == 0)
82 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
85 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
89 struct xattr_handler ocfs2_xattr_user_handler = {
90 .prefix = XATTR_USER_PREFIX,
91 .list = ocfs2_xattr_user_list,
92 .get = ocfs2_xattr_user_get,
93 .set = ocfs2_xattr_user_set,