From: Ajeet Yadav Date: Tue, 1 Feb 2011 21:33:32 +0000 (-0700) Subject: xfs_repair: handle negative errors from read X-Git-Tag: v3.1.5~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e4741acb76ad4c0aa3d7a3eb8ae5d14992f4e21;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: handle negative errors from read xfs_repair does not handle read() errors while searching for secondary superblocks. This problem is identified with a simple test case: (1) delete primary superblock of xfs partition with #dd if=/dev/zero of=/dev/sda1 bs=512 count=1 #sync (2) run xfs_repair, and remove the storage while it is searching for secondary superblocks xfs_repair will loop forever, printing ............ Signed-off-by: Ajeet Yadav Signed-off-by: Christoph Hellwig --- diff --git a/repair/sb.c b/repair/sb.c index ba58f2eeb..0ee23453d 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -122,7 +122,7 @@ find_secondary_sb(xfs_sb_t *rsb) done = 1; } - if (!done && (bsize = read(x.dfd, sb, BSIZE)) == 0) { + if (!done && (bsize = read(x.dfd, sb, BSIZE)) <= 0) { done = 1; }