[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] pygrub: don't leave fds open


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 23 Jul 2012 19:55:15 +0000
  • Delivery-date: Mon, 23 Jul 2012 19:56:09 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxx>
# Date 1343045385 -3600
# Node ID 7b8b143e4a86a49ca2c82c450b84ad6d4f023c34
# Parent  8948b4b1084544490b6dff60ea6d4e1b86ce4fa4
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@xxxxxxxxxx>
Acked-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 8948b4b10845 -r 7b8b143e4a86 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Mon Jul 23 13:09:44 2012 +0100
+++ b/tools/pygrub/src/pygrub   Mon Jul 23 13:09:45 2012 +0100
@@ -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

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.