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

[PATCH] Re: [Xen-users] Problems with pygrub: ValueError: unable to open file

Improve pygrub error reporting when opening ext2 fs is not possible

As reported in the thread:
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@xxxxxx>

diff -r f0e14b4e535c tools/pygrub/src/fsys/ext2/ext2module.c
--- a/tools/pygrub/src/fsys/ext2/ext2module.c   Thu Mar 30 14:37:22 2006 +0100
+++ b/tools/pygrub/src/fsys/ext2/ext2module.c   Thu Mar 30 20:52:41 2006 +0200
@@ -225,19 +225,24 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args
         return NULL;

     if (offset != 0) {
         snprintf(offsetopt, 29, "offset=%d", offset);

     err = ext2fs_open2(name, offsetopt, flags, superblock, block_size,
                        unix_io_manager, &efs);
+    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);
     if (err) {
-        PyErr_SetString(PyExc_ValueError, "unable to open file");
+        PyErr_SetString(PyExc_ValueError, "unable to open filesystem");
         return NULL;

Xen-users mailing list



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