]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/versions.c
xfsprogs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
[thirdparty/xfsprogs-dev.git] / repair / versions.c
1 /*
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <libxfs.h>
20
21 #define EXTERN
22 #include "versions.h"
23 #undef EXTERN
24 #include "err_protos.h"
25 #include "globals.h"
26
27 void
28 update_sb_version(xfs_mount_t *mp)
29 {
30 xfs_sb_t *sb;
31 __uint16_t vn;
32
33 sb = &mp->m_sb;
34
35 if (fs_attributes && !xfs_sb_version_hasattr(sb)) {
36 ASSERT(fs_attributes_allowed);
37 xfs_sb_version_addattr(sb);
38 }
39
40 if (fs_attributes2 && !xfs_sb_version_hasattr2(sb)) {
41 ASSERT(fs_attributes2_allowed);
42 xfs_sb_version_addattr2(sb);
43 }
44
45 if (fs_inode_nlink && !xfs_sb_version_hasnlink(sb)) {
46 ASSERT(fs_inode_nlink_allowed);
47 xfs_sb_version_addnlink(sb);
48 }
49
50 /*
51 * fix up the superblock version number and feature bits,
52 * turn off quota bits and flags if the filesystem doesn't
53 * have quotas.
54 */
55 if (fs_quotas) {
56 if (!xfs_sb_version_hasquota(sb)) {
57 ASSERT(fs_quotas_allowed);
58 xfs_sb_version_addquota(sb);
59 }
60
61 /*
62 * protect against stray bits in the quota flag field
63 */
64 if (sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL) {
65 /*
66 * update the incore superblock, if we're in
67 * no_modify mode, it'll never get flushed out
68 * so this is ok.
69 */
70 do_warn(_("bogus quota flags 0x%x set in superblock"),
71 sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL);
72
73 sb->sb_qflags &= XFS_MOUNT_QUOTA_ALL;
74
75 if (!no_modify)
76 do_warn(_(", bogus flags will be cleared\n"));
77 else
78 do_warn(_(", bogus flags would be cleared\n"));
79 }
80 } else {
81 sb->sb_qflags = 0;
82
83 if (xfs_sb_version_hasquota(sb)) {
84 lost_quotas = 1;
85 vn = sb->sb_versionnum;
86 vn &= ~XFS_SB_VERSION_QUOTABIT;
87
88 if (!(vn & XFS_SB_VERSION_ALLFBITS))
89 vn = xfs_sb_version_toold(vn);
90
91 ASSERT(vn != 0);
92 sb->sb_versionnum = vn;
93 }
94 }
95
96 if (!fs_aligned_inodes && xfs_sb_version_hasalign(sb))
97 sb->sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT;
98 }
99
100 /*
101 * returns 0 if things are fine, 1 if we don't understand
102 * this superblock version. Sets superblock geometry-dependent
103 * global variables.
104 */
105 int
106 parse_sb_version(xfs_sb_t *sb)
107 {
108 int issue_warning;
109
110 fs_attributes = 0;
111 fs_attributes2 = 0;
112 fs_inode_nlink = 0;
113 fs_quotas = 0;
114 fs_aligned_inodes = 0;
115 fs_sb_feature_bits = 0;
116 fs_ino_alignment = 0;
117 fs_has_extflgbit = 0;
118 have_uquotino = 0;
119 have_gquotino = 0;
120 issue_warning = 0;
121
122 /*
123 * ok, check to make sure that the sb isn't newer
124 * than we are
125 */
126 if (xfs_sb_version_hasextflgbit(sb)) {
127 fs_has_extflgbit = 1;
128 if (!fs_has_extflgbit_allowed) {
129 issue_warning = 1;
130 do_warn(
131 _("This filesystem has uninitialized extent flags.\n"));
132 }
133 }
134
135 if (xfs_sb_version_hasshared(sb)) {
136 fs_shared = 1;
137 if (!fs_shared_allowed) {
138 issue_warning = 1;
139 do_warn(_("This filesystem is marked shared.\n"));
140 }
141 }
142
143 if (issue_warning) {
144 do_warn(
145 _("This filesystem uses feature(s) not yet supported in this release.\n"
146 "Please run a more recent version of xfs_repair.\n"));
147 return(1);
148 }
149
150 if (!xfs_sb_good_version(sb)) {
151 do_warn(_("WARNING: unknown superblock version %d\n"),
152 XFS_SB_VERSION_NUM(sb));
153 do_warn(
154 _("This filesystem contains features not understood by this program.\n"));
155 return(1);
156 }
157
158 if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_4) {
159 if (!fs_sb_feature_bits_allowed) {
160 if (!no_modify) {
161 do_warn(
162 _("WARNING: you have disallowed superblock-feature-bits-allowed\n"
163 "\tbut this superblock has feature bits. The superblock\n"
164 "\twill be downgraded. This may cause loss of filesystem meta-data\n"));
165 } else {
166 do_warn(
167 _("WARNING: you have disallowed superblock-feature-bits-allowed\n"
168 "\tbut this superblock has feature bits. The superblock\n"
169 "\twould be downgraded. This might cause loss of filesystem\n"
170 "\tmeta-data.\n"));
171 }
172 } else {
173 fs_sb_feature_bits = 1;
174 }
175 }
176
177 if (xfs_sb_version_hasattr(sb)) {
178 if (!fs_attributes_allowed) {
179 if (!no_modify) {
180 do_warn(
181 _("WARNING: you have disallowed attributes but this filesystem\n"
182 "\thas attributes. The filesystem will be downgraded and\n"
183 "\tall attributes will be removed.\n"));
184 } else {
185 do_warn(
186 _("WARNING: you have disallowed attributes but this filesystem\n"
187 "\thas attributes. The filesystem would be downgraded and\n"
188 "\tall attributes would be removed.\n"));
189 }
190 } else {
191 fs_attributes = 1;
192 }
193 }
194
195 if (xfs_sb_version_hasattr2(sb)) {
196 if (!fs_attributes2_allowed) {
197 if (!no_modify) {
198 do_warn(
199 _("WARNING: you have disallowed attr2 attributes but this filesystem\n"
200 "\thas attributes. The filesystem will be downgraded and\n"
201 "\tall attr2 attributes will be removed.\n"));
202 } else {
203 do_warn(
204 _("WARNING: you have disallowed attr2 attributes but this filesystem\n"
205 "\thas attributes. The filesystem would be downgraded and\n"
206 "\tall attr2 attributes would be removed.\n"));
207 }
208 } else {
209 fs_attributes2 = 1;
210 }
211 }
212
213 if (xfs_sb_version_hasnlink(sb)) {
214 if (!fs_inode_nlink_allowed) {
215 if (!no_modify) {
216 do_warn(
217 _("WARNING: you have disallowed version 2 inodes but this filesystem\n"
218 "\thas version 2 inodes. The filesystem will be downgraded and\n"
219 "\tall version 2 inodes will be converted to version 1 inodes.\n"
220 "\tThis may cause some hard links to files to be destroyed\n"));
221 } else {
222 do_warn(
223 _("WARNING: you have disallowed version 2 inodes but this filesystem\n"
224 "\thas version 2 inodes. The filesystem would be downgraded and\n"
225 "\tall version 2 inodes would be converted to version 1 inodes.\n"
226 "\tThis might cause some hard links to files to be destroyed\n"));
227 }
228 } else {
229 fs_inode_nlink = 1;
230 }
231 }
232
233 if (xfs_sb_version_hasquota(sb)) {
234 if (!fs_quotas_allowed) {
235 if (!no_modify) {
236 do_warn(
237 _("WARNING: you have disallowed quotas but this filesystem\n"
238 "\thas quotas. The filesystem will be downgraded and\n"
239 "\tall quota information will be removed.\n"));
240 } else {
241 do_warn(
242 _("WARNING: you have disallowed quotas but this filesystem\n"
243 "\thas quotas. The filesystem would be downgraded and\n"
244 "\tall quota information would be removed.\n"));
245 }
246 } else {
247 fs_quotas = 1;
248
249 if (sb->sb_uquotino != 0 &&
250 sb->sb_uquotino != NULLFSINO)
251 have_uquotino = 1;
252
253 if (sb->sb_gquotino != 0 &&
254 sb->sb_gquotino != NULLFSINO)
255 have_gquotino = 1;
256 }
257 }
258
259 if (xfs_sb_version_hasalign(sb)) {
260 if (fs_aligned_inodes_allowed) {
261 fs_aligned_inodes = 1;
262 fs_ino_alignment = sb->sb_inoalignmt;
263 } else {
264 if (!no_modify) {
265 do_warn(
266 _("WARNING: you have disallowed aligned inodes but this filesystem\n"
267 "\thas aligned inodes. The filesystem will be downgraded.\n"
268 "\tThis will permanently degrade the performance of this filesystem.\n"));
269 } else {
270 do_warn(
271 _("WARNING: you have disallowed aligned inodes but this filesystem\n"
272 "\thas aligned inodes. The filesystem would be downgraded.\n"
273 "\tThis would permanently degrade the performance of this filesystem.\n"));
274 }
275 }
276 }
277
278 /*
279 * calculate maximum file offset for this geometry
280 */
281 fs_max_file_offset = 0x7fffffffffffffffLL >> sb->sb_blocklog;
282
283 return(0);
284 }