| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lfs_accessors.h,v 1.42 2016/01/10 16:14:27 christos Exp $ */ | | 1 | /* $NetBSD: lfs_accessors.h,v 1.43 2016/02/19 03:43:42 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */ | | 3 | /* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */ |
4 | /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ | | 4 | /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ |
5 | /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ | | 5 | /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ |
6 | | | 6 | |
7 | /*- | | 7 | /*- |
8 | * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. | | 8 | * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. |
9 | * All rights reserved. | | 9 | * All rights reserved. |
10 | * | | 10 | * |
11 | * This code is derived from software contributed to The NetBSD Foundation | | 11 | * This code is derived from software contributed to The NetBSD Foundation |
12 | * by Konrad E. Schroder <perseant@hhhh.org>. | | 12 | * by Konrad E. Schroder <perseant@hhhh.org>. |
13 | * | | 13 | * |
14 | * Redistribution and use in source and binary forms, with or without | | 14 | * Redistribution and use in source and binary forms, with or without |
| @@ -141,29 +141,34 @@ | | | @@ -141,29 +141,34 @@ |
141 | * | | 141 | * |
142 | * @(#)dir.h 8.5 (Berkeley) 4/27/95 | | 142 | * @(#)dir.h 8.5 (Berkeley) 4/27/95 |
143 | */ | | 143 | */ |
144 | | | 144 | |
145 | #ifndef _UFS_LFS_LFS_ACCESSORS_H_ | | 145 | #ifndef _UFS_LFS_LFS_ACCESSORS_H_ |
146 | #define _UFS_LFS_LFS_ACCESSORS_H_ | | 146 | #define _UFS_LFS_LFS_ACCESSORS_H_ |
147 | | | 147 | |
148 | #if defined(_KERNEL_OPT) | | 148 | #if defined(_KERNEL_OPT) |
149 | #include "opt_lfs.h" | | 149 | #include "opt_lfs.h" |
150 | #endif | | 150 | #endif |
151 | | | 151 | |
152 | #include <sys/bswap.h> | | 152 | #include <sys/bswap.h> |
153 | | | 153 | |
| | | 154 | #include <ufs/lfs/lfs.h> |
| | | 155 | |
154 | #if !defined(_KERNEL) && !defined(_STANDALONE) | | 156 | #if !defined(_KERNEL) && !defined(_STANDALONE) |
155 | #include <assert.h> | | 157 | #include <assert.h> |
| | | 158 | #include <string.h> |
156 | #define KASSERT assert | | 159 | #define KASSERT assert |
| | | 160 | #else |
| | | 161 | #include <sys/systm.h> |
157 | #endif | | 162 | #endif |
158 | | | 163 | |
159 | /* | | 164 | /* |
160 | * STRUCT_LFS is used by the libsa code to get accessors that work | | 165 | * STRUCT_LFS is used by the libsa code to get accessors that work |
161 | * with struct salfs instead of struct lfs, and by the cleaner to | | 166 | * with struct salfs instead of struct lfs, and by the cleaner to |
162 | * get accessors that work with struct clfs. | | 167 | * get accessors that work with struct clfs. |
163 | */ | | 168 | */ |
164 | | | 169 | |
165 | #ifndef STRUCT_LFS | | 170 | #ifndef STRUCT_LFS |
166 | #define STRUCT_LFS struct lfs | | 171 | #define STRUCT_LFS struct lfs |
167 | #endif | | 172 | #endif |
168 | | | 173 | |
169 | /* | | 174 | /* |
| @@ -482,27 +487,27 @@ LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t | | | @@ -482,27 +487,27 @@ LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t |
482 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime); | | 487 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime); |
483 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec); | | 488 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec); |
484 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime); | | 489 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime); |
485 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec); | | 490 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec); |
486 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime); | | 491 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime); |
487 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec); | | 492 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec); |
488 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags); | | 493 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags); |
489 | LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks); | | 494 | LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks); |
490 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen); | | 495 | LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen); |
491 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid); | | 496 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid); |
492 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid); | | 497 | LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid); |
493 | | | 498 | |
494 | /* XXX this should be done differently (it's a fake field) */ | | 499 | /* XXX this should be done differently (it's a fake field) */ |
495 | LFS_DEF_DINO_ACCESSOR(uint64_t, int32_t, rdev); | | 500 | LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev); |
496 | | | 501 | |
497 | static __inline daddr_t | | 502 | static __inline daddr_t |
498 | lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) | | 503 | lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) |
499 | { | | 504 | { |
500 | KASSERT(ix < ULFS_NDADDR); | | 505 | KASSERT(ix < ULFS_NDADDR); |
501 | if (fs->lfs_is64) { | | 506 | if (fs->lfs_is64) { |
502 | return LFS_SWAP_uint64_t(fs, dip->u_64.di_db[ix]); | | 507 | return LFS_SWAP_uint64_t(fs, dip->u_64.di_db[ix]); |
503 | } else { | | 508 | } else { |
504 | /* note: this must sign-extend or UNWRITTEN gets trashed */ | | 509 | /* note: this must sign-extend or UNWRITTEN gets trashed */ |
505 | return (int32_t)LFS_SWAP_uint32_t(fs, dip->u_32.di_db[ix]); | | 510 | return (int32_t)LFS_SWAP_uint32_t(fs, dip->u_32.di_db[ix]); |
506 | } | | 511 | } |
507 | } | | 512 | } |
508 | | | 513 | |
| @@ -732,50 +737,50 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo | | | @@ -732,50 +737,50 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo |
732 | } else { \ | | 737 | } else { \ |
733 | type32 *p = &fip->u_32.fi_##field; \ | | 738 | type32 *p = &fip->u_32.fi_##field; \ |
734 | (void)p; \ | | 739 | (void)p; \ |
735 | fip->u_32.fi_##field = val; \ | | 740 | fip->u_32.fi_##field = val; \ |
736 | } \ | | 741 | } \ |
737 | } \ | | 742 | } \ |
738 | | | 743 | |
739 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks); | | 744 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks); |
740 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version); | | 745 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version); |
741 | LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino); | | 746 | LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino); |
742 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength); | | 747 | LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength); |
743 | | | 748 | |
744 | static __inline daddr_t | | 749 | static __inline daddr_t |
745 | lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned index) | | 750 | lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx) |
746 | { | | 751 | { |
747 | void *firstblock; | | 752 | void *firstblock; |
748 | | | 753 | |
749 | firstblock = (char *)fip + FINFOSIZE(fs); | | 754 | firstblock = (char *)fip + FINFOSIZE(fs); |
750 | KASSERT(index < lfs_fi_getnblocks(fs, fip)); | | 755 | KASSERT(idx < lfs_fi_getnblocks(fs, fip)); |
751 | if (fs->lfs_is64) { | | 756 | if (fs->lfs_is64) { |
752 | return ((int64_t *)firstblock)[index]; | | 757 | return ((int64_t *)firstblock)[idx]; |
753 | } else { | | 758 | } else { |
754 | return ((int32_t *)firstblock)[index]; | | 759 | return ((int32_t *)firstblock)[idx]; |
755 | } | | 760 | } |
756 | } | | 761 | } |
757 | | | 762 | |
758 | static __inline void | | 763 | static __inline void |
759 | lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned index, daddr_t blk) | | 764 | lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx, daddr_t blk) |
760 | { | | 765 | { |
761 | void *firstblock; | | 766 | void *firstblock; |
762 | | | 767 | |
763 | firstblock = (char *)fip + FINFOSIZE(fs); | | 768 | firstblock = (char *)fip + FINFOSIZE(fs); |
764 | KASSERT(index < lfs_fi_getnblocks(fs, fip)); | | 769 | KASSERT(idx < lfs_fi_getnblocks(fs, fip)); |
765 | if (fs->lfs_is64) { | | 770 | if (fs->lfs_is64) { |
766 | ((int64_t *)firstblock)[index] = blk; | | 771 | ((int64_t *)firstblock)[idx] = blk; |
767 | } else { | | 772 | } else { |
768 | ((int32_t *)firstblock)[index] = blk; | | 773 | ((int32_t *)firstblock)[idx] = blk; |
769 | } | | 774 | } |
770 | } | | 775 | } |
771 | | | 776 | |
772 | /* | | 777 | /* |
773 | * inode info entries (in the segment summary) | | 778 | * inode info entries (in the segment summary) |
774 | */ | | 779 | */ |
775 | | | 780 | |
776 | #define IINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32)) | | 781 | #define IINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32)) |
777 | | | 782 | |
778 | /* iinfos scroll backward from the end of the segment summary block */ | | 783 | /* iinfos scroll backward from the end of the segment summary block */ |
779 | #define SEGSUM_IINFOSTART(fs, buf) \ | | 784 | #define SEGSUM_IINFOSTART(fs, buf) \ |
780 | ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs))) | | 785 | ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs))) |
781 | | | 786 | |
| @@ -1402,42 +1407,42 @@ static __inline void | | | @@ -1402,42 +1407,42 @@ static __inline void |
1402 | lfs_blocks_fromfinfo(STRUCT_LFS *fs, union lfs_blocks *bp, FINFO *fip) | | 1407 | lfs_blocks_fromfinfo(STRUCT_LFS *fs, union lfs_blocks *bp, FINFO *fip) |
1403 | { | | 1408 | { |
1404 | void *firstblock; | | 1409 | void *firstblock; |
1405 | | | 1410 | |
1406 | firstblock = (char *)fip + FINFOSIZE(fs); | | 1411 | firstblock = (char *)fip + FINFOSIZE(fs); |
1407 | if (fs->lfs_is64) { | | 1412 | if (fs->lfs_is64) { |
1408 | bp->b64 = (int64_t *)firstblock; | | 1413 | bp->b64 = (int64_t *)firstblock; |
1409 | } else { | | 1414 | } else { |
1410 | bp->b32 = (int32_t *)firstblock; | | 1415 | bp->b32 = (int32_t *)firstblock; |
1411 | } | | 1416 | } |
1412 | } | | 1417 | } |
1413 | | | 1418 | |
1414 | static __inline daddr_t | | 1419 | static __inline daddr_t |
1415 | lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned index) | | 1420 | lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx) |
1416 | { | | 1421 | { |
1417 | if (fs->lfs_is64) { | | 1422 | if (fs->lfs_is64) { |
1418 | return bp->b64[index]; | | 1423 | return bp->b64[idx]; |
1419 | } else { | | 1424 | } else { |
1420 | return bp->b32[index]; | | 1425 | return bp->b32[idx]; |
1421 | } | | 1426 | } |
1422 | } | | 1427 | } |
1423 | | | 1428 | |
1424 | static __inline void | | 1429 | static __inline void |
1425 | lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned index, daddr_t val) | | 1430 | lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx, daddr_t val) |
1426 | { | | 1431 | { |
1427 | if (fs->lfs_is64) { | | 1432 | if (fs->lfs_is64) { |
1428 | bp->b64[index] = val; | | 1433 | bp->b64[idx] = val; |
1429 | } else { | | 1434 | } else { |
1430 | bp->b32[index] = val; | | 1435 | bp->b32[idx] = val; |
1431 | } | | 1436 | } |
1432 | } | | 1437 | } |
1433 | | | 1438 | |
1434 | static __inline void | | 1439 | static __inline void |
1435 | lfs_blocks_inc(STRUCT_LFS *fs, union lfs_blocks *bp) | | 1440 | lfs_blocks_inc(STRUCT_LFS *fs, union lfs_blocks *bp) |
1436 | { | | 1441 | { |
1437 | if (fs->lfs_is64) { | | 1442 | if (fs->lfs_is64) { |
1438 | bp->b64++; | | 1443 | bp->b64++; |
1439 | } else { | | 1444 | } else { |
1440 | bp->b32++; | | 1445 | bp->b32++; |
1441 | } | | 1446 | } |
1442 | } | | 1447 | } |
1443 | | | 1448 | |