xattr.c (84695ffee7987ee1e581be4c4696e47e1a29403b) xattr.c (c25a1e0671fbca7b2c0d0757d533bd2650d6dc0c)
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * xattr.c
5 *
6 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
7 *
8 * CREDITS:

--- 7202 unchanged lines hidden (view full) ---

7211 * Initialize security and acl for a already created inode.
7212 * Used for reflink a non-preserve-security file.
7213 *
7214 * It uses common api like ocfs2_xattr_set, so the caller
7215 * must not hold any lock expect i_mutex.
7216 */
7217int ocfs2_init_security_and_acl(struct inode *dir,
7218 struct inode *inode,
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * xattr.c
5 *
6 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
7 *
8 * CREDITS:

--- 7202 unchanged lines hidden (view full) ---

7211 * Initialize security and acl for a already created inode.
7212 * Used for reflink a non-preserve-security file.
7213 *
7214 * It uses common api like ocfs2_xattr_set, so the caller
7215 * must not hold any lock expect i_mutex.
7216 */
7217int ocfs2_init_security_and_acl(struct inode *dir,
7218 struct inode *inode,
7219 const struct qstr *qstr,
7220 struct posix_acl *default_acl,
7221 struct posix_acl *acl)
7219 const struct qstr *qstr)
7222{
7220{
7223 struct buffer_head *dir_bh = NULL;
7224 int ret = 0;
7221 int ret = 0;
7222 struct buffer_head *dir_bh = NULL;
7225
7226 ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
7227 if (ret) {
7228 mlog_errno(ret);
7229 goto leave;
7230 }
7231
7232 ret = ocfs2_inode_lock(dir, &dir_bh, 0);
7233 if (ret) {
7234 mlog_errno(ret);
7235 goto leave;
7236 }
7223
7224 ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
7225 if (ret) {
7226 mlog_errno(ret);
7227 goto leave;
7228 }
7229
7230 ret = ocfs2_inode_lock(dir, &dir_bh, 0);
7231 if (ret) {
7232 mlog_errno(ret);
7233 goto leave;
7234 }
7235 ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);
7236 if (ret)
7237 mlog_errno(ret);
7237
7238
7238 if (!ret && default_acl)
7239 ret = ocfs2_iop_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
7240 if (!ret && acl)
7241 ret = ocfs2_iop_set_acl(inode, acl, ACL_TYPE_ACCESS);
7242
7243 ocfs2_inode_unlock(dir, 0);
7244 brelse(dir_bh);
7245leave:
7246 return ret;
7247}
7248
7249/*
7250 * 'security' attributes support
7251 */
7252static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
7239 ocfs2_inode_unlock(dir, 0);
7240 brelse(dir_bh);
7241leave:
7242 return ret;
7243}
7244
7245/*
7246 * 'security' attributes support
7247 */
7248static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
7253 struct dentry *unused, struct inode *inode,
7254 const char *name, void *buffer, size_t size)
7249 struct dentry *dentry, const char *name,
7250 void *buffer, size_t size)
7255{
7251{
7256 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY,
7252 return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY,
7257 name, buffer, size);
7258}
7259
7260static int ocfs2_xattr_security_set(const struct xattr_handler *handler,
7261 struct dentry *dentry, const char *name,
7262 const void *value, size_t size, int flags)
7263{
7264 return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY,

--- 51 unchanged lines hidden (view full) ---

7316 .get = ocfs2_xattr_security_get,
7317 .set = ocfs2_xattr_security_set,
7318};
7319
7320/*
7321 * 'trusted' attributes support
7322 */
7323static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
7253 name, buffer, size);
7254}
7255
7256static int ocfs2_xattr_security_set(const struct xattr_handler *handler,
7257 struct dentry *dentry, const char *name,
7258 const void *value, size_t size, int flags)
7259{
7260 return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY,

--- 51 unchanged lines hidden (view full) ---

7312 .get = ocfs2_xattr_security_get,
7313 .set = ocfs2_xattr_security_set,
7314};
7315
7316/*
7317 * 'trusted' attributes support
7318 */
7319static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
7324 struct dentry *unused, struct inode *inode,
7325 const char *name, void *buffer, size_t size)
7320 struct dentry *dentry, const char *name,
7321 void *buffer, size_t size)
7326{
7322{
7327 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED,
7323 return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED,
7328 name, buffer, size);
7329}
7330
7331static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler,
7332 struct dentry *dentry, const char *name,
7333 const void *value, size_t size, int flags)
7334{
7335 return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED,

--- 5 unchanged lines hidden (view full) ---

7341 .get = ocfs2_xattr_trusted_get,
7342 .set = ocfs2_xattr_trusted_set,
7343};
7344
7345/*
7346 * 'user' attributes support
7347 */
7348static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
7324 name, buffer, size);
7325}
7326
7327static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler,
7328 struct dentry *dentry, const char *name,
7329 const void *value, size_t size, int flags)
7330{
7331 return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED,

--- 5 unchanged lines hidden (view full) ---

7337 .get = ocfs2_xattr_trusted_get,
7338 .set = ocfs2_xattr_trusted_set,
7339};
7340
7341/*
7342 * 'user' attributes support
7343 */
7344static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
7349 struct dentry *unusde, struct inode *inode,
7350 const char *name, void *buffer, size_t size)
7345 struct dentry *dentry, const char *name,
7346 void *buffer, size_t size)
7351{
7347{
7352 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7348 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
7353
7354 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
7355 return -EOPNOTSUPP;
7349
7350 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
7351 return -EOPNOTSUPP;
7356 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
7352 return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_USER, name,
7357 buffer, size);
7358}
7359
7360static int ocfs2_xattr_user_set(const struct xattr_handler *handler,
7361 struct dentry *dentry, const char *name,
7362 const void *value, size_t size, int flags)
7363{
7364 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);

--- 13 unchanged lines hidden ---
7353 buffer, size);
7354}
7355
7356static int ocfs2_xattr_user_set(const struct xattr_handler *handler,
7357 struct dentry *dentry, const char *name,
7358 const void *value, size_t size, int flags)
7359{
7360 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);

--- 13 unchanged lines hidden ---