zfs_byteswap.c revision d5285cae913f4e01ffa0e6693a6d8ef1fbea30ba
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License (the "License").
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * swap ace_t and ace_oject_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinzfs_ace_byteswap(void *buf, size_t size, boolean_t zfs_layout)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Avoid overrun. Embedded aces can have one
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * of several sizes. We don't know exactly
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * how many our present, only the size of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * buffer containing them. That size may be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * larger than needed to hold the aces
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * present. As long as we do not do any
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * swapping beyond the end of our block we are
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * okay. It it safe to swap any non-ace data
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * within the block since it is just zeros.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* Overrun avoidance */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* Overrun avoidance */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* ARGSUSED */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Arggh, since we don't know how many ACEs are in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the array, we have to swap the entire block
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* ARGSUSED */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin zp->zp_acl.z_acl_extern_obj = BSWAP_64(zp->zp_acl.z_acl_extern_obj);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin zp->zp_acl.z_acl_size = BSWAP_32(zp->zp_acl.z_acl_size);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin zp->zp_acl.z_acl_version = BSWAP_16(zp->zp_acl.z_acl_version);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin zp->zp_acl.z_acl_count = BSWAP_16(zp->zp_acl.z_acl_count);