From: Karel Zak Date: Fri, 15 Jul 2016 08:39:20 +0000 (+0200) Subject: liblkid: fix probe_nilfs2 I/O error backup X-Git-Tag: v2.29-rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38f6945d63f3e233996af8ccec179168afb5a8e5;p=thirdparty%2Futil-linux.git liblkid: fix probe_nilfs2 I/O error backup Signed-off-by: Karel Zak --- diff --git a/libblkid/src/superblocks/nilfs.c b/libblkid/src/superblocks/nilfs.c index cd93d7bc5b..ab0f74c23f 100644 --- a/libblkid/src/superblocks/nilfs.c +++ b/libblkid/src/superblocks/nilfs.c @@ -109,18 +109,29 @@ static int probe_nilfs2(blkid_probe pr, if (!sbp) return errno ? -errno : 1; + valid[0] = nilfs_valid_sb(pr, sbp, 0); + + /* backup */ sbb = (struct nilfs_super_block *) blkid_probe_get_buffer( pr, NILFS_SBB_OFFSET(pr->size), sizeof(struct nilfs_super_block)); - if (!sbb) - return errno ? -errno : 1; + if (!sbb) { + valid[1] = 0; + + /* If the primary block is valid then continue and ignore also + * I/O errors for backup block. Note the this is probably CD + * where I/O errors and the end of the disk/session are "normal". + */ + if (!valid[0]) + return errno ? -errno : 1; + } else + valid[1] = nilfs_valid_sb(pr, sbb, 1); + /* * Compare two super blocks and set 1 in swp if the secondary * super block is valid and newer. Otherwise, set 0 in swp. */ - valid[0] = nilfs_valid_sb(pr, sbp, 0); - valid[1] = nilfs_valid_sb(pr, sbb, 1); if (!valid[0] && !valid[1]) return 1;