]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
da23017d NS |
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 | |
2bd0ea18 | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
da23017d NS |
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. | |
dfc130f3 | 13 | * |
da23017d NS |
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 | |
2bd0ea18 NS |
17 | */ |
18 | ||
6b803e5a | 19 | #include "libxfs.h" |
2bd0ea18 NS |
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; | |
2bd0ea18 NS |
31 | |
32 | sb = &mp->m_sb; | |
33 | ||
497d0706 | 34 | if (fs_attributes && !xfs_sb_version_hasattr(sb)) |
5e656dbb | 35 | xfs_sb_version_addattr(sb); |
2bd0ea18 | 36 | |
232470f2 | 37 | if (fs_attributes2 && !xfs_sb_version_hasattr2(sb)) |
5e656dbb | 38 | xfs_sb_version_addattr2(sb); |
9b1d68ec | 39 | |
5f6f3660 DC |
40 | /* V2 inode conversion is now always going to happen */ |
41 | if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) | |
42 | sb->sb_versionnum |= XFS_SB_VERSION_NLINKBIT; | |
2bd0ea18 NS |
43 | |
44 | /* | |
45 | * fix up the superblock version number and feature bits, | |
46 | * turn off quota bits and flags if the filesystem doesn't | |
47 | * have quotas. | |
48 | */ | |
49 | if (fs_quotas) { | |
99a1e0da | 50 | if (!xfs_sb_version_hasquota(sb)) |
5e656dbb | 51 | xfs_sb_version_addquota(sb); |
2bd0ea18 NS |
52 | |
53 | /* | |
54 | * protect against stray bits in the quota flag field | |
55 | */ | |
342aef1e | 56 | if (sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL) { |
2bd0ea18 NS |
57 | /* |
58 | * update the incore superblock, if we're in | |
59 | * no_modify mode, it'll never get flushed out | |
60 | * so this is ok. | |
61 | */ | |
507f4e33 | 62 | do_warn(_("bogus quota flags 0x%x set in superblock"), |
342aef1e CS |
63 | sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL); |
64 | ||
65 | sb->sb_qflags &= XFS_MOUNT_QUOTA_ALL; | |
2bd0ea18 NS |
66 | |
67 | if (!no_modify) | |
507f4e33 | 68 | do_warn(_(", bogus flags will be cleared\n")); |
2bd0ea18 | 69 | else |
507f4e33 | 70 | do_warn(_(", bogus flags would be cleared\n")); |
2bd0ea18 NS |
71 | } |
72 | } else { | |
73 | sb->sb_qflags = 0; | |
74 | ||
5e656dbb | 75 | if (xfs_sb_version_hasquota(sb)) { |
2bd0ea18 | 76 | lost_quotas = 1; |
5f6f3660 | 77 | sb->sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT; |
2bd0ea18 NS |
78 | } |
79 | } | |
80 | ||
f8149110 | 81 | if (!fs_aligned_inodes && xfs_sb_version_hasalign(sb)) |
5e656dbb | 82 | sb->sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; |
2bd0ea18 NS |
83 | } |
84 | ||
85 | /* | |
86 | * returns 0 if things are fine, 1 if we don't understand | |
87 | * this superblock version. Sets superblock geometry-dependent | |
88 | * global variables. | |
89 | */ | |
90 | int | |
91 | parse_sb_version(xfs_sb_t *sb) | |
92 | { | |
2bd0ea18 | 93 | fs_attributes = 0; |
9b1d68ec | 94 | fs_attributes2 = 0; |
5f6f3660 | 95 | fs_inode_nlink = 1; |
2bd0ea18 NS |
96 | fs_quotas = 0; |
97 | fs_aligned_inodes = 0; | |
98 | fs_sb_feature_bits = 0; | |
99 | fs_ino_alignment = 0; | |
100 | fs_has_extflgbit = 0; | |
101 | have_uquotino = 0; | |
b36eef04 | 102 | have_gquotino = 0; |
0340d706 | 103 | have_pquotino = 0; |
2bd0ea18 | 104 | |
5f6f3660 DC |
105 | if (sb->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) { |
106 | do_warn(_("Shared Version bit set. Not supported. Ever.\n")); | |
ff105f75 DC |
107 | return 1; |
108 | } | |
109 | ||
2bd0ea18 NS |
110 | /* |
111 | * ok, check to make sure that the sb isn't newer | |
112 | * than we are | |
113 | */ | |
a425d16a | 114 | if (xfs_sb_version_hasextflgbit(sb)) |
2bd0ea18 | 115 | fs_has_extflgbit = 1; |
2bd0ea18 | 116 | |
5e656dbb | 117 | if (!xfs_sb_good_version(sb)) { |
507f4e33 NS |
118 | do_warn(_("WARNING: unknown superblock version %d\n"), |
119 | XFS_SB_VERSION_NUM(sb)); | |
2bd0ea18 | 120 | do_warn( |
507f4e33 | 121 | _("This filesystem contains features not understood by this program.\n")); |
2bd0ea18 NS |
122 | return(1); |
123 | } | |
124 | ||
644589b1 ES |
125 | if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_4) |
126 | fs_sb_feature_bits = 1; | |
2bd0ea18 | 127 | |
a98b22b6 DW |
128 | /* Look for V5 feature flags we don't know about */ |
129 | if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_5 && | |
130 | (xfs_sb_has_compat_feature(sb, XFS_SB_FEAT_COMPAT_UNKNOWN) || | |
131 | xfs_sb_has_ro_compat_feature(sb, XFS_SB_FEAT_RO_COMPAT_UNKNOWN) || | |
132 | xfs_sb_has_incompat_feature(sb, XFS_SB_FEAT_INCOMPAT_UNKNOWN))) { | |
133 | do_warn( | |
134 | _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n" | |
135 | "Using a more recent xfs_repair is recommended.\n"), | |
136 | sb->sb_features_compat & XFS_SB_FEAT_COMPAT_UNKNOWN, | |
137 | sb->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN, | |
138 | sb->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_UNKNOWN); | |
139 | return 1; | |
140 | } | |
141 | ||
497d0706 ES |
142 | if (xfs_sb_version_hasattr(sb)) |
143 | fs_attributes = 1; | |
2bd0ea18 | 144 | |
232470f2 ES |
145 | if (xfs_sb_version_hasattr2(sb)) |
146 | fs_attributes2 = 1; | |
9b1d68ec | 147 | |
5f6f3660 | 148 | if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { |
add8ff67 ES |
149 | if (!no_modify) { |
150 | do_warn( | |
151 | _("WARNING: you have a V1 inode filesystem. It will be converted to a\n" | |
5f6f3660 | 152 | "\tversion 2 inode filesystem. If you do not want this, run an older\n" |
add8ff67 ES |
153 | "\tversion of xfs_repair.\n")); |
154 | } else { | |
155 | do_warn( | |
156 | _("WARNING: you have a V1 inode filesystem. It would be converted to a\n" | |
157 | "\tversion 2 inode filesystem. If you do not want this, run an older\n" | |
158 | "\tversion of xfs_repair.\n")); | |
159 | } | |
2bd0ea18 NS |
160 | } |
161 | ||
5e656dbb | 162 | if (xfs_sb_version_hasquota(sb)) { |
99a1e0da | 163 | fs_quotas = 1; |
2bd0ea18 | 164 | |
99a1e0da ES |
165 | if (sb->sb_uquotino != 0 && sb->sb_uquotino != NULLFSINO) |
166 | have_uquotino = 1; | |
2bd0ea18 | 167 | |
99a1e0da ES |
168 | if (sb->sb_gquotino != 0 && sb->sb_gquotino != NULLFSINO) |
169 | have_gquotino = 1; | |
0340d706 | 170 | |
99a1e0da ES |
171 | if (sb->sb_pquotino != 0 && sb->sb_pquotino != NULLFSINO) |
172 | have_pquotino = 1; | |
2bd0ea18 NS |
173 | } |
174 | ||
5e656dbb | 175 | if (xfs_sb_version_hasalign(sb)) { |
dd17791c ES |
176 | fs_aligned_inodes = 1; |
177 | fs_ino_alignment = sb->sb_inoalignmt; | |
2bd0ea18 NS |
178 | } |
179 | ||
180 | /* | |
181 | * calculate maximum file offset for this geometry | |
182 | */ | |
183 | fs_max_file_offset = 0x7fffffffffffffffLL >> sb->sb_blocklog; | |
184 | ||
185 | return(0); | |
186 | } |