From: Ian Jackson Subject: Re: [PATCH 3/9] pygrub: don't leave fds open Date: Tue, 17 Jul 2012 17:01:12 +0100 Message-ID: <20485.35912.163131.382067@mariner.uk.xensource.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: Christoph Egger , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Roger Pau Monne writes ("[PATCH 3/9] 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. > > Cc: Ian Jackson > Cc: Christoph Egger > Signed-off-by: Roger Pau Monne Looks plausible to me. Acked-by: Ian Jackson Although: > 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) ... > fd = os.open(file, os.O_RDONLY) > buf = os.read(fd, 512) > + os.close(fd) These are two remarkably similar bits of code which might deserve a function. Ian.