diff options
author | Roger Pau Monne <roger.pau@citrix.com> | 2012-07-23 13:09:45 +0100 |
---|---|---|
committer | Roger Pau Monne <roger.pau@citrix.com> | 2012-07-23 13:09:45 +0100 |
commit | ed78b8ba6619d054020b2738eabe323ca4a25d68 (patch) | |
tree | 221ff5a15ebbbb5dd104950e0477cbe48abed2d9 /tools/pygrub | |
parent | f778d0fa882611997cc32d44537116f41e36cabb (diff) | |
download | xen-ed78b8ba6619d054020b2738eabe323ca4a25d68.tar.gz xen-ed78b8ba6619d054020b2738eabe323ca4a25d68.tar.bz2 xen-ed78b8ba6619d054020b2738eabe323ca4a25d68.zip |
pygrub: don't leave fds open
On NetBSD a block device can only be opened once, so make sure pygrub
closes it every time, if this is not done libfsimage is not able to
open the disk later.
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/pygrub')
-rw-r--r-- | tools/pygrub/src/pygrub | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index 6dd44ace6a..ad78c22de0 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -67,6 +67,7 @@ def get_solaris_slice(file, offset): fd = os.open(file, os.O_RDONLY) os.lseek(fd, offset + (DK_LABEL_LOC * SECTOR_SIZE), 0) buf = os.read(fd, 512) + os.close(fd) if struct.unpack("<H", buf[508:510])[0] != DKL_MAGIC: raise RuntimeError, "Invalid disklabel magic" @@ -93,6 +94,7 @@ def get_fs_offset_gpt(file): buf = os.read(fd, partsize) offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE) i -= 1 + os.close(fd) return offsets FDISK_PART_SOLARIS=0xbf @@ -116,6 +118,7 @@ def get_partition_offsets(file): fd = os.open(file, os.O_RDONLY) buf = os.read(fd, 512) + os.close(fd) for poff in (446, 462, 478, 494): # partition offsets # MBR contains a 16 byte descriptor per partition |