]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libxfs/xfs_mount.c
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 * Mount initialization code establishing various mount
37 * fields from the superblock associated with the given
41 xfs_mount_common(xfs_mount_t
*mp
, xfs_sb_t
*sbp
)
45 mp
->m_agfrotor
= mp
->m_agirotor
= 0;
46 mp
->m_blkbit_log
= sbp
->sb_blocklog
+ XFS_NBBYLOG
;
47 mp
->m_blkbb_log
= sbp
->sb_blocklog
- BBSHIFT
;
48 mp
->m_agno_log
= xfs_highbit32(sbp
->sb_agcount
- 1) + 1;
49 mp
->m_agino_log
= sbp
->sb_inopblog
+ sbp
->sb_agblklog
;
50 mp
->m_litino
= sbp
->sb_inodesize
-
51 ((uint
)sizeof(xfs_dinode_core_t
) + (uint
)sizeof(xfs_agino_t
));
52 mp
->m_blockmask
= sbp
->sb_blocksize
- 1;
53 mp
->m_blockwsize
= sbp
->sb_blocksize
>> XFS_WORDLOG
;
54 mp
->m_blockwmask
= mp
->m_blockwsize
- 1;
57 * Setup for attributes, in case they get created.
58 * This value is for inodes getting attributes for the first time,
59 * the per-inode value is for old attribute values.
61 ASSERT(sbp
->sb_inodesize
>= 256 && sbp
->sb_inodesize
<= 2048);
62 switch (sbp
->sb_inodesize
) {
64 mp
->m_attroffset
= XFS_LITINO(mp
) - XFS_BMDR_SPACE_CALC(2);
69 mp
->m_attroffset
= XFS_BMDR_SPACE_CALC(12);
74 ASSERT(mp
->m_attroffset
< XFS_LITINO(mp
));
76 for (i
= 0; i
< 2; i
++) {
77 mp
->m_alloc_mxr
[i
] = XFS_BTREE_BLOCK_MAXRECS(sbp
->sb_blocksize
,
79 mp
->m_alloc_mnr
[i
] = XFS_BTREE_BLOCK_MINRECS(sbp
->sb_blocksize
,
82 for (i
= 0; i
< 2; i
++) {
83 mp
->m_bmap_dmxr
[i
] = XFS_BTREE_BLOCK_MAXRECS(sbp
->sb_blocksize
,
85 mp
->m_bmap_dmnr
[i
] = XFS_BTREE_BLOCK_MINRECS(sbp
->sb_blocksize
,
88 for (i
= 0; i
< 2; i
++) {
89 mp
->m_inobt_mxr
[i
] = XFS_BTREE_BLOCK_MAXRECS(sbp
->sb_blocksize
,
91 mp
->m_inobt_mnr
[i
] = XFS_BTREE_BLOCK_MINRECS(sbp
->sb_blocksize
,
95 mp
->m_bsize
= XFS_FSB_TO_BB(mp
, 1);
96 mp
->m_ialloc_inos
= (int)MAX(XFS_INODES_PER_CHUNK
, sbp
->sb_inopblock
);
97 mp
->m_ialloc_blks
= mp
->m_ialloc_inos
>> sbp
->sb_inopblog
;
102 short type
; /* 0 = integer
103 * 1 = binary / string (no translation)
106 { offsetof(xfs_sb_t
, sb_magicnum
), 0 },
107 { offsetof(xfs_sb_t
, sb_blocksize
), 0 },
108 { offsetof(xfs_sb_t
, sb_dblocks
), 0 },
109 { offsetof(xfs_sb_t
, sb_rblocks
), 0 },
110 { offsetof(xfs_sb_t
, sb_rextents
), 0 },
111 { offsetof(xfs_sb_t
, sb_uuid
), 1 },
112 { offsetof(xfs_sb_t
, sb_logstart
), 0 },
113 { offsetof(xfs_sb_t
, sb_rootino
), 0 },
114 { offsetof(xfs_sb_t
, sb_rbmino
), 0 },
115 { offsetof(xfs_sb_t
, sb_rsumino
), 0 },
116 { offsetof(xfs_sb_t
, sb_rextsize
), 0 },
117 { offsetof(xfs_sb_t
, sb_agblocks
), 0 },
118 { offsetof(xfs_sb_t
, sb_agcount
), 0 },
119 { offsetof(xfs_sb_t
, sb_rbmblocks
), 0 },
120 { offsetof(xfs_sb_t
, sb_logblocks
), 0 },
121 { offsetof(xfs_sb_t
, sb_versionnum
), 0 },
122 { offsetof(xfs_sb_t
, sb_sectsize
), 0 },
123 { offsetof(xfs_sb_t
, sb_inodesize
), 0 },
124 { offsetof(xfs_sb_t
, sb_inopblock
), 0 },
125 { offsetof(xfs_sb_t
, sb_fname
[0]), 1 },
126 { offsetof(xfs_sb_t
, sb_blocklog
), 0 },
127 { offsetof(xfs_sb_t
, sb_sectlog
), 0 },
128 { offsetof(xfs_sb_t
, sb_inodelog
), 0 },
129 { offsetof(xfs_sb_t
, sb_inopblog
), 0 },
130 { offsetof(xfs_sb_t
, sb_agblklog
), 0 },
131 { offsetof(xfs_sb_t
, sb_rextslog
), 0 },
132 { offsetof(xfs_sb_t
, sb_inprogress
), 0 },
133 { offsetof(xfs_sb_t
, sb_imax_pct
), 0 },
134 { offsetof(xfs_sb_t
, sb_icount
), 0 },
135 { offsetof(xfs_sb_t
, sb_ifree
), 0 },
136 { offsetof(xfs_sb_t
, sb_fdblocks
), 0 },
137 { offsetof(xfs_sb_t
, sb_frextents
), 0 },
138 { offsetof(xfs_sb_t
, sb_uquotino
), 0 },
139 { offsetof(xfs_sb_t
, sb_pquotino
), 0 },
140 { offsetof(xfs_sb_t
, sb_qflags
), 0 },
141 { offsetof(xfs_sb_t
, sb_flags
), 0 },
142 { offsetof(xfs_sb_t
, sb_shared_vn
), 0 },
143 { offsetof(xfs_sb_t
, sb_inoalignmt
), 0 },
144 { offsetof(xfs_sb_t
, sb_unit
), 0 },
145 { offsetof(xfs_sb_t
, sb_width
), 0 },
146 { offsetof(xfs_sb_t
, sb_dirblklog
), 0 },
147 { offsetof(xfs_sb_t
, sb_dummy
), 1 },
148 { sizeof(xfs_sb_t
), 0 }
153 * data - on disk version of sb
155 * dir - conversion direction: <0 - convert sb to buf
156 * >0 - convert buf to sb
157 * arch - architecture to read/write from/to buf
158 * fields - which fields to copy (bitmask)
161 xfs_xlatesb(void *data
, xfs_sb_t
*sb
, int dir
, xfs_arch_t arch
,
173 buf_ptr
=(xfs_caddr_t
)data
;
174 mem_ptr
=(xfs_caddr_t
)sb
;
181 f
= (xfs_sb_field_t
)xfs_lowbit64((__uint64_t
)fields
);
182 first
= xfs_sb_info
[f
].offset
;
183 size
= xfs_sb_info
[f
+ 1].offset
- first
;
185 ASSERT(xfs_sb_info
[f
].type
==0 || xfs_sb_info
[f
].type
==1);
187 if (arch
== ARCH_NOCONVERT
|| size
==1 || xfs_sb_info
[f
].type
==1) {
189 bcopy(buf_ptr
+ first
, mem_ptr
+ first
, size
);
191 bcopy(mem_ptr
+ first
, buf_ptr
+ first
, size
);
196 INT_XLATE(*(__uint16_t
*)(buf_ptr
+first
),
197 *(__uint16_t
*)(mem_ptr
+first
), dir
, arch
);
200 INT_XLATE(*(__uint32_t
*)(buf_ptr
+first
),
201 *(__uint32_t
*)(mem_ptr
+first
), dir
, arch
);
204 INT_XLATE(*(__uint64_t
*)(buf_ptr
+first
),
205 *(__uint64_t
*)(mem_ptr
+first
), dir
, arch
);
211 fields
&= ~(1LL << f
);