From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: Re: [PATCH 3/9] pygrub: don't leave fds open Date: Wed, 11 Jul 2012 13:02:56 +0200 Message-ID: <4FFD5D60.5040706@amd.com> References: <1342002232-75531-1-git-send-email-roger.pau@citrix.com> <1342002232-75531-4-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1342002232-75531-4-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: Ian Jackson , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 07/11/12 12:23, Roger Pau Monne wrote: > 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. > > Cc: Ian Jackson > Cc: Christoph Egger > Signed-off-by: Roger Pau Monne Acked-by: Christoph Egger > --- > 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 6dd44ac..ad78c22 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(" raise RuntimeError, "Invalid disklabel magic" > > @@ -93,6 +94,7 @@ def get_fs_offset_gpt(file): > buf = os.read(fd, partsize) > offsets.append(struct.unpack(" 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 -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632