ocfs2: Uninline ocfs2_xattr_name_hash()
[linux-2.6/mini2440.git] / fs / ocfs2 / xattr_user.c
blob93ba71637788e58017f65d63ae7874cec016c90a
1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
4 * xattr_user.c
6 * Copyright (C) 2008 Oracle. All rights reserved.
8 * CREDITS:
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>
34 #include "ocfs2.h"
35 #include "alloc.h"
36 #include "dlmglue.h"
37 #include "file.h"
38 #include "ocfs2_fs.h"
39 #include "xattr.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,
45 size_t name_len)
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)
52 return 0;
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';
59 return total_len;
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)
68 return -EINVAL;
69 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
70 return -EOPNOTSUPP;
71 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
72 buffer, size);
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)
81 return -EINVAL;
82 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
83 return -EOPNOTSUPP;
85 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
86 size, flags);
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,