/*
* Copyright (c) 1998 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* This copy is a minimal version for libsa and it's ufs.c. The unused
* functions are removed, and additional swapping is performed on the
* di_extb, di_db, and di_ib arrays.
*/
/*
* In order to avoid a lot of lines, as the first N fields (52)
* of the superblock up to fs_fmod are u_int32_t, we just loop
* here to convert them.
*/
o32 = (const u_int32_t *)o;
n32 = (u_int32_t *)n;
for (i = 0; i < offsetof(struct fs, fs_fmod) / sizeof(u_int32_t); i++)
n32[i] = bswap32(o32[i]);
/* These fields overlap with a possible location for the
* historic FS_DYNAMICPOSTBLFMT postbl table, and with the
* first half of the historic FS_42POSTBLFMT postbl table.
*/
n->fs_maxbsize = bswap32(o->fs_maxbsize);
/* XXX journal */
n->fs_quota_magic = bswap32(o->fs_quota_magic);
for (i = 0; i < MAXQUOTAS; i++)
n->fs_quotafile[i] = bswap64(o->fs_quotafile[i]);
n->fs_sblockloc = bswap64(o->fs_sblockloc);
libsa_ffs_csumtotal_swap(&o->fs_cstotal, &n->fs_cstotal);
n->fs_time = bswap64(o->fs_time);
n->fs_size = bswap64(o->fs_size);
n->fs_dsize = bswap64(o->fs_dsize);
n->fs_csaddr = bswap64(o->fs_csaddr);
n->fs_pendingblocks = bswap64(o->fs_pendingblocks);
n->fs_pendinginodes = bswap32(o->fs_pendinginodes);
/* These fields overlap with the second half of the
* historic FS_42POSTBLFMT postbl table
*/
for (i = 0; i < FSMAXSNAP; i++)
n->fs_snapinum[i] = bswap32(o->fs_snapinum[i]);
n->fs_avgfilesize = bswap32(o->fs_avgfilesize);
n->fs_avgfpdir = bswap32(o->fs_avgfpdir);
/* fs_sparecon[28] - ignore for now */
n->fs_flags = bswap32(o->fs_flags);
n->fs_contigsumsize = bswap32(o->fs_contigsumsize);
n->fs_maxsymlinklen = bswap32(o->fs_maxsymlinklen);
n->fs_old_inodefmt = bswap32(o->fs_old_inodefmt);
n->fs_maxfilesize = bswap64(o->fs_maxfilesize);
n->fs_qbmask = bswap64(o->fs_qbmask);
n->fs_qfmask = bswap64(o->fs_qfmask);
n->fs_state = bswap32(o->fs_state);
n->fs_old_postblformat = bswap32(o->fs_old_postblformat);
n->fs_old_nrpos = bswap32(o->fs_old_nrpos);
n->fs_old_postbloff = bswap32(o->fs_old_postbloff);
n->fs_old_rotbloff = bswap32(o->fs_old_rotbloff);