From: Christoph Egger Subject: [PATCH] tools: fix sysfs error path Date: Thu, 21 Jan 2010 10:20:40 +0100 Message-ID: <201001211020.41021.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_pxBWLalVX+LeKl0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_pxBWLalVX+LeKl0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! Attached patch fixes sysfs error path. NetBSD also has a /proc/mounts file but no sysfs. On Linux you can test this with sysfs not mounted. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --Boundary-00=_pxBWLalVX+LeKl0 Content-Type: text/x-diff; charset="iso 8859-15"; name="xen_tools_util.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_tools_util.diff" diff -r 35a9ca776c34 tools/python/xen/util/pci.py --- a/tools/python/xen/util/pci.py Tue Jan 19 11:04:15 2010 +0100 +++ b/tools/python/xen/util/pci.py Thu Jan 21 10:17:00 2010 +0100 @@ -441,6 +441,8 @@ def find_sysfs_mnt(): def get_all_pci_names(): sysfs_mnt = find_sysfs_mnt() + if sysfs_mnt is None: + return None pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH).read().split() return pci_names diff -r 35a9ca776c34 tools/python/xen/util/utils.py --- a/tools/python/xen/util/utils.py Tue Jan 19 11:04:15 2010 +0100 +++ b/tools/python/xen/util/utils.py Thu Jan 21 10:17:00 2010 +0100 @@ -68,7 +68,9 @@ def find_sysfs_mount(): continue if sline[2] == 'sysfs': sysfs_mount_point= sline[1] - return sysfs_mount_point + break + mounts_file.close() + return sysfs_mount_point except IOError, (errno, strerr): raise diff -r 35a9ca776c34 tools/python/xen/util/vscsi_util.py --- a/tools/python/xen/util/vscsi_util.py Tue Jan 19 11:04:15 2010 +0100 +++ b/tools/python/xen/util/vscsi_util.py Thu Jan 21 10:17:00 2010 +0100 @@ -123,6 +123,9 @@ def _vscsi_get_scsidevices_by_sysfs(): except: return devices + if sysfs_mnt is None: + return devices + for dirpath, dirnames, files in os.walk(sysfs_mnt + SYSFS_SCSI_PATH): for hctl in dirnames: paths = os.path.join(dirpath, hctl) --Boundary-00=_pxBWLalVX+LeKl0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_pxBWLalVX+LeKl0--