From: pelikan Date: Sun, 13 Jul 2014 16:08:53 +0000 (+0000) Subject: kill fs2hXX/h2fsXX macros with letohXX/htoleXX X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=60a51e06e5943c0b5713ed6f577c4cfc6f969aca;p=openbsd kill fs2hXX/h2fsXX macros with letohXX/htoleXX The reason being that ext2 structures are little-endian but JBD2 journal is big-endian. Don't confuse readers by talking about "file system endian". ok guenther --- diff --git a/sbin/fsck_ext2fs/dir.c b/sbin/fsck_ext2fs/dir.c index f24f1675a15..cda8b6f3c9d 100644 --- a/sbin/fsck_ext2fs/dir.c +++ b/sbin/fsck_ext2fs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.18 2014/05/24 02:27:31 krw Exp $ */ +/* $OpenBSD: dir.c,v 1.19 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: dir.c,v 1.5 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -131,7 +131,7 @@ dirscan(struct inodesc *idesc) } idesc->id_loc = 0; for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) { - dsize = fs2h16(dp->e2d_reclen); + dsize = letoh16(dp->e2d_reclen); memcpy(dbuf, dp, (size_t)dsize); idesc->id_dirp = (struct ext2fs_direct *)dbuf; if ((n = (*idesc->id_func)(idesc)) & ALTERED) { @@ -172,7 +172,7 @@ fsck_readdir(struct inodesc *idesc) fix = dofix(idesc, "DIRECTORY CORRUPTED"); bp = getdirblk(idesc->id_blkno, blksiz); dp = (struct ext2fs_direct *)(bp->b_un.b_buf + idesc->id_loc); - dp->e2d_reclen = h2fs16(sblock.e2fs_bsize); + dp->e2d_reclen = htole16(sblock.e2fs_bsize); dp->e2d_ino = 0; dp->e2d_namlen = 0; dp->e2d_type = 0; @@ -188,8 +188,8 @@ dpok: return NULL; dploc = idesc->id_loc; dp = (struct ext2fs_direct *)(bp->b_un.b_buf + dploc); - idesc->id_loc += fs2h16(dp->e2d_reclen); - idesc->id_filesize -= fs2h16(dp->e2d_reclen); + idesc->id_loc += letoh16(dp->e2d_reclen); + idesc->id_filesize -= letoh16(dp->e2d_reclen); if ((idesc->id_loc % sblock.e2fs_bsize) == 0) return (dp); ndp = (struct ext2fs_direct *)(bp->b_un.b_buf + idesc->id_loc); @@ -203,7 +203,7 @@ dpok: fix = dofix(idesc, "DIRECTORY CORRUPTED"); bp = getdirblk(idesc->id_blkno, blksiz); dp = (struct ext2fs_direct *)(bp->b_un.b_buf + dploc); - dp->e2d_reclen = h2fs16(fs2h16(dp->e2d_reclen) + size); + dp->e2d_reclen = htole16(letoh16(dp->e2d_reclen) + size); if (fix) dirty(bp); } @@ -220,10 +220,10 @@ dircheck(struct inodesc *idesc, struct ext2fs_direct *dp) int size; char *cp; int spaceleft; - u_int16_t reclen = fs2h16(dp->e2d_reclen); + u_int16_t reclen = letoh16(dp->e2d_reclen); spaceleft = sblock.e2fs_bsize - (idesc->id_loc % sblock.e2fs_bsize); - if (fs2h32(dp->e2d_ino) > maxino || + if (letoh32(dp->e2d_ino) > maxino || reclen == 0 || reclen > spaceleft || (reclen & 0x3) != 0) @@ -269,7 +269,7 @@ fileerror(ino_t cwd, ino_t ino, char *errmesg) dp = ginode(ino); if (ftypeok(dp)) pfatal("%s=%s\n", - (fs2h16(dp->e2di_mode) & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf); + (letoh16(dp->e2di_mode) & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf); else pfatal("NAME=%s\n", pathbuf); } @@ -280,15 +280,15 @@ adjust(struct inodesc *idesc, short lcnt) struct ext2fs_dinode *dp; dp = ginode(idesc->id_number); - if (fs2h16(dp->e2di_nlink) == lcnt) { + if (letoh16(dp->e2di_nlink) == lcnt) { if (linkup(idesc->id_number, (ino_t)0) == 0) clri(idesc, "UNREF", 0); } else { pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname : - ((fs2h16(dp->e2di_mode) & IFMT) == IFDIR ? "DIR" : "FILE")); + ((letoh16(dp->e2di_mode) & IFMT) == IFDIR ? "DIR" : "FILE")); pinode(idesc->id_number); printf(" COUNT %d SHOULD BE %d", - fs2h16(dp->e2di_nlink), fs2h16(dp->e2di_nlink) - lcnt); + letoh16(dp->e2di_nlink), letoh16(dp->e2di_nlink) - lcnt); if (preen) { if (lcnt < 0) { printf("\n"); @@ -297,7 +297,7 @@ adjust(struct inodesc *idesc, short lcnt) printf(" (ADJUSTED)\n"); } if (preen || reply("ADJUST") == 1) { - dp->e2di_nlink = h2fs16(fs2h16(dp->e2di_nlink) - lcnt); + dp->e2di_nlink = htole16(letoh16(dp->e2di_nlink) - lcnt); inodirty(); } } @@ -320,12 +320,12 @@ mkentry(struct inodesc *idesc) oldlen = EXT2FS_DIRSIZ(dirp->e2d_namlen); else oldlen = 0; - if (fs2h16(dirp->e2d_reclen) - oldlen < newlen) + if (letoh16(dirp->e2d_reclen) - oldlen < newlen) return (KEEPON); - newent.e2d_reclen = h2fs16(fs2h16(dirp->e2d_reclen) - oldlen); - dirp->e2d_reclen = h2fs16(oldlen); + newent.e2d_reclen = htole16(letoh16(dirp->e2d_reclen) - oldlen); + dirp->e2d_reclen = htole16(oldlen); dirp = (struct ext2fs_direct *)(((char *)dirp) + oldlen); - dirp->e2d_ino = h2fs32(idesc->id_parent); /* ino to be entered is in id_parent */ + dirp->e2d_ino = htole32(idesc->id_parent); /* ino to be entered is in id_parent */ dirp->e2d_reclen = newent.e2d_reclen; dirp->e2d_namlen = newent.e2d_namlen; dirp->e2d_type = newent.e2d_type; @@ -342,7 +342,7 @@ chgino(struct inodesc *idesc) if (strlen(idesc->id_name) != namlen || strncmp(dirp->e2d_name, idesc->id_name, (int)namlen)) return (KEEPON); - dirp->e2d_ino = h2fs32(idesc->id_parent); + dirp->e2d_ino = htole32(idesc->id_parent); if (sblock.e2fs.e2fs_rev > E2FS_REV0 && (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) dirp->e2d_type = inot2ext2dt(typemap[idesc->id_parent]); @@ -362,7 +362,7 @@ linkup(ino_t orphan, ino_t parentdir) memset(&idesc, 0, sizeof(struct inodesc)); dp = ginode(orphan); - lostdir = (fs2h16(dp->e2di_mode) & IFMT) == IFDIR; + lostdir = (letoh16(dp->e2di_mode) & IFMT) == IFDIR; pwarn("UNREF %s ", lostdir ? "DIR" : "FILE"); pinode(orphan); if (preen && inosize(dp) == 0) @@ -404,7 +404,7 @@ linkup(ino_t orphan, ino_t parentdir) } } dp = ginode(lfdir); - if ((fs2h16(dp->e2di_mode) & IFMT) != IFDIR) { + if ((letoh16(dp->e2di_mode) & IFMT) != IFDIR) { pfatal("lost+found IS NOT A DIRECTORY"); if (reply("REALLOCATE") == 0) return (0); @@ -441,7 +441,7 @@ linkup(ino_t orphan, ino_t parentdir) parentdir != (ino_t)-1) (void)makeentry(orphan, lfdir, ".."); dp = ginode(lfdir); - dp->e2di_nlink = h2fs16(fs2h16(dp->e2di_nlink) +1); + dp->e2di_nlink = htole16(letoh16(dp->e2di_nlink) +1); inodirty(); lncntp[lfdir]++; pwarn("DIR I=%llu CONNECTED. ", (unsigned long long)orphan); @@ -518,16 +518,16 @@ expanddir(struct ext2fs_dinode *dp, char *name) char *firstblk; lastbn = lblkno(&sblock, inosize(dp)); - if (lastbn >= NDADDR - 1 || fs2h32(dp->e2di_blocks[lastbn]) == 0 || + if (lastbn >= NDADDR - 1 || letoh32(dp->e2di_blocks[lastbn]) == 0 || inosize(dp) == 0) return (0); if ((newblk = allocblk()) == 0) return (0); dp->e2di_blocks[lastbn + 1] = dp->e2di_blocks[lastbn]; - dp->e2di_blocks[lastbn] = h2fs32(newblk); + dp->e2di_blocks[lastbn] = htole32(newblk); inossize(dp, inosize(dp) + sblock.e2fs_bsize); - dp->e2di_nblock = h2fs32(fs2h32(dp->e2di_nblock) + 1); - bp = getdirblk(fs2h32(dp->e2di_blocks[lastbn + 1]), + dp->e2di_nblock = htole32(letoh32(dp->e2di_nblock) + 1); + bp = getdirblk(letoh32(dp->e2di_blocks[lastbn + 1]), sblock.e2fs_bsize); if (bp->b_errs) goto bad; @@ -544,11 +544,11 @@ expanddir(struct ext2fs_dinode *dp, char *name) memcpy(bp->b_un.b_buf, firstblk, sblock.e2fs_bsize); free(firstblk); dirty(bp); - bp = getdirblk(fs2h32(dp->e2di_blocks[lastbn + 1]), + bp = getdirblk(letoh32(dp->e2di_blocks[lastbn + 1]), sblock.e2fs_bsize); if (bp->b_errs) goto bad; - emptydir.dot_reclen = h2fs16(sblock.e2fs_bsize); + emptydir.dot_reclen = htole16(sblock.e2fs_bsize); memcpy(bp->b_un.b_buf, &emptydir, sizeof emptydir); pwarn("NO SPACE LEFT IN %s", name); if (preen) @@ -561,9 +561,9 @@ expanddir(struct ext2fs_dinode *dp, char *name) bad: dp->e2di_blocks[lastbn] = dp->e2di_blocks[lastbn + 1]; dp->e2di_blocks[lastbn + 1] = 0; - dp->e2di_size = h2fs32(fs2h32(dp->e2di_size) - sblock.e2fs_bsize); + dp->e2di_size = htole32(letoh32(dp->e2di_size) - sblock.e2fs_bsize); inossize(dp, inosize(dp) - sblock.e2fs_bsize); - dp->e2di_nblock = h2fs32(fs2h32(dp->e2di_nblock) - 1); + dp->e2di_nblock = htole32(letoh32(dp->e2di_nblock) - 1); freeblk(newblk); return (0); } @@ -580,8 +580,8 @@ allocdir(ino_t parent, ino_t request, int mode) struct ext2fs_dirtemplate *dirp; ino = allocino(request, IFDIR|mode); - dirhead.dot_reclen = h2fs16(12); /* XXX */ - dirhead.dotdot_reclen = h2fs16(sblock.e2fs_bsize - 12); /* XXX */ + dirhead.dot_reclen = htole16(12); /* XXX */ + dirhead.dotdot_reclen = htole16(sblock.e2fs_bsize - 12); /* XXX */ dirhead.dot_namlen = 1; if (sblock.e2fs.e2fs_rev > E2FS_REV0 && (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) @@ -595,20 +595,20 @@ allocdir(ino_t parent, ino_t request, int mode) else dirhead.dotdot_type = 0; dirp = &dirhead; - dirp->dot_ino = h2fs32(ino); - dirp->dotdot_ino = h2fs32(parent); + dirp->dot_ino = htole32(ino); + dirp->dotdot_ino = htole32(parent); dp = ginode(ino); - bp = getdirblk(fs2h32(dp->e2di_blocks[0]), sblock.e2fs_bsize); + bp = getdirblk(letoh32(dp->e2di_blocks[0]), sblock.e2fs_bsize); if (bp->b_errs) { freeino(ino); return (0); } memcpy(bp->b_un.b_buf, dirp, sizeof(struct ext2fs_dirtemplate)); dirty(bp); - dp->e2di_nlink = h2fs16(2); + dp->e2di_nlink = htole16(2); inodirty(); if (ino == EXT2_ROOTINO) { - lncntp[ino] = fs2h16(dp->e2di_nlink); + lncntp[ino] = letoh16(dp->e2di_nlink); cacheino(dp, ino); return(ino); } @@ -619,11 +619,11 @@ allocdir(ino_t parent, ino_t request, int mode) cacheino(dp, ino); statemap[ino] = statemap[parent]; if (statemap[ino] == DSTATE) { - lncntp[ino] = fs2h16(dp->e2di_nlink); + lncntp[ino] = letoh16(dp->e2di_nlink); lncntp[parent]++; } dp = ginode(parent); - dp->e2di_nlink = h2fs16(fs2h16(dp->e2di_nlink) + 1); + dp->e2di_nlink = htole16(letoh16(dp->e2di_nlink) + 1); inodirty(); return (ino); } @@ -638,7 +638,7 @@ freedir(ino_t ino, ino_t parent) if (ino != parent) { dp = ginode(parent); - dp->e2di_nlink = h2fs16(fs2h16(dp->e2di_nlink) - 1); + dp->e2di_nlink = htole16(letoh16(dp->e2di_nlink) - 1); inodirty(); } freeino(ino); diff --git a/sbin/fsck_ext2fs/inode.c b/sbin/fsck_ext2fs/inode.c index 1f0712d87a8..068d529162e 100644 --- a/sbin/fsck_ext2fs/inode.c +++ b/sbin/fsck_ext2fs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.21 2014/07/11 13:50:01 pelikan Exp $ */ +/* $OpenBSD: inode.c,v 1.22 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: inode.c,v 1.8 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -56,7 +56,7 @@ */ #define fsck_ino_to_fsba(fs, x) \ - (fs2h32((fs)->e2fs_gd[ino_to_cg(fs, x)].ext2bgd_i_tables) + \ + (letoh32((fs)->e2fs_gd[ino_to_cg(fs, x)].ext2bgd_i_tables) + \ (((x)-1) % (fs)->e2fs.e2fs_ipg)/(fs)->e2fs_ipb) static ino_t startinum; @@ -85,10 +85,10 @@ setlarge(void) u_int64_t inosize(struct ext2fs_dinode *dp) { - u_int64_t size = fs2h32(dp->e2di_size); + u_int64_t size = letoh32(dp->e2di_size); - if ((fs2h16(dp->e2di_mode) & IFMT) == IFREG) - size |= (u_int64_t)fs2h32(dp->e2di_size_hi) << 32; + if ((letoh16(dp->e2di_mode) & IFMT) == IFREG) + size |= (u_int64_t)letoh32(dp->e2di_size_hi) << 32; if (size >= 0x80000000U) (void)setlarge(); return size; @@ -97,17 +97,17 @@ inosize(struct ext2fs_dinode *dp) void inossize(struct ext2fs_dinode *dp, u_int64_t size) { - if ((fs2h16(dp->e2di_mode) & IFMT) == IFREG) { - dp->e2di_size_hi = h2fs32(size >> 32); + if ((letoh16(dp->e2di_mode) & IFMT) == IFREG) { + dp->e2di_size_hi = htole32(size >> 32); if (size >= 0x80000000U) if (!setlarge()) return; } else if (size >= 0x80000000U) { pfatal("TRYING TO SET FILESIZE TO %llu ON MODE %x FILE\n", - (unsigned long long)size, fs2h16(dp->e2di_mode) & IFMT); + (unsigned long long)size, letoh16(dp->e2di_mode) & IFMT); return; } - dp->e2di_size = h2fs32(size); + dp->e2di_size = htole32(size); } int @@ -124,7 +124,7 @@ ckinode(struct ext2fs_dinode *dp, struct inodesc *idesc) idesc->id_fix = DONTKNOW; idesc->id_entryno = 0; idesc->id_filesize = inosize(dp); - mode = fs2h16(dp->e2di_mode) & IFMT; + mode = letoh16(dp->e2di_mode) & IFMT; if (mode == IFBLK || mode == IFCHR || mode == IFIFO || (mode == IFLNK && (inosize(dp) < EXT2_MAXSYMLINKLEN))) return (KEEPON); @@ -153,7 +153,7 @@ ckinode(struct ext2fs_dinode *dp, struct inodesc *idesc) } continue; } - idesc->id_blkno = fs2h32(*ap); + idesc->id_blkno = letoh32(*ap); if (idesc->id_type == ADDR) ret = (*idesc->id_func)(idesc); else @@ -166,7 +166,7 @@ ckinode(struct ext2fs_dinode *dp, struct inodesc *idesc) sizepb = sblock.e2fs_bsize; for (ap = &dino.e2di_blocks[NDADDR], n = 1; n <= NIADDR; ap++, n++) { if (*ap) { - idesc->id_blkno = fs2h32(*ap); + idesc->id_blkno = letoh32(*ap); ret = iblock(idesc, n, remsize); if (ret & STOP) return (ret); @@ -242,7 +242,7 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize) aplim = &bp->b_un.b_indir[nif]; for (ap = bp->b_un.b_indir; ap < aplim; ap++) { if (*ap) { - idesc->id_blkno = fs2h32(*ap); + idesc->id_blkno = letoh32(*ap); if (ilevel == 0) n = (*func)(idesc); else @@ -527,7 +527,7 @@ findname(struct inodesc *idesc) struct ext2fs_direct *dirp = idesc->id_dirp; u_int16_t namlen = dirp->e2d_namlen; - if (fs2h32(dirp->e2d_ino) != idesc->id_parent) + if (letoh32(dirp->e2d_ino) != idesc->id_parent) return (KEEPON); memcpy(idesc->id_name, dirp->e2d_name, (size_t)namlen); idesc->id_name[namlen] = '\0'; @@ -538,7 +538,7 @@ int findino(struct inodesc *idesc) { struct ext2fs_direct *dirp = idesc->id_dirp; - u_int32_t ino = fs2h32(dirp->e2d_ino); + u_int32_t ino = letoh32(dirp->e2d_ino); if (ino == 0) return (KEEPON); @@ -565,18 +565,18 @@ pinode(ino_t ino) return; dp = ginode(ino); printf(" OWNER="); - uid = fs2h16(dp->e2di_uid_low) | (fs2h16(dp->e2di_uid_high) << 16); + uid = letoh16(dp->e2di_uid_low) | (letoh16(dp->e2di_uid_high) << 16); #ifndef SMALL if ((pw = getpwuid((int)uid)) != 0) printf("%s ", pw->pw_name); else #endif printf("%u ", (unsigned)uid); - printf("MODE=%o\n", fs2h16(dp->e2di_mode)); + printf("MODE=%o\n", letoh16(dp->e2di_mode)); if (preen) printf("%s: ", cdevname()); printf("SIZE=%llu ", (long long)inosize(dp)); - t = (time_t)fs2h32(dp->e2di_mtime); + t = (time_t) letoh32(dp->e2di_mtime); p = ctime(&t); printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]); } @@ -641,18 +641,18 @@ allocino(ino_t request, int type) return (0); } dp = ginode(ino); - dp->e2di_blocks[0] = h2fs32(allocblk()); + dp->e2di_blocks[0] = htole32(allocblk()); if (dp->e2di_blocks[0] == 0) { statemap[ino] = USTATE; return (0); } - dp->e2di_mode = h2fs16(type); + dp->e2di_mode = htole16(type); (void)time(&t); - dp->e2di_atime = (u_int32_t)h2fs32(t); + dp->e2di_atime = (u_int32_t)htole32(t); dp->e2di_mtime = dp->e2di_ctime = dp->e2di_atime; dp->e2di_dtime = 0; inossize(dp, sblock.e2fs_bsize); - dp->e2di_nblock = h2fs32(btodb(sblock.e2fs_bsize)); + dp->e2di_nblock = htole32(btodb(sblock.e2fs_bsize)); n_files++; inodirty(); typemap[ino] = E2IFTODT(type); diff --git a/sbin/fsck_ext2fs/pass1.c b/sbin/fsck_ext2fs/pass1.c index 40ef4ab065a..6f463e9bf57 100644 --- a/sbin/fsck_ext2fs/pass1.c +++ b/sbin/fsck_ext2fs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.13 2013/04/24 13:46:27 deraadt Exp $ */ +/* $OpenBSD: pass1.c,v 1.14 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */ /* @@ -67,18 +67,18 @@ pass1(void) dbase = c * sblock.e2fs.e2fs_bpg + sblock.e2fs.e2fs_first_dblock; /* Mark the blocks used for the inode table */ - if (fs2h32(sblock.e2fs_gd[c].ext2bgd_i_tables) >= dbase) { + if (letoh32(sblock.e2fs_gd[c].ext2bgd_i_tables) >= dbase) { for (i = 0; i < sblock.e2fs_itpg; i++) setbmap( - fs2h32(sblock.e2fs_gd[c].ext2bgd_i_tables) + letoh32(sblock.e2fs_gd[c].ext2bgd_i_tables) + i); } /* Mark the blocks used for the block bitmap */ - if (fs2h32(sblock.e2fs_gd[c].ext2bgd_b_bitmap) >= dbase) - setbmap(fs2h32(sblock.e2fs_gd[c].ext2bgd_b_bitmap)); + if (letoh32(sblock.e2fs_gd[c].ext2bgd_b_bitmap) >= dbase) + setbmap(letoh32(sblock.e2fs_gd[c].ext2bgd_b_bitmap)); /* Mark the blocks used for the inode bitmap */ - if (fs2h32(sblock.e2fs_gd[c].ext2bgd_i_bitmap) >= dbase) - setbmap(fs2h32(sblock.e2fs_gd[c].ext2bgd_i_bitmap)); + if (letoh32(sblock.e2fs_gd[c].ext2bgd_i_bitmap) >= dbase) + setbmap(letoh32(sblock.e2fs_gd[c].ext2bgd_i_bitmap)); if (sblock.e2fs.e2fs_rev == E2FS_REV0 || (sblock.e2fs.e2fs_features_rocompat & @@ -130,7 +130,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) if (inumber < EXT2_FIRSTINO && inumber != EXT2_ROOTINO) return; - mode = fs2h16(dp->e2di_mode) & IFMT; + mode = letoh16(dp->e2di_mode) & IFMT; if (mode == 0 || (dp->e2di_dtime != 0 && dp->e2di_nlink == 0)) { if (mode == 0 && ( memcmp(dp->e2di_blocks, zino.e2di_blocks, @@ -154,7 +154,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) if (preen || reply("CORRECT")) { time_t t; time(&t); - dp->e2di_dtime = h2fs32(t); + dp->e2di_dtime = htole32(t); dp = ginode(inumber); inodirty(); } @@ -165,7 +165,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) } lastino = inumber; if (dp->e2di_dtime != 0) { - time_t t = fs2h32(dp->e2di_dtime); + time_t t = letoh32(dp->e2di_dtime); char *p = ctime(&t); pwarn("INODE I=%llu HAS DTIME=%12.12s %4.4s", (unsigned long long)inumber, &p[4], &p[20]); @@ -185,7 +185,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) } if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) { dp = ginode(inumber); - dp->e2di_mode = h2fs16(IFREG|0600); + dp->e2di_mode = htole16(IFREG|0600); inossize(dp, sblock.e2fs_bsize); inodirty(); } @@ -220,7 +220,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) if (dp->e2di_blocks[j] != 0) { if (debug) printf("bad direct addr: %d\n", - fs2h32(dp->e2di_blocks[j])); + letoh32(dp->e2di_blocks[j])); goto unknown; } for (j = 0, ndb -= NDADDR; ndb > 0; j++) @@ -229,7 +229,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) if (dp->e2di_blocks[j+NDADDR] != 0) { if (debug) printf("bad indirect addr: %d\n", - fs2h32(dp->e2di_blocks[j+NDADDR])); + letoh32(dp->e2di_blocks[j+NDADDR])); goto unknown; } } @@ -237,7 +237,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) if (ftypeok(dp) == 0) goto unknown; n_files++; - lncntp[inumber] = fs2h16(dp->e2di_nlink); + lncntp[inumber] = letoh16(dp->e2di_nlink); if (dp->e2di_nlink == 0) { zlnp = (struct zlncnt *)malloc(sizeof *zlnp); if (zlnp == NULL) { @@ -264,16 +264,16 @@ checkinode(ino_t inumber, struct inodesc *idesc) idesc->id_number = inumber; (void)ckinode(dp, idesc); idesc->id_entryno *= btodb(sblock.e2fs_bsize); - if (fs2h32(dp->e2di_nblock) != idesc->id_entryno) { + if (letoh32(dp->e2di_nblock) != idesc->id_entryno) { pwarn("INCORRECT BLOCK COUNT I=%llu (%d should be %d)", (unsigned long long)inumber, - fs2h32(dp->e2di_nblock), idesc->id_entryno); + letoh32(dp->e2di_nblock), idesc->id_entryno); if (preen) printf(" (CORRECTED)\n"); else if (reply("CORRECT") == 0) return; dp = ginode(inumber); - dp->e2di_nblock = h2fs32(idesc->id_entryno); + dp->e2di_nblock = htole32(idesc->id_entryno); inodirty(); } return; diff --git a/sbin/fsck_ext2fs/pass2.c b/sbin/fsck_ext2fs/pass2.c index 7bcb12ce6cc..81d06949b37 100644 --- a/sbin/fsck_ext2fs/pass2.c +++ b/sbin/fsck_ext2fs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.12 2013/04/24 13:46:27 deraadt Exp $ */ +/* $OpenBSD: pass2.c,v 1.13 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: pass2.c,v 1.6 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -96,7 +96,7 @@ pass2(void) if (reply("FIX") == 0) errexit("%s\n", ""); dp = ginode(EXT2_ROOTINO); - dp->e2di_mode = h2fs16((fs2h16(dp->e2di_mode) & ~IFMT) | IFDIR); + dp->e2di_mode = htole16((letoh16(dp->e2di_mode) & ~IFMT) | IFDIR); inodirty(); break; @@ -145,7 +145,7 @@ pass2(void) } } memset(&dino, 0, sizeof(struct ext2fs_dinode)); - dino.e2di_mode = h2fs16(IFDIR); + dino.e2di_mode = htole16(IFDIR); inossize(&dino, inp->i_isize); memcpy(&dino.e2di_blocks[0], &inp->i_blks[0], (size_t)inp->i_numblks); curino.id_number = inp->i_number; @@ -204,11 +204,11 @@ pass2check(struct inodesc *idesc) */ if (idesc->id_entryno != 0) goto chk1; - if (fs2h32(dirp->e2d_ino) != 0 && dirp->e2d_namlen == 1 && + if (letoh32(dirp->e2d_ino) != 0 && dirp->e2d_namlen == 1 && dirp->e2d_name[0] == '.') { - if (fs2h32(dirp->e2d_ino) != idesc->id_number) { + if (letoh32(dirp->e2d_ino) != idesc->id_number) { direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'"); - dirp->e2d_ino = h2fs32(idesc->id_number); + dirp->e2d_ino = htole32(idesc->id_number); if (reply("FIX") == 1) ret |= ALTERED; } @@ -223,7 +223,7 @@ pass2check(struct inodesc *idesc) goto chk1; } direrror(idesc->id_number, "MISSING '.'"); - proto.e2d_ino = h2fs32(idesc->id_number); + proto.e2d_ino = htole32(idesc->id_number); proto.e2d_namlen = 1; if (sblock.e2fs.e2fs_rev > E2FS_REV0 && (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) @@ -232,25 +232,25 @@ pass2check(struct inodesc *idesc) proto.e2d_type = 0; (void)strlcpy(proto.e2d_name, ".", sizeof proto.e2d_name); entrysize = EXT2FS_DIRSIZ(proto.e2d_namlen); - if (fs2h32(dirp->e2d_ino) != 0 && strcmp(dirp->e2d_name, "..") != 0) { + if (letoh32(dirp->e2d_ino) != 0 && strcmp(dirp->e2d_name, "..") != 0) { pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", dirp->e2d_name); - } else if (fs2h16(dirp->e2d_reclen) < entrysize) { + } else if (letoh16(dirp->e2d_reclen) < entrysize) { pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n"); - } else if (fs2h16(dirp->e2d_reclen) < 2 * entrysize) { + } else if (letoh16(dirp->e2d_reclen) < 2 * entrysize) { proto.e2d_reclen = dirp->e2d_reclen; memcpy(dirp, &proto, (size_t)entrysize); if (reply("FIX") == 1) ret |= ALTERED; } else { - n = fs2h16(dirp->e2d_reclen) - entrysize; - proto.e2d_reclen = h2fs16(entrysize); + n = letoh16(dirp->e2d_reclen) - entrysize; + proto.e2d_reclen = htole16(entrysize); memcpy(dirp, &proto, (size_t)entrysize); idesc->id_entryno++; - lncntp[fs2h32(dirp->e2d_ino)]--; + lncntp[letoh32(dirp->e2d_ino)]--; dirp = (struct ext2fs_direct *)((char *)(dirp) + entrysize); memset(dirp, 0, (size_t)n); - dirp->e2d_reclen = h2fs16(n); + dirp->e2d_reclen = htole16(n); if (reply("FIX") == 1) ret |= ALTERED; } @@ -258,7 +258,7 @@ chk1: if (idesc->id_entryno > 1) goto chk2; inp = getinoinfo(idesc->id_number); - proto.e2d_ino = h2fs32(inp->i_parent); + proto.e2d_ino = htole32(inp->i_parent); proto.e2d_namlen = 2; if (sblock.e2fs.e2fs_rev > E2FS_REV0 && (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) @@ -269,20 +269,20 @@ chk1: entrysize = EXT2FS_DIRSIZ(2); if (idesc->id_entryno == 0) { n = EXT2FS_DIRSIZ(dirp->e2d_namlen); - if (fs2h16(dirp->e2d_reclen) < n + entrysize) + if (letoh16(dirp->e2d_reclen) < n + entrysize) goto chk2; - proto.e2d_reclen = h2fs16(fs2h16(dirp->e2d_reclen) - n); - dirp->e2d_reclen = h2fs16(n); + proto.e2d_reclen = htole16(letoh16(dirp->e2d_reclen) - n); + dirp->e2d_reclen = htole16(n); idesc->id_entryno++; - lncntp[fs2h32(dirp->e2d_ino)]--; + lncntp[letoh32(dirp->e2d_ino)]--; dirp = (struct ext2fs_direct *)((char *)(dirp) + n); - memset(dirp, 0, (size_t)fs2h16(proto.e2d_reclen)); + memset(dirp, 0, (size_t)letoh16(proto.e2d_reclen)); dirp->e2d_reclen = proto.e2d_reclen; } - if (fs2h32(dirp->e2d_ino) != 0 && + if (letoh32(dirp->e2d_ino) != 0 && dirp->e2d_namlen == 2 && strncmp(dirp->e2d_name, "..", 2) == 0) { - inp->i_dotdot = fs2h32(dirp->e2d_ino); + inp->i_dotdot = letoh32(dirp->e2d_ino); if (sblock.e2fs.e2fs_rev > E2FS_REV0 && (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE) && dirp->e2d_type != EXT2_FT_DIR) { @@ -293,14 +293,14 @@ chk1: } goto chk2; } - if (fs2h32(dirp->e2d_ino) != 0 && + if (letoh32(dirp->e2d_ino) != 0 && dirp->e2d_namlen == 1 && strncmp(dirp->e2d_name, ".", 1) != 0) { fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n", dirp->e2d_name); inp->i_dotdot = (ino_t)-1; - } else if (fs2h16(dirp->e2d_reclen) < entrysize) { + } else if (letoh16(dirp->e2d_reclen) < entrysize) { fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n"); inp->i_dotdot = (ino_t)-1; @@ -316,11 +316,11 @@ chk1: ret |= ALTERED; } idesc->id_entryno++; - if (fs2h32(dirp->e2d_ino) != 0) - lncntp[fs2h32(dirp->e2d_ino)]--; + if (letoh32(dirp->e2d_ino) != 0) + lncntp[letoh32(dirp->e2d_ino)]--; return (ret|KEEPON); chk2: - if (fs2h32(dirp->e2d_ino) == 0) + if (letoh32(dirp->e2d_ino) == 0) return (ret|KEEPON); if (dirp->e2d_namlen <= 2 && dirp->e2d_name[0] == '.' && @@ -342,18 +342,18 @@ chk2: } idesc->id_entryno++; n = 0; - if (fs2h32(dirp->e2d_ino) > maxino || - (fs2h32(dirp->e2d_ino) < EXT2_FIRSTINO && - fs2h32(dirp->e2d_ino) != EXT2_ROOTINO)) { - fileerror(idesc->id_number, fs2h32(dirp->e2d_ino), "I OUT OF RANGE"); + if (letoh32(dirp->e2d_ino) > maxino || + (letoh32(dirp->e2d_ino) < EXT2_FIRSTINO && + letoh32(dirp->e2d_ino) != EXT2_ROOTINO)) { + fileerror(idesc->id_number, letoh32(dirp->e2d_ino), "I OUT OF RANGE"); n = reply("REMOVE"); } else { again: - switch (statemap[fs2h32(dirp->e2d_ino)]) { + switch (statemap[letoh32(dirp->e2d_ino)]) { case USTATE: if (idesc->id_entryno <= 2) break; - fileerror(idesc->id_number, fs2h32(dirp->e2d_ino), "UNALLOCATED"); + fileerror(idesc->id_number, letoh32(dirp->e2d_ino), "UNALLOCATED"); n = reply("REMOVE"); break; @@ -361,7 +361,7 @@ again: case FCLEAR: if (idesc->id_entryno <= 2) break; - if (statemap[fs2h32(dirp->e2d_ino)] == FCLEAR) + if (statemap[letoh32(dirp->e2d_ino)] == FCLEAR) errmsg = "DUP/BAD"; else if (!preen) errmsg = "ZERO LENGTH DIRECTORY"; @@ -369,23 +369,23 @@ again: n = 1; break; } - fileerror(idesc->id_number, fs2h32(dirp->e2d_ino), errmsg); + fileerror(idesc->id_number, letoh32(dirp->e2d_ino), errmsg); if ((n = reply("REMOVE")) == 1) break; - dp = ginode(fs2h32(dirp->e2d_ino)); - statemap[fs2h32(dirp->e2d_ino)] = - (fs2h16(dp->e2di_mode) & IFMT) == IFDIR ? DSTATE : FSTATE; - lncntp[fs2h32(dirp->e2d_ino)] = fs2h16(dp->e2di_nlink); + dp = ginode(letoh32(dirp->e2d_ino)); + statemap[letoh32(dirp->e2d_ino)] = + (letoh16(dp->e2di_mode) & IFMT) == IFDIR ? DSTATE : FSTATE; + lncntp[letoh32(dirp->e2d_ino)] = letoh16(dp->e2di_nlink); goto again; case DSTATE: case DFOUND: - inp = getinoinfo(fs2h32(dirp->e2d_ino)); + inp = getinoinfo(letoh32(dirp->e2d_ino)); if (inp->i_parent != 0 && idesc->id_entryno > 2) { getpathname(pathbuf, sizeof pathbuf, idesc->id_number, idesc->id_number); getpathname(namebuf, sizeof namebuf, - fs2h32(dirp->e2d_ino), fs2h32(dirp->e2d_ino)); + letoh32(dirp->e2d_ino), letoh32(dirp->e2d_ino)); pwarn("%s %s %s\n", pathbuf, "IS AN EXTRANEOUS HARD LINK TO DIRECTORY", namebuf); @@ -403,22 +403,22 @@ again: (sblock.e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE) && dirp->e2d_type != - inot2ext2dt(typemap[fs2h32(dirp->e2d_ino)])) { + inot2ext2dt(typemap[letoh32(dirp->e2d_ino)])) { dirp->e2d_type = - inot2ext2dt(typemap[fs2h32(dirp->e2d_ino)]); + inot2ext2dt(typemap[letoh32(dirp->e2d_ino)]); fileerror(idesc->id_number, - fs2h32(dirp->e2d_ino), + letoh32(dirp->e2d_ino), "BAD TYPE VALUE"); if (reply("FIX") == 1) ret |= ALTERED; } - lncntp[fs2h32(dirp->e2d_ino)]--; + lncntp[letoh32(dirp->e2d_ino)]--; break; default: errexit("BAD STATE %d FOR INODE I=%llu\n", - statemap[fs2h32(dirp->e2d_ino)], - (unsigned long long)fs2h32(dirp->e2d_ino)); + statemap[letoh32(dirp->e2d_ino)], + (unsigned long long)letoh32(dirp->e2d_ino)); } } if (n == 0) diff --git a/sbin/fsck_ext2fs/pass5.c b/sbin/fsck_ext2fs/pass5.c index 5558aa4eef8..151bda78aa3 100644 --- a/sbin/fsck_ext2fs/pass5.c +++ b/sbin/fsck_ext2fs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.16 2013/04/24 13:46:27 deraadt Exp $ */ +/* $OpenBSD: pass5.c,v 1.17 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: pass5.c,v 1.7 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -81,17 +81,17 @@ pass5(void) ndirs = 0; if (blk_bitmap == NULL) { - blk_bitmap = getdatablk(fs2h32(fs->e2fs_gd[c].ext2bgd_b_bitmap), + blk_bitmap = getdatablk(letoh32(fs->e2fs_gd[c].ext2bgd_b_bitmap), fs->e2fs_bsize); } else { - getblk(blk_bitmap, fs2h32(fs->e2fs_gd[c].ext2bgd_b_bitmap), + getblk(blk_bitmap, letoh32(fs->e2fs_gd[c].ext2bgd_b_bitmap), fs->e2fs_bsize); } if (ino_bitmap == NULL) { - ino_bitmap = getdatablk(fs2h32(fs->e2fs_gd[c].ext2bgd_i_bitmap), + ino_bitmap = getdatablk(letoh32(fs->e2fs_gd[c].ext2bgd_i_bitmap), fs->e2fs_bsize); } else { - getblk(ino_bitmap, fs2h32(fs->e2fs_gd[c].ext2bgd_i_bitmap), + getblk(ino_bitmap, letoh32(fs->e2fs_gd[c].ext2bgd_i_bitmap), fs->e2fs_bsize); } memset(bbmap, 0, fs->e2fs_bsize); @@ -160,27 +160,27 @@ pass5(void) cs_nifree += nifree; cs_ndir += ndirs; - if (debug && (fs2h16(fs->e2fs_gd[c].ext2bgd_nbfree) != nbfree || - fs2h16(fs->e2fs_gd[c].ext2bgd_nifree) != nifree || - fs2h16(fs->e2fs_gd[c].ext2bgd_ndirs) != ndirs)) { + if (debug && (letoh16(fs->e2fs_gd[c].ext2bgd_nbfree) != nbfree || + letoh16(fs->e2fs_gd[c].ext2bgd_nifree) != nifree || + letoh16(fs->e2fs_gd[c].ext2bgd_ndirs) != ndirs)) { printf("summary info for cg %d is %d, %d, %d," "should be %d, %d, %d\n", c, - fs2h16(fs->e2fs_gd[c].ext2bgd_nbfree), - fs2h16(fs->e2fs_gd[c].ext2bgd_nifree), - fs2h16(fs->e2fs_gd[c].ext2bgd_ndirs), + letoh16(fs->e2fs_gd[c].ext2bgd_nbfree), + letoh16(fs->e2fs_gd[c].ext2bgd_nifree), + letoh16(fs->e2fs_gd[c].ext2bgd_ndirs), nbfree, nifree, ndirs); } (void)snprintf(msg, sizeof(msg), "SUMMARY INFORMATIONS WRONG FOR CG #%d", c); - if ((fs2h16(fs->e2fs_gd[c].ext2bgd_nbfree) != nbfree || - fs2h16(fs->e2fs_gd[c].ext2bgd_nifree) != nifree || - fs2h16(fs->e2fs_gd[c].ext2bgd_ndirs) != ndirs) && + if ((letoh16(fs->e2fs_gd[c].ext2bgd_nbfree) != nbfree || + letoh16(fs->e2fs_gd[c].ext2bgd_nifree) != nifree || + letoh16(fs->e2fs_gd[c].ext2bgd_ndirs) != ndirs) && dofix(&idesc[0], msg)) { - fs->e2fs_gd[c].ext2bgd_nbfree = h2fs16(nbfree); - fs->e2fs_gd[c].ext2bgd_nifree = h2fs16(nifree); - fs->e2fs_gd[c].ext2bgd_ndirs = h2fs16(ndirs); + fs->e2fs_gd[c].ext2bgd_nbfree = htole16(nbfree); + fs->e2fs_gd[c].ext2bgd_nifree = htole16(nifree); + fs->e2fs_gd[c].ext2bgd_ndirs = htole16(ndirs); sbdirty(); } diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index a5e895d0289..0fa3bb3d5ac 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.22 2014/07/13 13:50:00 pelikan Exp $ */ +/* $OpenBSD: setup.c,v 1.23 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -226,7 +226,7 @@ setup(char *dev) goto badsblabel; } for (numdirs = 0, cg = 0; cg < sblock.e2fs_ncg; cg++) { - numdirs += fs2h16(sblock.e2fs_gd[cg].ext2bgd_ndirs); + numdirs += letoh16(sblock.e2fs_gd[cg].ext2bgd_ndirs); } inplast = 0; listmax = numdirs + 10; @@ -363,8 +363,8 @@ readsb(int listerr) continue; printf("offset %ld, original %ld, alternate %ld\n", (long)(olp - (u_int32_t *)sblk.b_un.b_fs), - (long)fs2h32(*olp), - (long)fs2h32(*nlp)); + (long)letoh32(*olp), + (long)letoh32(*nlp)); } } badsb(listerr, @@ -379,32 +379,32 @@ void copyback_sb(struct bufarea *bp) { /* Copy the in-memory superblock back to buffer */ - bp->b_un.b_fs->e2fs_icount = fs2h32(sblock.e2fs.e2fs_icount); - bp->b_un.b_fs->e2fs_bcount = fs2h32(sblock.e2fs.e2fs_bcount); - bp->b_un.b_fs->e2fs_rbcount = fs2h32(sblock.e2fs.e2fs_rbcount); - bp->b_un.b_fs->e2fs_fbcount = fs2h32(sblock.e2fs.e2fs_fbcount); - bp->b_un.b_fs->e2fs_ficount = fs2h32(sblock.e2fs.e2fs_ficount); + bp->b_un.b_fs->e2fs_icount = letoh32(sblock.e2fs.e2fs_icount); + bp->b_un.b_fs->e2fs_bcount = letoh32(sblock.e2fs.e2fs_bcount); + bp->b_un.b_fs->e2fs_rbcount = letoh32(sblock.e2fs.e2fs_rbcount); + bp->b_un.b_fs->e2fs_fbcount = letoh32(sblock.e2fs.e2fs_fbcount); + bp->b_un.b_fs->e2fs_ficount = letoh32(sblock.e2fs.e2fs_ficount); bp->b_un.b_fs->e2fs_first_dblock = - fs2h32(sblock.e2fs.e2fs_first_dblock); - bp->b_un.b_fs->e2fs_log_bsize = fs2h32(sblock.e2fs.e2fs_log_bsize); - bp->b_un.b_fs->e2fs_log_fsize = fs2h32(sblock.e2fs.e2fs_log_fsize); - bp->b_un.b_fs->e2fs_bpg = fs2h32(sblock.e2fs.e2fs_bpg); - bp->b_un.b_fs->e2fs_fpg = fs2h32(sblock.e2fs.e2fs_fpg); - bp->b_un.b_fs->e2fs_ipg = fs2h32(sblock.e2fs.e2fs_ipg); - bp->b_un.b_fs->e2fs_mtime = fs2h32(sblock.e2fs.e2fs_mtime); - bp->b_un.b_fs->e2fs_wtime = fs2h32(sblock.e2fs.e2fs_wtime); - bp->b_un.b_fs->e2fs_lastfsck = fs2h32(sblock.e2fs.e2fs_lastfsck); - bp->b_un.b_fs->e2fs_fsckintv = fs2h32(sblock.e2fs.e2fs_fsckintv); - bp->b_un.b_fs->e2fs_creator = fs2h32(sblock.e2fs.e2fs_creator); - bp->b_un.b_fs->e2fs_rev = fs2h32(sblock.e2fs.e2fs_rev); - bp->b_un.b_fs->e2fs_mnt_count = fs2h16(sblock.e2fs.e2fs_mnt_count); + letoh32(sblock.e2fs.e2fs_first_dblock); + bp->b_un.b_fs->e2fs_log_bsize = letoh32(sblock.e2fs.e2fs_log_bsize); + bp->b_un.b_fs->e2fs_log_fsize = letoh32(sblock.e2fs.e2fs_log_fsize); + bp->b_un.b_fs->e2fs_bpg = letoh32(sblock.e2fs.e2fs_bpg); + bp->b_un.b_fs->e2fs_fpg = letoh32(sblock.e2fs.e2fs_fpg); + bp->b_un.b_fs->e2fs_ipg = letoh32(sblock.e2fs.e2fs_ipg); + bp->b_un.b_fs->e2fs_mtime = letoh32(sblock.e2fs.e2fs_mtime); + bp->b_un.b_fs->e2fs_wtime = letoh32(sblock.e2fs.e2fs_wtime); + bp->b_un.b_fs->e2fs_lastfsck = letoh32(sblock.e2fs.e2fs_lastfsck); + bp->b_un.b_fs->e2fs_fsckintv = letoh32(sblock.e2fs.e2fs_fsckintv); + bp->b_un.b_fs->e2fs_creator = letoh32(sblock.e2fs.e2fs_creator); + bp->b_un.b_fs->e2fs_rev = letoh32(sblock.e2fs.e2fs_rev); + bp->b_un.b_fs->e2fs_mnt_count = letoh16(sblock.e2fs.e2fs_mnt_count); bp->b_un.b_fs->e2fs_max_mnt_count = - fs2h16(sblock.e2fs.e2fs_max_mnt_count); - bp->b_un.b_fs->e2fs_magic = fs2h16(sblock.e2fs.e2fs_magic); - bp->b_un.b_fs->e2fs_state = fs2h16(sblock.e2fs.e2fs_state); - bp->b_un.b_fs->e2fs_beh = fs2h16(sblock.e2fs.e2fs_beh); - bp->b_un.b_fs->e2fs_ruid = fs2h16(sblock.e2fs.e2fs_ruid); - bp->b_un.b_fs->e2fs_rgid = fs2h16(sblock.e2fs.e2fs_rgid); + letoh16(sblock.e2fs.e2fs_max_mnt_count); + bp->b_un.b_fs->e2fs_magic = letoh16(sblock.e2fs.e2fs_magic); + bp->b_un.b_fs->e2fs_state = letoh16(sblock.e2fs.e2fs_state); + bp->b_un.b_fs->e2fs_beh = letoh16(sblock.e2fs.e2fs_beh); + bp->b_un.b_fs->e2fs_ruid = letoh16(sblock.e2fs.e2fs_ruid); + bp->b_un.b_fs->e2fs_rgid = letoh16(sblock.e2fs.e2fs_rgid); } void diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index a23ae0ca3b2..7601ec6ea76 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.22 2014/05/24 14:54:49 krw Exp $ */ +/* $OpenBSD: utilities.c,v 1.23 2014/07/13 16:08:53 pelikan Exp $ */ /* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */ /* @@ -55,7 +55,7 @@ static void rwerror(char *, daddr32_t); int ftypeok(struct ext2fs_dinode *dp) { - switch (fs2h16(dp->e2di_mode) & IFMT) { + switch (letoh16(dp->e2di_mode) & IFMT) { case IFDIR: case IFREG: @@ -68,7 +68,7 @@ ftypeok(struct ext2fs_dinode *dp) default: if (debug) - printf("bad file type 0%o\n", fs2h16(dp->e2di_mode)); + printf("bad file type 0%o\n", letoh16(dp->e2di_mode)); return (0); } }