diff options
-rw-r--r-- | usr.sbin/makefs/ffs.c | 30 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ffs_alloc.c | 29 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ffs_balloc.c | 31 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ffs_subr.c | 9 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/mkfs.c | 3 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ufs_bmap.c | 3 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ufs_bswap.h | 53 |
7 files changed, 47 insertions, 111 deletions
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c index 0b932ca960e..182eb79e4c9 100644 --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs.c,v 1.15 2016/10/22 19:17:47 natano Exp $ */ +/* $OpenBSD: ffs.c,v 1.16 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */ /* @@ -82,7 +82,6 @@ #include <ufs/ufs/dir.h> #include <ufs/ffs/fs.h> -#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" @@ -525,8 +524,7 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur, dinp->di_size = dbufp->size; } else if (S_ISBLK(cur->type) || S_ISCHR(cur->type)) { dinp->di_size = 0; /* a device */ - dinp->di_rdev = - ufs_rw32(cur->inode->st.st_rdev, 0); + dinp->di_rdev = cur->inode->st.st_rdev; } else if (S_ISLNK(cur->type)) { /* symlink */ slen = strlen(cur->symlink); if (slen < MAXSYMLINKLEN_UFS1) { /* short link */ @@ -568,8 +566,7 @@ ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur, dinp->di_size = dbufp->size; } else if (S_ISBLK(cur->type) || S_ISCHR(cur->type)) { dinp->di_size = 0; /* a device */ - dinp->di_rdev = - ufs_rw64(cur->inode->st.st_rdev, 0); + dinp->di_rdev = cur->inode->st.st_rdev; } else if (S_ISLNK(cur->type)) { /* symlink */ slen = strlen(cur->symlink); if (slen < MAXSYMLINKLEN_UFS2) { /* short link */ @@ -782,7 +779,7 @@ static void ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node) { struct direct de, *dp; - uint16_t llen, reclen; + uint16_t llen; u_char *newbuf; assert (dbuf != NULL); @@ -790,31 +787,30 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node) assert (node != NULL); /* create direct entry */ (void)memset(&de, 0, sizeof(de)); - de.d_ino = ufs_rw32(node->inode->ino, 0); + de.d_ino = node->inode->ino; de.d_type = IFTODT(node->type); de.d_namlen = (uint8_t)strlen(name); strlcpy(de.d_name, name, sizeof de.d_name); - reclen = DIRSIZ(NEWDIRFMT, &de); - de.d_reclen = ufs_rw16(reclen, 0); + de.d_reclen = DIRSIZ(NEWDIRFMT, &de); dp = (struct direct *)(dbuf->buf + dbuf->cur); llen = 0; if (dp != NULL) llen = DIRSIZ(NEWDIRFMT, dp); - if (reclen + dbuf->cur + llen > roundup(dbuf->size, DIRBLKSIZ)) { + if (de.d_reclen + dbuf->cur + llen > roundup(dbuf->size, DIRBLKSIZ)) { newbuf = erealloc(dbuf->buf, dbuf->size + DIRBLKSIZ); dbuf->buf = newbuf; dbuf->size += DIRBLKSIZ; memset(dbuf->buf + dbuf->size - DIRBLKSIZ, 0, DIRBLKSIZ); dbuf->cur = dbuf->size - DIRBLKSIZ; } else if (dp) { /* shrink end of previous */ - dp->d_reclen = ufs_rw16(llen,0); + dp->d_reclen = llen; dbuf->cur += llen; } dp = (struct direct *)(dbuf->buf + dbuf->cur); - memcpy(dp, &de, reclen); - dp->d_reclen = ufs_rw16(dbuf->size - dbuf->cur, 0); + memcpy(dp, &de, de.d_reclen); + dp->d_reclen = dbuf->size - dbuf->cur; } /* @@ -875,10 +871,10 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts) /* * Initialize inode blocks on the fly for UFS2. */ - initediblk = ufs_rw32(cgp->cg_initediblk, 0); + initediblk = cgp->cg_initediblk; if (ffs_opts->version == 2 && (uint32_t)(cgino + INOPB(fs)) > initediblk && - initediblk < ufs_rw32(cgp->cg_ffs2_niblk, 0)) { + initediblk < cgp->cg_ffs2_niblk) { memset(buf, 0, fs->fs_bsize); dip = (struct ufs2_dinode *)buf; for (i = 0; i < INOPB(fs); i++) { @@ -889,7 +885,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts) cg * fs->fs_ipg + initediblk)), fs->fs_bsize, buf, fsopts); initediblk += INOPB(fs); - cgp->cg_initediblk = ufs_rw32(initediblk, 0); + cgp->cg_initediblk = initediblk; } diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c index dbe74879b47..582a892d19a 100644 --- a/usr.sbin/makefs/ffs/ffs_alloc.c +++ b/usr.sbin/makefs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.10 2016/10/22 18:17:14 natano Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.11 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $ */ /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */ @@ -50,7 +50,6 @@ #include <ufs/ffs/fs.h> #include "ffs/buf.h" -#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" @@ -161,8 +160,7 @@ ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap) startcg = ino_to_cg(fs, ip->i_number) + lbn / fs->fs_maxbpg; else - startcg = dtog(fs, - ufs_rw32(bap[indx - 1], 0) + 1); + startcg = dtog(fs, bap[indx - 1] + 1); startcg %= fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; for (cg = startcg; cg < fs->fs_ncg; cg++) @@ -176,7 +174,7 @@ ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap) /* * We just always try to lay things out contiguously. */ - return ufs_rw32(bap[indx - 1], 0) + fs->fs_frag; + return bap[indx - 1] + fs->fs_frag; } daddr_t @@ -200,8 +198,7 @@ ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap) startcg = ino_to_cg(fs, ip->i_number) + lbn / fs->fs_maxbpg; else - startcg = dtog(fs, - ufs_rw64(bap[indx - 1], 0) + 1); + startcg = dtog(fs, bap[indx - 1] + 1); startcg %= fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; for (cg = startcg; cg < fs->fs_ncg; cg++) @@ -217,7 +214,7 @@ ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap) /* * We just always try to lay things out contiguously. */ - return ufs_rw64(bap[indx - 1], 0) + fs->fs_frag; + return bap[indx - 1] + fs->fs_frag; } /* @@ -375,8 +372,8 @@ ffs_alloccgblk(struct inode *ip, struct mkfsbuf *bp, daddr_t bpref) cgp = (struct cg *)bp->b_data; blksfree = cg_blksfree(cgp); - if (bpref == 0 || dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, 0)) { - bpref = ufs_rw32(cgp->cg_rotor, 0); + if (bpref == 0 || dtog(fs, bpref) != cgp->cg_cgx) { + bpref = cgp->cg_rotor; } else { bpref = blknum(fs, bpref); bno = dtogd(fs, bpref); @@ -392,16 +389,16 @@ ffs_alloccgblk(struct inode *ip, struct mkfsbuf *bp, daddr_t bpref) bno = ffs_mapsearch(fs, cgp, bpref, (int)fs->fs_frag); if (bno < 0) return (0); - cgp->cg_rotor = ufs_rw32(bno, 0); + cgp->cg_rotor = bno; gotit: blkno = fragstoblks(fs, bno); ffs_clrblock(fs, blksfree, (long)blkno); ffs_clusteracct(fs, cgp, blkno, -1); cgp->cg_cs.cs_nbfree -= 1; fs->fs_cstotal.cs_nbfree--; - fs->fs_cs(fs, ufs_rw32(cgp->cg_cgx, 0)).cs_nbfree--; + fs->fs_cs(fs, cgp->cg_cgx).cs_nbfree--; fs->fs_fmod = 1; - blkno = ufs_rw32(cgp->cg_cgx, 0) * fs->fs_fpg + bno; + blkno = cgp->cg_cgx * fs->fs_fpg + bno; return (blkno); } @@ -436,7 +433,7 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) if (bpref) start = dtogd(fs, bpref) / NBBY; else - start = ufs_rw32(cgp->cg_frotor, 0) / NBBY; + start = cgp->cg_frotor / NBBY; len = howmany(fs->fs_fpg, NBBY) - start; ostart = start; olen = len; @@ -454,12 +451,12 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) if (loc == 0) { errx(EXIT_FAILURE, "%s: map corrupted: start %d " "len %d offset %d %ld", __func__, ostart, olen, - ufs_rw32(cgp->cg_freeoff, 0), + cgp->cg_freeoff, (long)cg_blksfree(cgp) - (long)cgp); } } bno = (start + len - loc) * NBBY; - cgp->cg_frotor = ufs_rw32(bno, 0); + cgp->cg_frotor = bno; /* * found the byte in the map * sift through the bits to find the selected frag diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c index 2ed6b74a2ae..64bce933cb5 100644 --- a/usr.sbin/makefs/ffs/ffs_balloc.c +++ b/usr.sbin/makefs/ffs/ffs_balloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_balloc.c,v 1.7 2016/10/22 16:51:52 natano Exp $ */ +/* $OpenBSD: ffs_balloc.c,v 1.8 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.21 2015/03/29 05:52:59 agc Exp $ */ /* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */ @@ -42,7 +42,6 @@ #include <ufs/ffs/fs.h> #include "ffs/buf.h" -#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" @@ -112,7 +111,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp */ if (lbn < NDADDR) { - nb = ufs_rw32(ip->i_ffs1_db[lbn], 0); + nb = ip->i_ffs1_db[lbn]; if (nb != 0 && ip->i_ffs1_size >= lblktosize(fs, lbn + 1)) { /* @@ -185,7 +184,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp *bpp = bp; } } - ip->i_ffs1_db[lbn] = ufs_rw32((int32_t)newb, 0); + ip->i_ffs1_db[lbn] = newb; return (0); } @@ -207,7 +206,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp */ --num; - nb = ufs_rw32(ip->i_ffs1_ib[indirs[0].in_off], 0); + nb = ip->i_ffs1_ib[indirs[0].in_off]; allocib = NULL; allocblk = allociblk; if (nb == 0) { @@ -227,7 +226,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp if ((error = bwrite(bp)) != 0) return error; allocib = &ip->i_ffs1_ib[indirs[0].in_off]; - *allocib = ufs_rw32((int32_t)nb, 0); + *allocib = nb; } /* @@ -242,7 +241,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp return error; } bap = (int32_t *)bp->b_data; - nb = ufs_rw32(bap[indirs[i].in_off], 0); + nb = bap[indirs[i].in_off]; if (i == num) break; i++; @@ -271,7 +270,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp brelse(bp, 0); return error; } - bap[indirs[i - 1].in_off] = ufs_rw32(nb, 0); + bap[indirs[i - 1].in_off] = nb; bwrite(bp); } @@ -295,7 +294,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp clrbuf(nbp); *bpp = nbp; } - bap[indirs[num].in_off] = ufs_rw32(nb, 0); + bap[indirs[num].in_off] = nb; /* * If required, write synchronously, otherwise use @@ -361,7 +360,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp */ if (lbn < NDADDR) { - nb = ufs_rw64(ip->i_ffs2_db[lbn], 0); + nb = ip->i_ffs2_db[lbn]; if (nb != 0 && ip->i_ffs2_size >= lblktosize(fs, lbn + 1)) { /* @@ -434,7 +433,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp *bpp = bp; } } - ip->i_ffs2_db[lbn] = ufs_rw64(newb, 0); + ip->i_ffs2_db[lbn] = newb; return (0); } @@ -456,7 +455,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp */ --num; - nb = ufs_rw64(ip->i_ffs2_ib[indirs[0].in_off], 0); + nb = ip->i_ffs2_ib[indirs[0].in_off]; allocib = NULL; allocblk = allociblk; if (nb == 0) { @@ -476,7 +475,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp if ((error = bwrite(bp)) != 0) return error; allocib = &ip->i_ffs2_ib[indirs[0].in_off]; - *allocib = ufs_rw64(nb, 0); + *allocib = nb; } /* @@ -491,7 +490,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp return error; } bap = (int64_t *)bp->b_data; - nb = ufs_rw64(bap[indirs[i].in_off], 0); + nb = bap[indirs[i].in_off]; if (i == num) break; i++; @@ -520,7 +519,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp brelse(bp, 0); return error; } - bap[indirs[i - 1].in_off] = ufs_rw64(nb, 0); + bap[indirs[i - 1].in_off] = nb; bwrite(bp); } @@ -544,7 +543,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct mkfsbuf **bp clrbuf(nbp); *bpp = nbp; } - bap[indirs[num].in_off] = ufs_rw64(nb, 0); + bap[indirs[num].in_off] = nb; /* * If required, write synchronously, otherwise use diff --git a/usr.sbin/makefs/ffs/ffs_subr.c b/usr.sbin/makefs/ffs/ffs_subr.c index bf3e291d8e7..bc03ecf7a64 100644 --- a/usr.sbin/makefs/ffs/ffs_subr.c +++ b/usr.sbin/makefs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.3 2016/10/22 17:15:28 natano Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.4 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: ffs_subr.c,v 1.49 2016/05/07 11:59:08 maxv Exp $ */ /* @@ -39,7 +39,6 @@ #include <err.h> -#include "ffs/ufs_bswap.h" #include "ffs/ffs_extern.h" @@ -156,8 +155,8 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt) */ start = blkno + 1; end = start + fs->fs_contigsumsize; - if ((uint32_t)end >= ufs_rw32(cgp->cg_nclusterblks, 0)) - end = ufs_rw32(cgp->cg_nclusterblks, 0); + if ((uint32_t)end >= cgp->cg_nclusterblks) + end = cgp->cg_nclusterblks; mapp = &freemapp[start / NBBY]; map = *mapp++; bit = 1 << (start % NBBY); @@ -211,6 +210,6 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt) */ lp = &sump[fs->fs_contigsumsize]; for (i = fs->fs_contigsumsize; i > 0; i--) - if (ufs_rw32(*lp--, 0) > 0) + if (*lp-- > 0) break; } diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c index 97cbab6d332..e62a57d88ef 100644 --- a/usr.sbin/makefs/ffs/mkfs.c +++ b/usr.sbin/makefs/ffs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.10 2016/10/22 16:51:52 natano Exp $ */ +/* $OpenBSD: mkfs.c,v 1.11 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: mkfs.c,v 1.34 2016/06/24 19:24:11 christos Exp $ */ /* @@ -53,7 +53,6 @@ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> -#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" diff --git a/usr.sbin/makefs/ffs/ufs_bmap.c b/usr.sbin/makefs/ffs/ufs_bmap.c index 58c9367c391..9da3410efd6 100644 --- a/usr.sbin/makefs/ffs/ufs_bmap.c +++ b/usr.sbin/makefs/ffs/ufs_bmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_bmap.c,v 1.4 2016/10/22 16:51:52 natano Exp $ */ +/* $OpenBSD: ufs_bmap.c,v 1.5 2016/10/22 19:43:50 natano Exp $ */ /* $NetBSD: ufs_bmap.c,v 1.18 2013/06/19 17:51:27 dholland Exp $ */ /* From: NetBSD: ufs_bmap.c,v 1.14 2001/11/08 05:00:51 chs Exp */ @@ -50,7 +50,6 @@ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> -#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" diff --git a/usr.sbin/makefs/ffs/ufs_bswap.h b/usr.sbin/makefs/ffs/ufs_bswap.h deleted file mode 100644 index 4c8aa1af5fa..00000000000 --- a/usr.sbin/makefs/ffs/ufs_bswap.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: ufs_bswap.h,v 1.1 2016/10/18 17:23:21 natano Exp $ */ -/* $NetBSD: ufs_bswap.h,v 1.21 2016/04/29 03:05:04 christos Exp $ */ - -/* - * 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. - * - */ - -#ifndef _UFS_UFS_BSWAP_H_ -#define _UFS_UFS_BSWAP_H_ - -#include <sys/endian.h> - -/* inlines for access to swapped data */ -static inline u_int16_t -ufs_rw16(uint16_t a, int ns) -{ - return a; -} - -static inline u_int32_t -ufs_rw32(uint32_t a, int ns) -{ - return a; -} - -static inline u_int64_t -ufs_rw64(uint64_t a, int ns) -{ - return a; -} - -#endif /* !_UFS_UFS_BSWAP_H_ */ |