Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/lfs/lfs_accessors.h,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/lfs/lfs_accessors.h,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.33 retrieving revision 1.33.2.6 diff -u -p -r1.33 -r1.33.2.6 --- src/sys/ufs/lfs/lfs_accessors.h 2015/09/21 01:24:58 1.33 +++ src/sys/ufs/lfs/lfs_accessors.h 2017/02/05 13:41:01 1.33.2.6 @@ -1,8 +1,8 @@ -/* $NetBSD: lfs_accessors.h,v 1.33 2015/09/21 01:24:58 dholland Exp $ */ +/* $NetBSD: lfs_accessors.h,v 1.33.2.6 2017/02/05 13:41:01 skrll Exp $ */ /* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */ -/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ -/* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ +/* from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp */ +/* from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -151,9 +151,14 @@ #include +#include + #if !defined(_KERNEL) && !defined(_STANDALONE) #include +#include #define KASSERT assert +#else +#include #endif /* @@ -255,7 +260,7 @@ #define LFS_NEXTDIR(fs, dp) \ ((LFS_DIRHEADER *)((char *)(dp) + lfs_dir_getreclen(fs, dp))) -static __unused inline char * +static __inline char * lfs_dir_nameptr(const STRUCT_LFS *fs, LFS_DIRHEADER *dh) { if (fs->lfs_is64) { @@ -265,7 +270,7 @@ lfs_dir_nameptr(const STRUCT_LFS *fs, LF } } -static __unused inline uint64_t +static __inline uint64_t lfs_dir_getino(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) { if (fs->lfs_is64) { @@ -285,7 +290,7 @@ lfs_dir_getino(const STRUCT_LFS *fs, con } } -static __unused inline uint16_t +static __inline uint16_t lfs_dir_getreclen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) { if (fs->lfs_is64) { @@ -295,7 +300,7 @@ lfs_dir_getreclen(const STRUCT_LFS *fs, } } -static __unused inline uint8_t +static __inline uint8_t lfs_dir_gettype(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) { if (fs->lfs_is64) { @@ -308,12 +313,12 @@ lfs_dir_gettype(const STRUCT_LFS *fs, co } } -static __unused inline uint8_t +static __inline uint8_t lfs_dir_getnamlen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) { if (fs->lfs_is64) { KASSERT(fs->lfs_hasolddirfmt == 0); - return dh->u_64.dh_type; + return dh->u_64.dh_namlen; } else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) { /* low-order byte of old 16-bit namlen field */ return dh->u_32.dh_type; @@ -322,7 +327,7 @@ lfs_dir_getnamlen(const STRUCT_LFS *fs, } } -static __unused inline void +static __inline void lfs_dir_setino(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint64_t ino) { if (fs->lfs_is64) { @@ -341,7 +346,7 @@ lfs_dir_setino(STRUCT_LFS *fs, LFS_DIRHE } } -static __unused inline void +static __inline void lfs_dir_setreclen(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint16_t reclen) { if (fs->lfs_is64) { @@ -351,7 +356,7 @@ lfs_dir_setreclen(STRUCT_LFS *fs, LFS_DI } } -static __unused inline void +static __inline void lfs_dir_settype(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t type) { if (fs->lfs_is64) { @@ -365,7 +370,7 @@ lfs_dir_settype(const STRUCT_LFS *fs, LF } } -static __unused inline void +static __inline void lfs_dir_setnamlen(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t namlen) { if (fs->lfs_is64) { @@ -379,7 +384,7 @@ lfs_dir_setnamlen(const STRUCT_LFS *fs, } } -static __unused inline void +static __inline void lfs_copydirname(STRUCT_LFS *fs, char *dest, const char *src, unsigned namlen, unsigned reclen) { @@ -395,7 +400,7 @@ lfs_copydirname(STRUCT_LFS *fs, char *de memset(dest + namlen, '\0', spacelen - namlen); } -static __unused LFS_DIRHEADER * +static __inline LFS_DIRHEADER * lfs_dirtemplate_dotdot(STRUCT_LFS *fs, union lfs_dirtemplate *dt) { /* XXX blah, be nice to have a way to do this w/o casts */ @@ -406,7 +411,7 @@ lfs_dirtemplate_dotdot(STRUCT_LFS *fs, u } } -static __unused char * +static __inline char * lfs_dirtemplate_dotdotname(STRUCT_LFS *fs, union lfs_dirtemplate *dt) { if (fs->lfs_is64) { @@ -434,7 +439,7 @@ lfs_dirtemplate_dotdotname(STRUCT_LFS *f #define DINO_IN_BLOCK(fs, base, ix) \ ((union lfs_dinode *)((char *)(base) + DINOSIZE(fs) * (ix))) -static __unused inline void +static __inline void lfs_copy_dinode(STRUCT_LFS *fs, union lfs_dinode *dst, const union lfs_dinode *src) { @@ -452,7 +457,7 @@ lfs_copy_dinode(STRUCT_LFS *fs, } #define LFS_DEF_DINO_ACCESSOR(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_dino_get##field(STRUCT_LFS *fs, union lfs_dinode *dip) \ { \ if (fs->lfs_is64) { \ @@ -461,7 +466,7 @@ lfs_copy_dinode(STRUCT_LFS *fs, return LFS_SWAP_##type32(fs, dip->u_32.di_##field); \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_dino_set##field(STRUCT_LFS *fs, union lfs_dinode *dip, type val) \ { \ if (fs->lfs_is64) { \ @@ -492,54 +497,56 @@ LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid); /* XXX this should be done differently (it's a fake field) */ -LFS_DEF_DINO_ACCESSOR(uint64_t, int32_t, rdev); +LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev); -static __unused inline daddr_t +static __inline daddr_t lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) { KASSERT(ix < ULFS_NDADDR); if (fs->lfs_is64) { - return dip->u_64.di_db[ix]; + return LFS_SWAP_int64_t(fs, dip->u_64.di_db[ix]); } else { - return dip->u_32.di_db[ix]; + /* note: this must sign-extend or UNWRITTEN gets trashed */ + return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_db[ix]); } } -static __unused inline daddr_t +static __inline daddr_t lfs_dino_getib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) { KASSERT(ix < ULFS_NIADDR); if (fs->lfs_is64) { - return dip->u_64.di_ib[ix]; + return LFS_SWAP_int64_t(fs, dip->u_64.di_ib[ix]); } else { - return dip->u_32.di_ib[ix]; + /* note: this must sign-extend or UNWRITTEN gets trashed */ + return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_ib[ix]); } } -static __unused inline void +static __inline void lfs_dino_setdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val) { KASSERT(ix < ULFS_NDADDR); if (fs->lfs_is64) { - dip->u_64.di_db[ix] = val; + dip->u_64.di_db[ix] = LFS_SWAP_int64_t(fs, val); } else { - dip->u_32.di_db[ix] = val; + dip->u_32.di_db[ix] = LFS_SWAP_uint32_t(fs, val); } } -static __unused inline void +static __inline void lfs_dino_setib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val) { KASSERT(ix < ULFS_NIADDR); if (fs->lfs_is64) { - dip->u_64.di_ib[ix] = val; + dip->u_64.di_ib[ix] = LFS_SWAP_int64_t(fs, val); } else { - dip->u_32.di_ib[ix] = val; + dip->u_32.di_ib[ix] = LFS_SWAP_uint32_t(fs, val); } } /* birthtime is present only in the 64-bit inode */ -static __unused inline void +static __inline void lfs_dino_setbirthtime(STRUCT_LFS *fs, union lfs_dinode *dip, const struct timespec *ts) { @@ -555,7 +562,7 @@ lfs_dino_setbirthtime(STRUCT_LFS *fs, un * indirect blocks */ -static __unused inline daddr_t +static __inline daddr_t lfs_iblock_get(STRUCT_LFS *fs, void *block, unsigned ix) { if (fs->lfs_is64) { @@ -569,7 +576,7 @@ lfs_iblock_get(STRUCT_LFS *fs, void *blo } } -static __unused inline void +static __inline void lfs_iblock_set(STRUCT_LFS *fs, void *block, unsigned ix, daddr_t val) { if (fs->lfs_is64) { @@ -669,7 +676,8 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo if ((_e = bread((F)->lfs_ivnode, \ ((IN) / lfs_sb_getsepb(F)) + lfs_sb_getcleansz(F), \ lfs_sb_getbsize(F), 0, &(BP))) != 0) \ - panic("lfs: ifile read: %d", _e); \ + panic("lfs: ifile read: segentry %llu: error %d\n", \ + (unsigned long long)(IN), _e); \ if (lfs_sb_getversion(F) == 1) \ (SP) = (SEGUSE *)((SEGUSE_V1 *)(BP)->b_data + \ ((IN) & (lfs_sb_getsepb(F) - 1))); \ @@ -710,7 +718,7 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo ((FINFO *)((char *)(fip) + FINFO_FULLSIZE(fs, fip))) #define LFS_DEF_FI_ACCESSOR(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_fi_get##field(STRUCT_LFS *fs, FINFO *fip) \ { \ if (fs->lfs_is64) { \ @@ -719,7 +727,7 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo return fip->u_32.fi_##field; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_fi_set##field(STRUCT_LFS *fs, FINFO *fip, type val) \ { \ if (fs->lfs_is64) { \ @@ -738,31 +746,67 @@ LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino); LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength); -static __unused inline daddr_t -lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned index) +static __inline daddr_t +lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx) { void *firstblock; firstblock = (char *)fip + FINFOSIZE(fs); - KASSERT(index < lfs_fi_getnblocks(fs, fip)); + KASSERT(idx < lfs_fi_getnblocks(fs, fip)); if (fs->lfs_is64) { - return ((int64_t *)firstblock)[index]; + return ((int64_t *)firstblock)[idx]; } else { - return ((int32_t *)firstblock)[index]; + return ((int32_t *)firstblock)[idx]; } } -static __unused inline void -lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned index, daddr_t blk) +static __inline void +lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx, daddr_t blk) { void *firstblock; firstblock = (char *)fip + FINFOSIZE(fs); - KASSERT(index < lfs_fi_getnblocks(fs, fip)); + KASSERT(idx < lfs_fi_getnblocks(fs, fip)); if (fs->lfs_is64) { - ((int64_t *)firstblock)[index] = blk; + ((int64_t *)firstblock)[idx] = blk; } else { - ((int32_t *)firstblock)[index] = blk; + ((int32_t *)firstblock)[idx] = blk; + } +} + +/* + * inode info entries (in the segment summary) + */ + +#define IINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32)) + +/* iinfos scroll backward from the end of the segment summary block */ +#define SEGSUM_IINFOSTART(fs, buf) \ + ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs))) + +#define NEXTLOWER_IINFO(fs, iip) \ + ((IINFO *)((char *)(iip) - IINFOSIZE(fs))) + +#define NTH_IINFO(fs, buf, n) \ + ((IINFO *)((char *)SEGSUM_IINFOSTART(fs, buf) - (n)*IINFOSIZE(fs))) + +static __inline uint64_t +lfs_ii_getblock(STRUCT_LFS *fs, IINFO *iip) +{ + if (fs->lfs_is64) { + return iip->u_64.ii_block; + } else { + return iip->u_32.ii_block; + } +} + +static __inline void +lfs_ii_setblock(STRUCT_LFS *fs, IINFO *iip, uint64_t block) +{ + if (fs->lfs_is64) { + iip->u_64.ii_block = block; + } else { + iip->u_32.ii_block = block; } } @@ -809,7 +853,7 @@ lfs_fi_setblock(STRUCT_LFS *fs, FINFO *f } while (0) #define LFS_DEF_IF_ACCESSOR(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_if_get##field(STRUCT_LFS *fs, IFILE *ifp) \ { \ if (fs->lfs_is64) { \ @@ -818,7 +862,7 @@ lfs_fi_setblock(STRUCT_LFS *fs, FINFO *f return ifp->u_32.if_##field; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_if_set##field(STRUCT_LFS *fs, IFILE *ifp, type val) \ { \ if (fs->lfs_is64) { \ @@ -832,11 +876,11 @@ lfs_fi_setblock(STRUCT_LFS *fs, FINFO *f } \ } \ -LFS_DEF_IF_ACCESSOR(u_int32_t, u_int32_t, version); +LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, version); LFS_DEF_IF_ACCESSOR(int64_t, int32_t, daddr); -LFS_DEF_IF_ACCESSOR(u_int64_t, u_int32_t, nextfree); -LFS_DEF_IF_ACCESSOR(u_int64_t, u_int32_t, atime_sec); -LFS_DEF_IF_ACCESSOR(u_int32_t, u_int32_t, atime_nsec); +LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, nextfree); +LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, atime_sec); +LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, atime_nsec); /* * Cleaner information structure. This resides in the ifile and is used @@ -848,7 +892,7 @@ LFS_DEF_IF_ACCESSOR(u_int32_t, u_int32_t lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs)) #define LFS_DEF_CI_ACCESSOR(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_ci_get##field(STRUCT_LFS *fs, CLEANERINFO *cip) \ { \ if (fs->lfs_is64) { \ @@ -857,7 +901,7 @@ LFS_DEF_IF_ACCESSOR(u_int32_t, u_int32_t return cip->u_32.field; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_ci_set##field(STRUCT_LFS *fs, CLEANERINFO *cip, type val) \ { \ if (fs->lfs_is64) { \ @@ -871,22 +915,22 @@ LFS_DEF_IF_ACCESSOR(u_int32_t, u_int32_t } \ } \ -LFS_DEF_CI_ACCESSOR(u_int32_t, u_int32_t, clean); -LFS_DEF_CI_ACCESSOR(u_int32_t, u_int32_t, dirty); +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, clean); +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, dirty); LFS_DEF_CI_ACCESSOR(int64_t, int32_t, bfree); LFS_DEF_CI_ACCESSOR(int64_t, int32_t, avail); -LFS_DEF_CI_ACCESSOR(u_int64_t, u_int32_t, free_head); -LFS_DEF_CI_ACCESSOR(u_int64_t, u_int32_t, free_tail); -LFS_DEF_CI_ACCESSOR(u_int32_t, u_int32_t, flags); +LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_head); +LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_tail); +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, flags); -static __unused inline void +static __inline void lfs_ci_shiftcleantodirty(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num) { lfs_ci_setclean(fs, cip, lfs_ci_getclean(fs, cip) - num); lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) + num); } -static __unused inline void +static __inline void lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num) { lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) - num); @@ -895,11 +939,13 @@ lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs, /* Read in the block with the cleaner info from the ifile. */ #define LFS_CLEANERINFO(CP, F, BP) do { \ + int _e; \ SHARE_IFLOCK(F); \ VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS; \ - if (bread((F)->lfs_ivnode, \ - (daddr_t)0, lfs_sb_getbsize(F), 0, &(BP))) \ - panic("lfs: ifile read"); \ + _e = bread((F)->lfs_ivnode, \ + (daddr_t)0, lfs_sb_getbsize(F), 0, &(BP)); \ + if (_e) \ + panic("lfs: ifile read: cleanerinfo: error %d\n", _e); \ (CP) = (CLEANERINFO *)(BP)->b_data; \ UNSHARE_IFLOCK(F); \ } while (0) @@ -981,7 +1027,7 @@ lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs, * XXX this can't be a macro yet; this file needs to be resorted. */ #if 0 -static __unused inline FINFO * +static __inline FINFO * segsum_finfobase(STRUCT_LFS *fs, SEGSUM *ssp) { return (FINFO *)((char *)ssp + SEGSUM_SIZE(fs)); @@ -992,7 +1038,7 @@ segsum_finfobase(STRUCT_LFS *fs, SEGSUM #endif #define LFS_DEF_SS_ACCESSOR(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_ss_get##field(STRUCT_LFS *fs, SEGSUM *ssp) \ { \ if (fs->lfs_is64) { \ @@ -1001,7 +1047,7 @@ segsum_finfobase(STRUCT_LFS *fs, SEGSUM return ssp->u_32.ss_##field; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_ss_set##field(STRUCT_LFS *fs, SEGSUM *ssp, type val) \ { \ if (fs->lfs_is64) { \ @@ -1027,7 +1073,7 @@ LFS_DEF_SS_ACCESSOR(uint64_t, uint32_t, LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, serial); LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, create); -static __unused inline size_t +static __inline size_t lfs_ss_getsumstart(STRUCT_LFS *fs) { /* These are actually all the same. */ @@ -1044,7 +1090,7 @@ lfs_ss_getsumstart(STRUCT_LFS *fs) */ } -static __unused inline uint32_t +static __inline uint32_t lfs_ss_getocreate(STRUCT_LFS *fs, SEGSUM *ssp) { KASSERT(fs->lfs_is64 == 0); @@ -1054,7 +1100,7 @@ lfs_ss_getocreate(STRUCT_LFS *fs, SEGSUM return ssp->u_v1.ss_create; } -static __unused inline void +static __inline void lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM *ssp, uint32_t val) { KASSERT(fs->lfs_is64 == 0); @@ -1074,7 +1120,7 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM */ #define LFS_DEF_SB_ACCESSOR_FULL(type, type32, field) \ - static __unused inline type \ + static __inline type \ lfs_sb_get##field(STRUCT_LFS *fs) \ { \ if (fs->lfs_is64) { \ @@ -1083,7 +1129,7 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM return fs->lfs_dlfs_u.u_32.dlfs_##field; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_sb_set##field(STRUCT_LFS *fs, type val) \ { \ if (fs->lfs_is64) { \ @@ -1092,7 +1138,7 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM fs->lfs_dlfs_u.u_32.dlfs_##field = val; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_sb_add##field(STRUCT_LFS *fs, type val) \ { \ if (fs->lfs_is64) { \ @@ -1103,7 +1149,7 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM *p32 += val; \ } \ } \ - static __unused inline void \ + static __inline void \ lfs_sb_sub##field(STRUCT_LFS *fs, type val) \ { \ if (fs->lfs_is64) { \ @@ -1118,7 +1164,7 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM #define LFS_DEF_SB_ACCESSOR(t, f) LFS_DEF_SB_ACCESSOR_FULL(t, t, f) #define LFS_DEF_SB_ACCESSOR_32ONLY(type, field, val64) \ - static __unused inline type \ + static __inline type \ lfs_sb_get##field(STRUCT_LFS *fs) \ { \ if (fs->lfs_is64) { \ @@ -1128,64 +1174,63 @@ lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM } \ } -#define lfs_magic lfs_dlfs.dlfs_magic -LFS_DEF_SB_ACCESSOR(u_int32_t, version); -LFS_DEF_SB_ACCESSOR_FULL(u_int64_t, u_int32_t, size); -LFS_DEF_SB_ACCESSOR(u_int32_t, ssize); -LFS_DEF_SB_ACCESSOR_FULL(u_int64_t, u_int32_t, dsize); -LFS_DEF_SB_ACCESSOR(u_int32_t, bsize); -LFS_DEF_SB_ACCESSOR(u_int32_t, fsize); -LFS_DEF_SB_ACCESSOR(u_int32_t, frag); +LFS_DEF_SB_ACCESSOR(uint32_t, version); +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, size); +LFS_DEF_SB_ACCESSOR(uint32_t, ssize); +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, dsize); +LFS_DEF_SB_ACCESSOR(uint32_t, bsize); +LFS_DEF_SB_ACCESSOR(uint32_t, fsize); +LFS_DEF_SB_ACCESSOR(uint32_t, frag); LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, freehd); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, bfree); LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, nfiles); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, avail); LFS_DEF_SB_ACCESSOR(int32_t, uinodes); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, idaddr); -LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, ifile, LFS_IFILE_INUM); +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, ifile, LFS_IFILE_INUM); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastseg); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, nextseg); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, curseg); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, offset); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastpseg); -LFS_DEF_SB_ACCESSOR(u_int32_t, inopf); -LFS_DEF_SB_ACCESSOR(u_int32_t, minfree); +LFS_DEF_SB_ACCESSOR(uint32_t, inopf); +LFS_DEF_SB_ACCESSOR(uint32_t, minfree); LFS_DEF_SB_ACCESSOR(uint64_t, maxfilesize); -LFS_DEF_SB_ACCESSOR(u_int32_t, fsbpseg); -LFS_DEF_SB_ACCESSOR(u_int32_t, inopb); -LFS_DEF_SB_ACCESSOR(u_int32_t, ifpb); -LFS_DEF_SB_ACCESSOR(u_int32_t, sepb); -LFS_DEF_SB_ACCESSOR(u_int32_t, nindir); -LFS_DEF_SB_ACCESSOR(u_int32_t, nseg); -LFS_DEF_SB_ACCESSOR(u_int32_t, nspf); -LFS_DEF_SB_ACCESSOR(u_int32_t, cleansz); -LFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz); -LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, segmask, 0); -LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, segshift, 0); -LFS_DEF_SB_ACCESSOR(u_int64_t, bmask); -LFS_DEF_SB_ACCESSOR(u_int32_t, bshift); -LFS_DEF_SB_ACCESSOR(u_int64_t, ffmask); -LFS_DEF_SB_ACCESSOR(u_int32_t, ffshift); -LFS_DEF_SB_ACCESSOR(u_int64_t, fbmask); -LFS_DEF_SB_ACCESSOR(u_int32_t, fbshift); -LFS_DEF_SB_ACCESSOR(u_int32_t, blktodb); -LFS_DEF_SB_ACCESSOR(u_int32_t, fsbtodb); -LFS_DEF_SB_ACCESSOR(u_int32_t, sushift); +LFS_DEF_SB_ACCESSOR(uint32_t, fsbpseg); +LFS_DEF_SB_ACCESSOR(uint32_t, inopb); +LFS_DEF_SB_ACCESSOR(uint32_t, ifpb); +LFS_DEF_SB_ACCESSOR(uint32_t, sepb); +LFS_DEF_SB_ACCESSOR(uint32_t, nindir); +LFS_DEF_SB_ACCESSOR(uint32_t, nseg); +LFS_DEF_SB_ACCESSOR(uint32_t, nspf); +LFS_DEF_SB_ACCESSOR(uint32_t, cleansz); +LFS_DEF_SB_ACCESSOR(uint32_t, segtabsz); +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segmask, 0); +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segshift, 0); +LFS_DEF_SB_ACCESSOR(uint64_t, bmask); +LFS_DEF_SB_ACCESSOR(uint32_t, bshift); +LFS_DEF_SB_ACCESSOR(uint64_t, ffmask); +LFS_DEF_SB_ACCESSOR(uint32_t, ffshift); +LFS_DEF_SB_ACCESSOR(uint64_t, fbmask); +LFS_DEF_SB_ACCESSOR(uint32_t, fbshift); +LFS_DEF_SB_ACCESSOR(uint32_t, blktodb); +LFS_DEF_SB_ACCESSOR(uint32_t, fsbtodb); +LFS_DEF_SB_ACCESSOR(uint32_t, sushift); LFS_DEF_SB_ACCESSOR(int32_t, maxsymlinklen); -LFS_DEF_SB_ACCESSOR(u_int32_t, cksum); -LFS_DEF_SB_ACCESSOR(u_int16_t, pflags); -LFS_DEF_SB_ACCESSOR(u_int32_t, nclean); +LFS_DEF_SB_ACCESSOR(uint32_t, cksum); +LFS_DEF_SB_ACCESSOR(uint16_t, pflags); +LFS_DEF_SB_ACCESSOR(uint32_t, nclean); LFS_DEF_SB_ACCESSOR(int32_t, dmeta); -LFS_DEF_SB_ACCESSOR(u_int32_t, minfreeseg); -LFS_DEF_SB_ACCESSOR(u_int32_t, sumsize); -LFS_DEF_SB_ACCESSOR(u_int64_t, serial); -LFS_DEF_SB_ACCESSOR(u_int32_t, ibsize); +LFS_DEF_SB_ACCESSOR(uint32_t, minfreeseg); +LFS_DEF_SB_ACCESSOR(uint32_t, sumsize); +LFS_DEF_SB_ACCESSOR(uint64_t, serial); +LFS_DEF_SB_ACCESSOR(uint32_t, ibsize); LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, s0addr); -LFS_DEF_SB_ACCESSOR(u_int64_t, tstamp); -LFS_DEF_SB_ACCESSOR(u_int32_t, inodefmt); -LFS_DEF_SB_ACCESSOR(u_int32_t, interleave); -LFS_DEF_SB_ACCESSOR(u_int32_t, ident); -LFS_DEF_SB_ACCESSOR(u_int32_t, resvseg); +LFS_DEF_SB_ACCESSOR(uint64_t, tstamp); +LFS_DEF_SB_ACCESSOR(uint32_t, inodefmt); +LFS_DEF_SB_ACCESSOR(uint32_t, interleave); +LFS_DEF_SB_ACCESSOR(uint32_t, ident); +LFS_DEF_SB_ACCESSOR(uint32_t, resvseg); /* special-case accessors */ @@ -1198,7 +1243,7 @@ LFS_DEF_SB_ACCESSOR(u_int32_t, resvseg); /* * lfs_sboffs is an array */ -static __unused inline int32_t +static __inline int32_t lfs_sb_getsboff(STRUCT_LFS *fs, unsigned n) { #ifdef KASSERT /* ugh */ @@ -1210,7 +1255,7 @@ lfs_sb_getsboff(STRUCT_LFS *fs, unsigned return fs->lfs_dlfs_u.u_32.dlfs_sboffs[n]; } } -static __unused inline void +static __inline void lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val) { #ifdef KASSERT /* ugh */ @@ -1226,24 +1271,24 @@ lfs_sb_setsboff(STRUCT_LFS *fs, unsigned /* * lfs_fsmnt is a string */ -static __unused inline const char * +static __inline const char * lfs_sb_getfsmnt(STRUCT_LFS *fs) { if (fs->lfs_is64) { - return fs->lfs_dlfs_u.u_64.dlfs_fsmnt; + return (const char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt; } else { - return fs->lfs_dlfs_u.u_32.dlfs_fsmnt; + return (const char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt; } } -static __unused inline void +static __inline void lfs_sb_setfsmnt(STRUCT_LFS *fs, const char *str) { if (fs->lfs_is64) { - (void)strncpy(fs->lfs_dlfs_u.u_64.dlfs_fsmnt, str, + (void)strncpy((char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt, str, sizeof(fs->lfs_dlfs_u.u_64.dlfs_fsmnt)); } else { - (void)strncpy(fs->lfs_dlfs_u.u_32.dlfs_fsmnt, str, + (void)strncpy((char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt, str, sizeof(fs->lfs_dlfs_u.u_32.dlfs_fsmnt)); } } @@ -1266,7 +1311,7 @@ lfs_sb_setfsmnt(STRUCT_LFS *fs, const ch /* XXX: lowercase these as they're no longer macros */ /* Frags to diskblocks */ -static __unused inline uint64_t +static __inline uint64_t LFS_FSBTODB(STRUCT_LFS *fs, uint64_t b) { #if defined(_KERNEL) @@ -1276,7 +1321,7 @@ LFS_FSBTODB(STRUCT_LFS *fs, uint64_t b) #endif } /* Diskblocks to frags */ -static __unused inline uint64_t +static __inline uint64_t LFS_DBTOFSB(STRUCT_LFS *fs, uint64_t b) { #if defined(_KERNEL) @@ -1290,13 +1335,13 @@ LFS_DBTOFSB(STRUCT_LFS *fs, uint64_t b) #define lfs_lblktosize(fs, blk) ((blk) << lfs_sb_getbshift(fs)) /* Frags to bytes */ -static __unused inline uint64_t +static __inline uint64_t lfs_fsbtob(STRUCT_LFS *fs, uint64_t b) { return b << lfs_sb_getffshift(fs); } /* Bytes to frags */ -static __unused inline uint64_t +static __inline uint64_t lfs_btofsb(STRUCT_LFS *fs, uint64_t b) { return b >> lfs_sb_getffshift(fs); @@ -1333,7 +1378,7 @@ lfs_btofsb(STRUCT_LFS *fs, uint64_t b) /* XXX, blah. make this appear only if struct inode is defined */ #ifdef _UFS_LFS_LFS_INODE_H_ -static __unused inline uint32_t +static __inline uint32_t lfs_blksize(STRUCT_LFS *fs, struct inode *ip, uint64_t lbn) { if (lbn >= ULFS_NDADDR || lfs_dino_getsize(fs, ip->i_din) >= (lbn + 1) << lfs_sb_getbshift(fs)) { @@ -1348,7 +1393,7 @@ lfs_blksize(STRUCT_LFS *fs, struct inode * union lfs_blocks */ -static __unused inline void +static __inline void lfs_blocks_fromvoid(STRUCT_LFS *fs, union lfs_blocks *bp, void *p) { if (fs->lfs_is64) { @@ -1358,7 +1403,7 @@ lfs_blocks_fromvoid(STRUCT_LFS *fs, unio } } -static __unused inline void +static __inline void lfs_blocks_fromfinfo(STRUCT_LFS *fs, union lfs_blocks *bp, FINFO *fip) { void *firstblock; @@ -1371,27 +1416,27 @@ lfs_blocks_fromfinfo(STRUCT_LFS *fs, uni } } -static __unused inline daddr_t -lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned index) +static __inline daddr_t +lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx) { if (fs->lfs_is64) { - return bp->b64[index]; + return bp->b64[idx]; } else { - return bp->b32[index]; + return bp->b32[idx]; } } -static __unused inline void -lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned index, daddr_t val) +static __inline void +lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx, daddr_t val) { if (fs->lfs_is64) { - bp->b64[index] = val; + bp->b64[idx] = val; } else { - bp->b32[index] = val; + bp->b32[idx] = val; } } -static __unused inline void +static __inline void lfs_blocks_inc(STRUCT_LFS *fs, union lfs_blocks *bp) { if (fs->lfs_is64) { @@ -1401,7 +1446,7 @@ lfs_blocks_inc(STRUCT_LFS *fs, union lfs } } -static __unused inline int +static __inline int lfs_blocks_eq(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2) { if (fs->lfs_is64) { @@ -1411,7 +1456,7 @@ lfs_blocks_eq(STRUCT_LFS *fs, union lfs_ } } -static __unused inline int +static __inline int lfs_blocks_sub(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2) { /* (remember that the pointers are typed) */ @@ -1461,7 +1506,7 @@ lfs_blocks_sub(STRUCT_LFS *fs, union lfs /* Amount of non-meta space not available to mortal man */ #define LFS_EST_RSVD(F) ((LFS_EST_NONMETA(F) * \ - (u_int64_t)lfs_sb_getminfree(F)) / \ + (uint64_t)lfs_sb_getminfree(F)) / \ 100) /* Can credential C write BB blocks? XXX: kauth_cred_geteuid is abusive */