From 83d0abcbd63cc7ce6a73ff6cc22a8f55bf525757 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Fri, 3 Feb 2006 04:15:44 +0000 Subject: * isys/isys.py (readReiserFSLabel): Support all valid reiserfs block sizes. --- ChangeLog | 5 +++++ isys/isys.py | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e20597fda..ee8f1bcb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-02 David Cantrell + + * isys/isys.py (readReiserFSLabel): Support all valid reiserfs + block sizes. + 2006-02-02 David Cantrell * scripts/upd-instroot: Add reiserfstune. diff --git a/isys/isys.py b/isys/isys.py index d7b94d427..dad6f0583 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -693,22 +693,24 @@ def readReiserFSLabel_int(device): log.debug("error opening device %s: %s" % (device, e)) return label + # valid block sizes in reiserfs are 512 - 8192, powers of 2 + # we put 4096 first, since it's the default # reiserfs superblock occupies either the 2nd or 16th block - # blocks are apparently always 4096 bytes - for start in (4096, (4096*16)): - try: - os.lseek(fd, start, 0) - # read 120 bytes to get s_magic and s_label - buf = os.read(fd, 120) - except OSError, e: - log.debug("error reading reiserfs label on %s: %s" %(device, e)) - + for blksize in (4096, 512, 1024, 2048, 8192): + for start in (blksize, (blksize*16)): try: - os.close(fd) - except: - pass - - return label + os.lseek(fd, start, 0) + # read 120 bytes to get s_magic and s_label + buf = os.read(fd, 120) + except OSError, e: + log.debug("error reading reiserfs label on %s: %s" %(device, e)) + + try: + os.close(fd) + except: + pass + + return label # see if this block is the superblock # this reads reiserfs_super_block_v1.s_magic as defined -- cgit