[Libvir] [PATCH] Ancient libparted

Some of us are stuck with an ancient libparted, which doesn't know about PED_PARTITION_PROTECTED. This patch allows us to compile libvirt. === modified file 'src/parthelper.c' --- src/parthelper.c 2008-04-10 16:53:29 +0000 +++ src/parthelper.c 2008-04-29 07:47:08 +0000 @@ -67,8 +67,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; } else if (part->type == PED_PARTITION_EXTENDED) { @@ -80,8 +82,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; } -- Soren Hansen | Virtualisation specialist | Ubuntu Server Team Canonical Ltd. | http://www.ubuntu.com/

On Tue, Apr 29, 2008 at 09:54:04AM +0200, Soren Hansen wrote:
Some of us are stuck with an ancient libparted, which doesn't know about PED_PARTITION_PROTECTED. This patch allows us to compile libvirt.
=== modified file 'src/parthelper.c' --- src/parthelper.c 2008-04-10 16:53:29 +0000 +++ src/parthelper.c 2008-04-29 07:47:08 +0000 @@ -67,8 +67,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; } else if (part->type == PED_PARTITION_EXTENDED) { @@ -80,8 +82,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; }
Yup, I'll apply this. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v

"Richard W.M. Jones" <rjones@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:54:04AM +0200, Soren Hansen wrote:
Some of us are stuck with an ancient libparted, which doesn't know about PED_PARTITION_PROTECTED. This patch allows us to compile libvirt. === modified file 'src/parthelper.c' --- src/parthelper.c 2008-04-10 16:53:29 +0000 +++ src/parthelper.c 2008-04-29 07:47:08 +0000 @@ -67,8 +67,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; } else if (part->type == PED_PARTITION_EXTENDED) { @@ -80,8 +82,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; }
Yup, I'll apply this.
Hi guys, We prefer to avoid in-function #if directives, when possible, so I'll apply this on top of what's now in cvs: Avoid in-function #if directives. * src/parthelper.c [!PED_PARTITION_PROTECTED]: Define to 0. Remove in-function #ifdefs. diff --git a/src/parthelper.c b/src/parthelper.c index a0fe241..1cd7240 100644 --- a/src/parthelper.c +++ b/src/parthelper.c @@ -35,6 +35,12 @@ #include <parted/parted.h> #include <stdio.h> +/* Make the comparisons below fail if your parted headers + are so old that they lack the definition. */ +#ifndef PED_PARTITION_PROTECTED +# define PED_PARTITION_PROTECTED 0 +#endif + int main(int argc, char **argv) { PedDevice *dev; @@ -67,10 +73,8 @@ int main(int argc, char **argv) content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; -#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; -#endif else content = "data"; } else if (part->type == PED_PARTITION_EXTENDED) { @@ -82,10 +86,8 @@ int main(int argc, char **argv) content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; -#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; -#endif else content = "data"; } -- 1.5.5.1.68.gbdcd8

On Tue, Apr 29, 2008 at 02:32:08PM +0200, Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:54:04AM +0200, Soren Hansen wrote:
Some of us are stuck with an ancient libparted, which doesn't know about PED_PARTITION_PROTECTED. This patch allows us to compile libvirt. === modified file 'src/parthelper.c' --- src/parthelper.c 2008-04-10 16:53:29 +0000 +++ src/parthelper.c 2008-04-29 07:47:08 +0000 @@ -67,8 +67,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; } else if (part->type == PED_PARTITION_EXTENDED) { @@ -80,8 +82,10 @@ content = "free"; else if (part->type & PED_PARTITION_METADATA) content = "metadata"; +#ifdef PED_PARTITION_PROTECTED else if (part->type & PED_PARTITION_PROTECTED) content = "protected"; +#endif else content = "data"; }
Yup, I'll apply this.
Hi guys,
We prefer to avoid in-function #if directives, when possible, so I'll apply this on top of what's now in cvs:
Avoid in-function #if directives. * src/parthelper.c [!PED_PARTITION_PROTECTED]: Define to 0. Remove in-function #ifdefs.
Seems reasonable to me Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (4)
-
Daniel P. Berrange
-
Jim Meyering
-
Richard W.M. Jones
-
Soren Hansen