nfs4proc.c (012a211abd5db098094ce429de5f046368391e68) | nfs4proc.c (95ad37f90c338e3fd4abf61cecfe02b6f3e080f0) |
---|---|
1/* 2 * fs/nfs/nfs4proc.c 3 * 4 * Client-side procedure declarations for NFSv4. 5 * 6 * Copyright (c) 2002 The Regents of the University of Michigan. 7 * All rights reserved. 8 * --- 7434 unchanged lines hidden (view full) --- 7443 7444#ifdef CONFIG_NFS_V4_2 7445static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler, 7446 struct dentry *unused, struct inode *inode, 7447 const char *key, const void *buf, 7448 size_t buflen, int flags) 7449{ 7450 struct nfs_access_entry cache; | 1/* 2 * fs/nfs/nfs4proc.c 3 * 4 * Client-side procedure declarations for NFSv4. 5 * 6 * Copyright (c) 2002 The Regents of the University of Michigan. 7 * All rights reserved. 8 * --- 7434 unchanged lines hidden (view full) --- 7443 7444#ifdef CONFIG_NFS_V4_2 7445static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler, 7446 struct dentry *unused, struct inode *inode, 7447 const char *key, const void *buf, 7448 size_t buflen, int flags) 7449{ 7450 struct nfs_access_entry cache; |
7451 int ret; |
|
7451 7452 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7453 return -EOPNOTSUPP; 7454 7455 /* 7456 * There is no mapping from the MAY_* flags to the NFS_ACCESS_XA* 7457 * flags right now. Handling of xattr operations use the normal 7458 * file read/write permissions. 7459 * 7460 * Just in case the server has other ideas (which RFC 8276 allows), 7461 * do a cached access check for the XA* flags to possibly avoid 7462 * doing an RPC and getting EACCES back. 7463 */ 7464 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7465 if (!(cache.mask & NFS_ACCESS_XAWRITE)) 7466 return -EACCES; 7467 } 7468 | 7452 7453 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7454 return -EOPNOTSUPP; 7455 7456 /* 7457 * There is no mapping from the MAY_* flags to the NFS_ACCESS_XA* 7458 * flags right now. Handling of xattr operations use the normal 7459 * file read/write permissions. 7460 * 7461 * Just in case the server has other ideas (which RFC 8276 allows), 7462 * do a cached access check for the XA* flags to possibly avoid 7463 * doing an RPC and getting EACCES back. 7464 */ 7465 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7466 if (!(cache.mask & NFS_ACCESS_XAWRITE)) 7467 return -EACCES; 7468 } 7469 |
7469 if (buf == NULL) 7470 return nfs42_proc_removexattr(inode, key); 7471 else 7472 return nfs42_proc_setxattr(inode, key, buf, buflen, flags); | 7470 if (buf == NULL) { 7471 ret = nfs42_proc_removexattr(inode, key); 7472 if (!ret) 7473 nfs4_xattr_cache_remove(inode, key); 7474 } else { 7475 ret = nfs42_proc_setxattr(inode, key, buf, buflen, flags); 7476 if (!ret) 7477 nfs4_xattr_cache_add(inode, key, buf, NULL, buflen); 7478 } 7479 7480 return ret; |
7473} 7474 7475static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler, 7476 struct dentry *unused, struct inode *inode, 7477 const char *key, void *buf, size_t buflen) 7478{ 7479 struct nfs_access_entry cache; | 7481} 7482 7483static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler, 7484 struct dentry *unused, struct inode *inode, 7485 const char *key, void *buf, size_t buflen) 7486{ 7487 struct nfs_access_entry cache; |
7488 ssize_t ret; |
|
7480 7481 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7482 return -EOPNOTSUPP; 7483 7484 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7485 if (!(cache.mask & NFS_ACCESS_XAREAD)) 7486 return -EACCES; 7487 } 7488 | 7489 7490 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7491 return -EOPNOTSUPP; 7492 7493 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7494 if (!(cache.mask & NFS_ACCESS_XAREAD)) 7495 return -EACCES; 7496 } 7497 |
7489 return nfs42_proc_getxattr(inode, key, buf, buflen); | 7498 ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); 7499 if (ret) 7500 return ret; 7501 7502 ret = nfs4_xattr_cache_get(inode, key, buf, buflen); 7503 if (ret >= 0 || (ret < 0 && ret != -ENOENT)) 7504 return ret; 7505 7506 ret = nfs42_proc_getxattr(inode, key, buf, buflen); 7507 7508 return ret; |
7490} 7491 7492static ssize_t 7493nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) 7494{ 7495 u64 cookie; 7496 bool eof; | 7509} 7510 7511static ssize_t 7512nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) 7513{ 7514 u64 cookie; 7515 bool eof; |
7497 int ret, size; | 7516 ssize_t ret, size; |
7498 char *buf; 7499 size_t buflen; 7500 struct nfs_access_entry cache; 7501 7502 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7503 return 0; 7504 7505 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7506 if (!(cache.mask & NFS_ACCESS_XALIST)) 7507 return 0; 7508 } 7509 | 7517 char *buf; 7518 size_t buflen; 7519 struct nfs_access_entry cache; 7520 7521 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7522 return 0; 7523 7524 if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7525 if (!(cache.mask & NFS_ACCESS_XALIST)) 7526 return 0; 7527 } 7528 |
7529 ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); 7530 if (ret) 7531 return ret; 7532 7533 ret = nfs4_xattr_cache_list(inode, list, list_len); 7534 if (ret >= 0 || (ret < 0 && ret != -ENOENT)) 7535 return ret; 7536 |
|
7510 cookie = 0; 7511 eof = false; 7512 buflen = list_len ? list_len : XATTR_LIST_MAX; 7513 buf = list_len ? list : NULL; 7514 size = 0; 7515 7516 while (!eof) { 7517 ret = nfs42_proc_listxattrs(inode, buf, buflen, 7518 &cookie, &eof); 7519 if (ret < 0) 7520 return ret; 7521 7522 if (list_len) { 7523 buf += ret; 7524 buflen -= ret; 7525 } 7526 size += ret; 7527 } 7528 | 7537 cookie = 0; 7538 eof = false; 7539 buflen = list_len ? list_len : XATTR_LIST_MAX; 7540 buf = list_len ? list : NULL; 7541 size = 0; 7542 7543 while (!eof) { 7544 ret = nfs42_proc_listxattrs(inode, buf, buflen, 7545 &cookie, &eof); 7546 if (ret < 0) 7547 return ret; 7548 7549 if (list_len) { 7550 buf += ret; 7551 buflen -= ret; 7552 } 7553 size += ret; 7554 } 7555 |
7556 if (list_len) 7557 nfs4_xattr_cache_set_list(inode, list, size); 7558 |
|
7529 return size; 7530} 7531 7532#else 7533 7534static ssize_t 7535nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) 7536{ --- 2744 unchanged lines hidden --- | 7559 return size; 7560} 7561 7562#else 7563 7564static ssize_t 7565nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) 7566{ --- 2744 unchanged lines hidden --- |