/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <nfs/nfs4_clnt.h>
static int
{
int error = 0;
if (flags & ATTR_UTIME) {
} else {
}
return (error);
}
/*
* nfs4_ver_fattr4_attr translates a vattr attribute into a fattr4 attribute
* for use by nfsv4 verify. For setting atime or mtime use the entry for
* time_XX (XX == access or modify).
* Return TRUE if arg was set (even if there was an error) and FALSE
* otherwise. Also set error code. The caller should not continue
* if error was set, whether or not the return is TRUE or FALSE. Returning
* FALSE does not mean there was an error, only that the attr was not set.
*
* Note: For now we only have the options used by setattr. In the future
* the switch statement below should cover all vattr attrs and possibly
* sys attrs as well.
*/
/* ARGSUSED */
static bool_t
{
/*
* Special case for time set: if setting the
*/
*errorp = 0;
/*
* Bit matches the mask
*/
case AT_SIZE:
break;
case AT_MODE:
break;
case AT_UID:
/*
* if no mapping, uid could be mapped to a numeric string,
* e.g. 12345->"12345"
*/
FALSE))
break;
case AT_GID:
/*
* if no mapping, gid will be mapped to a number string,
* e.g. "12345"
*/
FALSE))
break;
case AT_ATIME:
&nap->time_access))) {
/*
* either asked for FATTR4_TIME_ACCESS_SET -
* not used for setattr
* or system time invalid for otw transfers
*/
}
break;
case AT_MTIME:
&nap->time_modify))) {
/*
* either asked for FATTR4_TIME_MODIFY_SET -
* not used for setattr
* or system time invalid for otw transfers
*/
}
break;
case AT_CTIME:
&nap->time_metadata)) {
/*
* system time invalid for otw transfers
*/
}
break;
default:
}
return (retval);
}
/*
* nfs4_set_fattr4_attr translates a vattr attribute into a fattr4 attribute
* for use by nfs4_setattr. For setting atime or mtime use the entry for
* time_XX_set rather than time_XX (XX == access or modify).
* Return TRUE if arg was set (even if there was an error) and FALSE
* otherwise. Also set error code. The caller should not continue
* if error was set, whether or not the return is TRUE or FALSE. Returning
* FALSE does not mean there was an error, only that the attr was not set.
*/
static bool_t
int *errorp)
{
/*
* Special case for time set: if setting the
*/
*errorp = 0;
/*
* Bit matches the mask
*/
case AT_SIZE:
break;
case AT_MODE:
break;
case AT_UID:
/*
* if no mapping, uid will be mapped to a number string,
* e.g. "12345"
*/
FALSE))
break;
case AT_GID:
/*
* if no mapping, gid will be mapped to a number string,
* e.g. "12345"
*/
FALSE))
break;
case AT_ATIME:
/* FATTR4_TIME_ACCESS - not used for verify */
}
break;
case AT_MTIME:
/* FATTR4_TIME_MODIFY - not used for verify */
}
break;
default:
/*
* If the ntovp->vbit == 0 this is most likely the ACL.
*/
} else
}
return (retval);
}
/*
* XXX - This is a shorter version of vattr_to_fattr4 which only takes care
* by using nfs4_ntov_map and the same functions used by the server.
* Here we just hardcoded the setattr attributes. Note that the order is
* important - it should follow the order of the bits in the mask.
*/
int
{
int i, j;
int attrcnt;
char *xdr_attrs;
int error = 0;
#ifndef lint
/*
* Make sure that maximum attribute number can be expressed as an
* 8 bit quantity.
*/
#endif
fattrp->attrlist4_len = 0;
KM_SLEEP);
/*
* Note we need to set the attrmask for set operations.
* In particular mtime and atime will be set to the
* servers time.
*/
/*
* this routine knows how to handle all vmask bits
*/
/*
* broken for servers that only support mandatory attrs.
* Mask out change attr for now and fix verify op to
* work with mandonly servers later. nfs4_vmask_to_nmask
* so we must turn off change because nfs4_ver_fattr4_attr
* will not generate args for change. This is a bug
* that will be fixed later.
* XXX
*/
}
/* Mask out any rec attrs unsupported by server */
attrcnt = 0;
xdr_size = 0;
for (i = 0; i < nfs4_ntov_map_size; i++) {
/*
* In the case of FATTR4_ACL_MASK, the vbit will be 0 (zero)
* so we must also check if the fbit is FATTR4_ACL_MASK before
* skipping over this attribute.
*/
continue;
continue;
}
if (attrfunc == nfs4_set_fattr4_attr) {
continue;
} else if (attrfunc == nfs4_ver_fattr4_attr) {
continue;
}
if (error)
goto done; /* Exit! */
/*
* Calculate XDR size
*/
if (nfs4_ntov_map[i].xdr_size != 0) {
/*
* If we are setting attributes (attrfunc is
* nfs4_set_fattr4_attr) and are setting the
* mtime or atime, adjust the xdr size down by
* 3 words, since we are using the server's
* time as the current time. Exception: if
* ATTR_UTIME is set, the client sends the
* time, so leave the xdr size alone.
*/
attrfunc == nfs4_set_fattr4_attr &&
!(flags & ATTR_UTIME)) {
}
} else {
/*
* The only zero xdr_sizes we should see
* are AT_UID, AT_GID and FATTR4_ACL_MASK
*/
xdr_size +=
xdr_size +=
/* fattr4_acl_len */
/* fattr4_acl_val */
+ sizeof (acemask4))));
for (j = 0; j < vsap->vsa_aclcnt; j++) {
/* who - utf8string_len */
/* who - utf8string_val */
xdr_size +=
}
}
}
/*
* This attr is going otw
*/
attrcnt++;
/*
* Clear this bit from test mask so we stop
* as soon as all requested attrs are done.
*/
if (va_mask == 0 &&
break;
}
if (attrcnt == 0) {
goto done;
}
for (i = 0; i < attrcnt; i++) {
"attribute failed\n");
break;
}
}
done:
/*
* Free any malloc'd attrs, can only be uid or gid
*/
}
}
/* xdrmem_destroy(&xdrs); */ /* NO-OP */
if (error)
return (error);
}
void
{
/*
* set attrlist4val/len to 0 because...
*
* op_readdir resfree function could call us again
* for last entry4 if it was able to encode the name
* and cookie but couldn't encode the attrs because
* of maxcount violation (from rddir args). In that
* been free'd, but the entry4 remains on the end of
* the list.
*/
attrp->attrlist4_len = 0;
}
}
/*
* Translate a vattr_t mask to a fattr4 type bitmap, caller is
* responsible for zeroing bitsval if needed.
*/
void
{
return;
}
if (vmask == 0) {
return;
}
*bitsval |= FATTR4_TYPE_MASK;
*bitsval |= FATTR4_MODE_MASK;
*bitsval |= FATTR4_OWNER_MASK;
*bitsval |= FATTR4_FSID_MASK;
/* set mounted_on_fileid when AT_NODEID requested */
*bitsval |= FATTR4_SIZE_MASK;
/* also set CHANGE whenever AT_CTIME requested */
if (vmask & AT_NBLOCKS)
}
/*
* nfs4_vmask_to_nmask_set is used for setattr. A separate function needed
* because of special treatment to timeset.
*/
void
{
if (vmask == 0) {
return;
}
*bitsval |= FATTR4_MODE_MASK;
*bitsval |= FATTR4_OWNER_MASK;
*bitsval |= FATTR4_SIZE_MASK;
}
/*
* Convert NFS Version 4 over the network attributes to the local
* virtual attributes.
*/
};
/*
* { fbit, vbit, vfsstat, mandatory,
* nval, xdr_size, xfunc,
* sv_getit, prtstr },
*/
NULL, "fattr4_supported_attrs" },
NULL, "fattr4_type" },
NULL, "fattr4_fh_expire_type" },
NULL, "fattr4_change" },
NULL, "fattr4_size" },
NULL, "fattr4_link_support" },
NULL, "fattr4_symlink_support" },
NULL, "fattr4_named_attr" },
NULL, "fattr4_fsid" },
NULL, "fattr4_unique_handles" },
NULL, "fattr4_lease_time" },
NULL, "fattr4_rdattr_error" },
FATTR4_ACL, 0, xdr_fattr4_acl,
NULL, "fattr4_acl" },
NULL, "fattr4_aclsupport" },
NULL, "fattr4_archive" },
NULL, "fattr4_cansettime" },
NULL, "fattr4_case_insensitive" },
NULL, "fattr4_case_preserving" },
NULL, "fattr4_chown_restricted" },
NULL, "fattr4_filehandle" },
NULL, "fattr4_fileid" },
NULL, "fattr4_files_avail" },
NULL, "fattr4_files_free" },
NULL, "fattr4_files_total" },
NULL, "fattr4_fs_locations" },
NULL, "fattr4_hidden" },
NULL, "fattr4_homogeneous" },
NULL, "fattr4_maxfilesize" },
NULL, "fattr4_maxlink" },
NULL, "fattr4_maxname" },
NULL, "fattr4_maxread" },
NULL, "fattr4_maxwrite" },
NULL, "fattr4_mimetype" },
NULL, "fattr4_mode" },
NULL, "fattr4_no_trunc" },
NULL, "fattr4_numlinks" },
NULL, "fattr4_owner" },
NULL, "fattr4_owner_group" },
NULL, "fattr4_quota_avail_hard" },
NULL, "fattr4_quota_avail_soft" },
NULL, "fattr4_quota_used" },
NULL, "fattr4_rawdev" },
NULL, "fattr4_space_avail" },
NULL, "fattr4_space_free" },
NULL, "fattr4_space_total" },
NULL, "fattr4_space_used" },
NULL, "fattr4_system" },
NULL, "fattr4_time_access" },
NULL, "fattr4_time_access_set" },
NULL, "fattr4_time_backup" },
NULL, "fattr4_time_create" },
NULL, "fattr4_time_delta" },
NULL, "fattr4_time_metadata" },
NULL, "fattr4_time_modify" },
NULL, "fattr4_time_modify_set" },
NULL, "fattr4_mounted_on_fileid" },
};
sizeof (struct nfs4_ntov_map);