aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pygrub
diff options
context:
space:
mode:
authormip@xencore04.1virtual.net <mip@xencore04.1virtual.net>2006-04-03 18:28:54 +0100
committermip@xencore04.1virtual.net <mip@xencore04.1virtual.net>2006-04-03 18:28:54 +0100
commitea0ce2d4397e1efba60b7f30d422a6649036f266 (patch)
tree4e45b9ec6f3942b14db09196cd4eae1724eab210 /tools/pygrub
parentd2a5e52e8c2b74eb2e6cc317b1add7941416c90d (diff)
downloadxen-ea0ce2d4397e1efba60b7f30d422a6649036f266.tar.gz
xen-ea0ce2d4397e1efba60b7f30d422a6649036f266.tar.bz2
xen-ea0ce2d4397e1efba60b7f30d422a6649036f266.zip
Improve pygrub error reporting when opening ext2 fs is not possible
As reported in the thread: http://lists.xensource.com/archives/html/xen-users/2006-03/msg00721.html, pygrub does not open ext2 file systems in partitioned images or sub partitions on e.g. CentOS/RHEL 4, because e2fsprogs ext2fs_open does not support an offset into the file to be opened. With this patch, the error is correctly reported instead of a generic "unable to open file" (and leaving the user searching in the dark). Signed-off-by: Michael Paesold <mpaesold@gmx.at>
Diffstat (limited to 'tools/pygrub')
-rw-r--r--tools/pygrub/src/fsys/ext2/ext2module.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/pygrub/src/fsys/ext2/ext2module.c b/tools/pygrub/src/fsys/ext2/ext2module.c
index decf1ad652..63d20f2983 100644
--- a/tools/pygrub/src/fsys/ext2/ext2module.c
+++ b/tools/pygrub/src/fsys/ext2/ext2module.c
@@ -213,7 +213,9 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args, PyObject *kwargs)
int flags = 0, superblock = 0, offset = 0, err;
unsigned int block_size = 0;
ext2_filsys efs;
+#ifdef HAVE_EXT2FS_OPEN2
char offsetopt[30];
+#endif
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iiii", kwlist,
&name, &flags, &superblock,
@@ -225,19 +227,24 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args, PyObject *kwargs)
return NULL;
}
+#ifdef HAVE_EXT2FS_OPEN2
if (offset != 0) {
snprintf(offsetopt, 29, "offset=%d", offset);
}
-#ifdef HAVE_EXT2FS_OPEN2
err = ext2fs_open2(name, offsetopt, flags, superblock, block_size,
unix_io_manager, &efs);
#else
+ if (offset != 0) {
+ PyErr_SetString(PyExc_ValueError, "offset argument not supported");
+ return NULL;
+ }
+
err = ext2fs_open(name, flags, superblock, block_size,
unix_io_manager, &efs);
#endif
if (err) {
- PyErr_SetString(PyExc_ValueError, "unable to open file");
+ PyErr_SetString(PyExc_ValueError, "unable to open filesystem");
return NULL;
}