]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: handle negative errors from read
authorAjeet Yadav <ajeet.yadav.77@gmail.com>
Tue, 1 Feb 2011 21:33:32 +0000 (14:33 -0700)
committerChristoph Hellwig <hch@tuxera.com>
Tue, 1 Feb 2011 21:33:32 +0000 (14:33 -0700)
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 <ajeet.yadav.77@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
repair/sb.c

index ba58f2eebb48021755d459a496eda545c57ec411..0ee23453d471f1501d17b7f6d27779dd3759e257 100644 (file)
@@ -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;
                }