From: "Michael Paesold" Subject: Re: [PATCH] Problems with pygrub: ValueError:unableto open file Date: Fri, 31 Mar 2006 17:28:54 +0200 Message-ID: <02f901c654d7$d22ec4a0$7801a8c0@zaphod> References: <011601c64eb4$39a8a030$0f01a8c0@zaphod> <442C27D1.5060800@gmx.at><442C2BEA.9080109@gmx.at> <003f01c65493$5de82b20$7801a8c0@zaphod> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_02F6_01C654E8.95713CD0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-users-bounces@lists.xensource.com Errors-To: xen-users-bounces@lists.xensource.com To: Xen Users Cc: Xen Devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_02F6_01C654E8.95713CD0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=response Content-Transfer-Encoding: 7bit Sorry for the last empty mail (hit the wrong button). Attached is a patch against xen-unstable to improve the error messages in pygrub when the e2fsprogs do not support the newer ext2fs_open2 function. This should help beginners to identify the real problem when pygrub does not work (e.g. on RHEL4). Please apply to xen-unstable. Best Regards, Michael Paesold # HG changeset patch # User mpaesold@gmx.at # Node ID 6d90c95b919b324b7d8e4c7a568040334c8862e9 # Parent f0e14b4e535c7d99c56c286384b0d512c5220884 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 ------=_NextPart_000_02F6_01C654E8.95713CD0 Content-Type: text/plain; format=flowed; name="xen-pygrub-errormsg.patch"; reply-type=response Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-pygrub-errormsg.patch" # HG changeset patch=0A= # User mip@xencore04.1virtual.net=0A= # Node ID 6d90c95b919b324b7d8e4c7a568040334c8862e9=0A= # Parent f0e14b4e535c7d99c56c286384b0d512c5220884=0A= Improve pygrub error reporting when opening ext2 fs is not possible=0A= =0A= As reported in the thread:=0A= http://lists.xensource.com/archives/html/xen-users/2006-03/msg00721.html,=0A= pygrub does not open ext2 file systems in partitioned images or sub=0A= partitions on e.g. CentOS/RHEL 4, because e2fsprogs ext2fs_open does not=0A= support an offset into the file to be opened.=0A= =0A= With this patch, the error is correctly reported instead of a generic=0A= "unable to open file" (and leaving the user searching in the dark).=0A= =0A= Signed-off-by: Michael Paesold =0A= =0A= diff -r f0e14b4e535c -r 6d90c95b919b = tools/pygrub/src/fsys/ext2/ext2module.c=0A= --- a/tools/pygrub/src/fsys/ext2/ext2module.c Thu Mar 30 14:37:22 2006 = +0100=0A= +++ b/tools/pygrub/src/fsys/ext2/ext2module.c Fri Mar 31 09:27:23 2006 = +0200=0A= @@ -213,7 +213,9 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args=0A= int flags =3D 0, superblock =3D 0, offset =3D 0, err;=0A= unsigned int block_size =3D 0;=0A= ext2_filsys efs;=0A= +#ifdef HAVE_EXT2FS_OPEN2=0A= char offsetopt[30];=0A= +#endif=0A= =0A= if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iiii", kwlist, =0A= &name, &flags, &superblock, =0A= @@ -225,19 +227,24 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args=0A= return NULL;=0A= }=0A= =0A= +#ifdef HAVE_EXT2FS_OPEN2=0A= if (offset !=3D 0) {=0A= snprintf(offsetopt, 29, "offset=3D%d", offset);=0A= }=0A= =0A= -#ifdef HAVE_EXT2FS_OPEN2=0A= err =3D ext2fs_open2(name, offsetopt, flags, superblock, = block_size, =0A= unix_io_manager, &efs);=0A= #else=0A= + if (offset !=3D 0) {=0A= + PyErr_SetString(PyExc_ValueError, "offset argument not = supported");=0A= + return NULL;=0A= + }=0A= +=0A= err =3D ext2fs_open(name, flags, superblock, block_size,=0A= unix_io_manager, &efs);=0A= #endif=0A= if (err) {=0A= - PyErr_SetString(PyExc_ValueError, "unable to open file");=0A= + PyErr_SetString(PyExc_ValueError, "unable to open filesystem");=0A= return NULL;=0A= }=0A= =0A= ------=_NextPart_000_02F6_01C654E8.95713CD0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users ------=_NextPart_000_02F6_01C654E8.95713CD0--