History

qnx4: reduce the insane nesting in qnx4_checkroot()

Al Viro committed 14 years ago

Commit 4134bf81 parent 1aab3231 file · +22 −34Browse files

Unified · Split

fs/qnx4/inode.c+22−34
@@ -179,45 +179,33 @@ static const char *qnx4_checkroot(struct super_block *sb) · 178 unmodified lines
179179 struct qnx4_inode_entry *rootdir;
180180 int rd, rl;
181181 int i, j;
182− int found = 0;
183182
184− if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/') {
183+ if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/')
185184 return "no qnx4 filesystem (no root dir).";
186− } else {
187− QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id));
188− rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
189− rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
190− for (j = 0; j < rl; j++) {
191− bh = sb_bread(sb, rd + j); /* root dir, first block */
192− if (bh == NULL) {
193− return "unable to read root entry.";
194− }
195− for (i = 0; i < QNX4_INODES_PER_BLOCK; i++) {
196− rootdir = (struct qnx4_inode_entry *) (bh->b_data + i * QNX4_DIR_ENTRY_SIZE);
197− QNX4DEBUG((KERN_INFO "rootdir entry found : [%s]\n", rootdir->di_fname));
198− if (!strcmp(rootdir->di_fname,
199− QNX4_BMNAME)) {
200− found = 1;
201− qnx4_sb(sb)->BitMap = kmemdup(rootdir,
202− sizeof(struct qnx4_inode_entry),
203− GFP_KERNEL);
204− if (!qnx4_sb(sb)->BitMap) {
205− brelse (bh);
206− return "not enough memory for bitmap inode";
207− }/* keep bitmap inode known */
208− break;
209− }
210− }
185+ QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id));
186+ rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
187+ rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
188+ for (j = 0; j < rl; j++) {
189+ bh = sb_bread(sb, rd + j); /* root dir, first block */
190+ if (bh == NULL)
191+ return "unable to read root entry.";
192+ rootdir = (struct qnx4_inode_entry *) bh->b_data;
193+ for (i = 0; i < QNX4_INODES_PER_BLOCK; i++, rootdir++) {
194+ QNX4DEBUG((KERN_INFO "rootdir entry found : [%s]\n", rootdir->di_fname));
195+ if (strcmp(rootdir->di_fname, QNX4_BMNAME) != 0)
196+ continue;
197+ qnx4_sb(sb)->BitMap = kmemdup(rootdir,
198+ sizeof(struct qnx4_inode_entry),
199+ GFP_KERNEL);
211200 brelse(bh);
212− if (found != 0) {
213− break;
214− }
215− }
216− if (found == 0) {
217− return "bitmap file not found.";
201+ if (!qnx4_sb(sb)->BitMap)
202+ return "not enough memory for bitmap inode";
203+ /* keep bitmap inode known */
204+ return NULL;
218205 }
206+ brelse(bh);
219207 }
220− return NULL;
208+ return "bitmap file not found.";
221209 }
222210
223211 static int qnx4_fill_super(struct super_block *s, void *data, int silent)