nfs4_attr.c (602:4ef537c7acd0) | nfs4_attr.c (11291:80bdcd03e626) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* |
23 * Copyright 2005 Sun Microsystems, Inc. 24 * All rights reserved. Use is subject to license terms. | 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. |
25 */ 26 | 24 */ 25 |
27#pragma ident "%Z%%M% %I% %E% SMI" 28 | |
29#include <sys/time.h> 30#include <sys/systm.h> 31 32#include <nfs/nfs.h> 33#include <nfs/nfs4.h> 34#include <nfs/rnode4.h> 35#include <nfs/nfs4_clnt.h> 36#include <sys/cmn_err.h> --- 65 unchanged lines hidden (view full) --- 102 */ 103 if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, 104 FALSE)) 105 retval = FALSE; 106 break; 107 case AT_ATIME: 108 if ((ntovp->nval != FATTR4_TIME_ACCESS) || 109 (*errorp = nfs4_time_vton(&vap->va_ctime, | 26#include <sys/time.h> 27#include <sys/systm.h> 28 29#include <nfs/nfs.h> 30#include <nfs/nfs4.h> 31#include <nfs/rnode4.h> 32#include <nfs/nfs4_clnt.h> 33#include <sys/cmn_err.h> --- 65 unchanged lines hidden (view full) --- 99 */ 100 if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, 101 FALSE)) 102 retval = FALSE; 103 break; 104 case AT_ATIME: 105 if ((ntovp->nval != FATTR4_TIME_ACCESS) || 106 (*errorp = nfs4_time_vton(&vap->va_ctime, |
110 &nap->time_access))) { | 107 &nap->time_access))) { |
111 /* 112 * either asked for FATTR4_TIME_ACCESS_SET - 113 * not used for setattr 114 * or system time invalid for otw transfers 115 */ 116 retval = FALSE; 117 } 118 break; 119 case AT_MTIME: 120 if ((ntovp->nval != FATTR4_TIME_MODIFY) || 121 (*errorp = nfs4_time_vton(&vap->va_mtime, | 108 /* 109 * either asked for FATTR4_TIME_ACCESS_SET - 110 * not used for setattr 111 * or system time invalid for otw transfers 112 */ 113 retval = FALSE; 114 } 115 break; 116 case AT_MTIME: 117 if ((ntovp->nval != FATTR4_TIME_MODIFY) || 118 (*errorp = nfs4_time_vton(&vap->va_mtime, |
122 &nap->time_modify))) { | 119 &nap->time_modify))) { |
123 /* 124 * either asked for FATTR4_TIME_MODIFY_SET - 125 * not used for setattr 126 * or system time invalid for otw transfers 127 */ 128 retval = FALSE; 129 } 130 break; 131 case AT_CTIME: 132 if (*errorp = nfs4_time_vton(&vap->va_ctime, | 120 /* 121 * either asked for FATTR4_TIME_MODIFY_SET - 122 * not used for setattr 123 * or system time invalid for otw transfers 124 */ 125 retval = FALSE; 126 } 127 break; 128 case AT_CTIME: 129 if (*errorp = nfs4_time_vton(&vap->va_ctime, |
133 &nap->time_metadata)) { | 130 &nap->time_metadata)) { |
134 /* 135 * system time invalid for otw transfers 136 */ 137 retval = FALSE; 138 } 139 break; 140 default: 141 retval = FALSE; --- 49 unchanged lines hidden (view full) --- 191 */ 192 if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, 193 FALSE)) 194 retval = FALSE; 195 break; 196 case AT_ATIME: 197 if ((ntovp->nval != FATTR4_TIME_ACCESS_SET) || 198 (*errorp = timestruc_to_settime4(&vap->va_atime, | 131 /* 132 * system time invalid for otw transfers 133 */ 134 retval = FALSE; 135 } 136 break; 137 default: 138 retval = FALSE; --- 49 unchanged lines hidden (view full) --- 188 */ 189 if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, 190 FALSE)) 191 retval = FALSE; 192 break; 193 case AT_ATIME: 194 if ((ntovp->nval != FATTR4_TIME_ACCESS_SET) || 195 (*errorp = timestruc_to_settime4(&vap->va_atime, |
199 &nap->time_access_set, flags))) { | 196 &nap->time_access_set, flags))) { |
200 /* FATTR4_TIME_ACCESS - not used for verify */ 201 retval = FALSE; 202 } 203 break; 204 case AT_MTIME: 205 if ((ntovp->nval != FATTR4_TIME_MODIFY_SET) || 206 (*errorp = timestruc_to_settime4(&vap->va_mtime, | 197 /* FATTR4_TIME_ACCESS - not used for verify */ 198 retval = FALSE; 199 } 200 break; 201 case AT_MTIME: 202 if ((ntovp->nval != FATTR4_TIME_MODIFY_SET) || 203 (*errorp = timestruc_to_settime4(&vap->va_mtime, |
207 &nap->time_modify_set, flags))) { | 204 &nap->time_modify_set, flags))) { |
208 /* FATTR4_TIME_MODIFY - not used for verify */ 209 retval = FALSE; 210 } 211 break; 212 default: 213 /* 214 * If the ntovp->vbit == 0 this is most likely the ACL. 215 */ --- 39 unchanged lines hidden (view full) --- 255 * 8 bit quantity. 256 */ 257 ASSERT(NFS4_MAXNUM_ATTRS <= (UINT8_MAX + 1)); 258#endif 259 fattrp->attrmask = 0; 260 fattrp->attrlist4_len = 0; 261 fattrp->attrlist4 = NULL; 262 na = kmem_zalloc(sizeof (union nfs4_attr_u) * nfs4_ntov_map_size, | 205 /* FATTR4_TIME_MODIFY - not used for verify */ 206 retval = FALSE; 207 } 208 break; 209 default: 210 /* 211 * If the ntovp->vbit == 0 this is most likely the ACL. 212 */ --- 39 unchanged lines hidden (view full) --- 252 * 8 bit quantity. 253 */ 254 ASSERT(NFS4_MAXNUM_ATTRS <= (UINT8_MAX + 1)); 255#endif 256 fattrp->attrmask = 0; 257 fattrp->attrlist4_len = 0; 258 fattrp->attrlist4 = NULL; 259 na = kmem_zalloc(sizeof (union nfs4_attr_u) * nfs4_ntov_map_size, |
263 KM_SLEEP); | 260 KM_SLEEP); |
264 265 if (op == OP_SETATTR || op == OP_CREATE || op == OP_OPEN) { 266 /* 267 * Note we need to set the attrmask for set operations. 268 * In particular mtime and atime will be set to the 269 * servers time. 270 */ 271 nfs4_vmask_to_nmask_set(va_mask, &fattrp->attrmask); --- 64 unchanged lines hidden (view full) --- 336 * 3 words, since we are using the server's 337 * time as the current time. Exception: if 338 * ATTR_UTIME is set, the client sends the 339 * time, so leave the xdr size alone. 340 */ 341 xdr_size += nfs4_ntov_map[i].xdr_size; 342 if ((nfs4_ntov_map[i].nval == FATTR4_TIME_ACCESS_SET || 343 nfs4_ntov_map[i].nval == FATTR4_TIME_MODIFY_SET) && | 261 262 if (op == OP_SETATTR || op == OP_CREATE || op == OP_OPEN) { 263 /* 264 * Note we need to set the attrmask for set operations. 265 * In particular mtime and atime will be set to the 266 * servers time. 267 */ 268 nfs4_vmask_to_nmask_set(va_mask, &fattrp->attrmask); --- 64 unchanged lines hidden (view full) --- 333 * 3 words, since we are using the server's 334 * time as the current time. Exception: if 335 * ATTR_UTIME is set, the client sends the 336 * time, so leave the xdr size alone. 337 */ 338 xdr_size += nfs4_ntov_map[i].xdr_size; 339 if ((nfs4_ntov_map[i].nval == FATTR4_TIME_ACCESS_SET || 340 nfs4_ntov_map[i].nval == FATTR4_TIME_MODIFY_SET) && |
344 attrfunc == nfs4_set_fattr4_attr && 345 !(flags & ATTR_UTIME)) { | 341 attrfunc == nfs4_set_fattr4_attr && 342 !(flags & ATTR_UTIME)) { |
346 xdr_size -= 3 * BYTES_PER_XDR_UNIT; 347 } 348 } else { 349 /* 350 * The only zero xdr_sizes we should see 351 * are AT_UID, AT_GID and FATTR4_ACL_MASK 352 */ 353 ASSERT(nfs4_ntov_map[i].vbit == AT_UID || | 343 xdr_size -= 3 * BYTES_PER_XDR_UNIT; 344 } 345 } else { 346 /* 347 * The only zero xdr_sizes we should see 348 * are AT_UID, AT_GID and FATTR4_ACL_MASK 349 */ 350 ASSERT(nfs4_ntov_map[i].vbit == AT_UID || |
354 nfs4_ntov_map[i].vbit == AT_GID || 355 nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK); | 351 nfs4_ntov_map[i].vbit == AT_GID || 352 nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK); |
356 if (nfs4_ntov_map[i].vbit == AT_UID) { 357 uid_attr = attrcnt; 358 xdr_size += BYTES_PER_XDR_UNIT; /* length */ 359 xdr_size += | 353 if (nfs4_ntov_map[i].vbit == AT_UID) { 354 uid_attr = attrcnt; 355 xdr_size += BYTES_PER_XDR_UNIT; /* length */ 356 xdr_size += |
360 RNDUP(na[attrcnt].owner.utf8string_len); | 357 RNDUP(na[attrcnt].owner.utf8string_len); |
361 } else if (nfs4_ntov_map[i].vbit == AT_GID) { 362 gid_attr = attrcnt; 363 xdr_size += BYTES_PER_XDR_UNIT; /* length */ 364 xdr_size += 365 RNDUP( | 358 } else if (nfs4_ntov_map[i].vbit == AT_GID) { 359 gid_attr = attrcnt; 360 xdr_size += BYTES_PER_XDR_UNIT; /* length */ 361 xdr_size += 362 RNDUP( |
366 na[attrcnt].owner_group.utf8string_len); | 363 na[attrcnt].owner_group.utf8string_len); |
367 } else if (nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK) { 368 nfsace4 *tmpacl = (nfsace4 *)vsap->vsa_aclentp; 369 370 acl_attr = attrcnt; 371 /* fattr4_acl_len */ 372 xdr_size += BYTES_PER_XDR_UNIT; 373 /* fattr4_acl_val */ 374 xdr_size += RNDUP((vsap->vsa_aclcnt * --- 31 unchanged lines hidden (view full) --- 406 } 407 408 fattrp->attrlist4 = xdr_attrs = kmem_alloc(xdr_size, KM_SLEEP); 409 fattrp->attrlist4_len = xdr_size; 410 xdrmem_create(&xdr, xdr_attrs, xdr_size, XDR_ENCODE); 411 for (i = 0; i < attrcnt; i++) { 412 if ((*nfs4_ntov_map[amap[i]].xfunc)(&xdr, &na[i]) == FALSE) { 413 cmn_err(CE_WARN, "vattr_to_fattr4: xdr encode of " | 364 } else if (nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK) { 365 nfsace4 *tmpacl = (nfsace4 *)vsap->vsa_aclentp; 366 367 acl_attr = attrcnt; 368 /* fattr4_acl_len */ 369 xdr_size += BYTES_PER_XDR_UNIT; 370 /* fattr4_acl_val */ 371 xdr_size += RNDUP((vsap->vsa_aclcnt * --- 31 unchanged lines hidden (view full) --- 403 } 404 405 fattrp->attrlist4 = xdr_attrs = kmem_alloc(xdr_size, KM_SLEEP); 406 fattrp->attrlist4_len = xdr_size; 407 xdrmem_create(&xdr, xdr_attrs, xdr_size, XDR_ENCODE); 408 for (i = 0; i < attrcnt; i++) { 409 if ((*nfs4_ntov_map[amap[i]].xfunc)(&xdr, &na[i]) == FALSE) { 410 cmn_err(CE_WARN, "vattr_to_fattr4: xdr encode of " |
414 "attribute failed\n"); | 411 "attribute failed\n"); |
415 error = EINVAL; 416 break; 417 } 418 } 419done: 420 /* 421 * Free any malloc'd attrs, can only be uid or gid 422 */ 423 if (uid_attr != -1 && na[uid_attr].owner.utf8string_val != NULL) { 424 kmem_free(na[uid_attr].owner.utf8string_val, | 412 error = EINVAL; 413 break; 414 } 415 } 416done: 417 /* 418 * Free any malloc'd attrs, can only be uid or gid 419 */ 420 if (uid_attr != -1 && na[uid_attr].owner.utf8string_val != NULL) { 421 kmem_free(na[uid_attr].owner.utf8string_val, |
425 na[uid_attr].owner.utf8string_len); | 422 na[uid_attr].owner.utf8string_len); |
426 } 427 if (gid_attr != -1 && na[gid_attr].owner_group.utf8string_val != NULL) { 428 kmem_free(na[gid_attr].owner_group.utf8string_val, | 423 } 424 if (gid_attr != -1 && na[gid_attr].owner_group.utf8string_val != NULL) { 425 kmem_free(na[gid_attr].owner_group.utf8string_val, |
429 na[gid_attr].owner_group.utf8string_len); | 426 na[gid_attr].owner_group.utf8string_len); |
430 } 431 432 /* xdrmem_destroy(&xdrs); */ /* NO-OP */ 433 kmem_free(na, sizeof (union nfs4_attr_u) * nfs4_ntov_map_size); 434 if (error) 435 nfs4_fattr4_free(fattrp); 436 return (error); 437} --- 327 unchanged lines hidden (view full) --- 765 { FATTR4_TIME_MODIFY_MASK, AT_MTIME, FALSE, FALSE, 766 FATTR4_TIME_MODIFY, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4, 767 NULL, "fattr4_time_modify" }, 768 769 { FATTR4_TIME_MODIFY_SET_MASK, AT_MTIME, FALSE, FALSE, 770 FATTR4_TIME_MODIFY_SET, 4 * BYTES_PER_XDR_UNIT, xdr_settime4, 771 NULL, "fattr4_time_modify_set" }, 772 | 427 } 428 429 /* xdrmem_destroy(&xdrs); */ /* NO-OP */ 430 kmem_free(na, sizeof (union nfs4_attr_u) * nfs4_ntov_map_size); 431 if (error) 432 nfs4_fattr4_free(fattrp); 433 return (error); 434} --- 327 unchanged lines hidden (view full) --- 762 { FATTR4_TIME_MODIFY_MASK, AT_MTIME, FALSE, FALSE, 763 FATTR4_TIME_MODIFY, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4, 764 NULL, "fattr4_time_modify" }, 765 766 { FATTR4_TIME_MODIFY_SET_MASK, AT_MTIME, FALSE, FALSE, 767 FATTR4_TIME_MODIFY_SET, 4 * BYTES_PER_XDR_UNIT, xdr_settime4, 768 NULL, "fattr4_time_modify_set" }, 769 |
773 { FATTR4_MOUNTED_ON_FILEID_MASK, 0, FALSE, FALSE, | 770 { FATTR4_MOUNTED_ON_FILEID_MASK, AT_NODEID, FALSE, FALSE, |
774 FATTR4_MOUNTED_ON_FILEID, 2 * BYTES_PER_XDR_UNIT, 775 xdr_u_longlong_t, 776 NULL, "fattr4_mounted_on_fileid" }, 777 778}; 779 780uint_t nfs4_ntov_map_size = sizeof (nfs4_ntov_map) / 781 sizeof (struct nfs4_ntov_map); | 771 FATTR4_MOUNTED_ON_FILEID, 2 * BYTES_PER_XDR_UNIT, 772 xdr_u_longlong_t, 773 NULL, "fattr4_mounted_on_fileid" }, 774 775}; 776 777uint_t nfs4_ntov_map_size = sizeof (nfs4_ntov_map) / 778 sizeof (struct nfs4_ntov_map); |