summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-07-10 17:52:09 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-07-10 17:52:09 +0100
commit745f1d9ee8480b3a38f778fcc4506ce86da473a6 (patch)
treebbc56de7c7fc5dd24cedd64c5fdbb65fc8e39b28
parent2105fabddfdcecca68e20285808b4d8bbe133227 (diff)
downloadlibguestfs-745f1d9ee8480b3a38f778fcc4506ce86da473a6.tar.gz
libguestfs-745f1d9ee8480b3a38f778fcc4506ce86da473a6.tar.xz
libguestfs-745f1d9ee8480b3a38f778fcc4506ce86da473a6.zip
Add 'version' call to get true library version number.
This patch also changes the way that the version is specified in configure.ac. It is now made out of four parts (major, minor, release and extra) and constructed for AC_INIT.
-rw-r--r--.gitignore1
-rw-r--r--configure.ac15
-rwxr-xr-xsrc/generator.ml41
-rw-r--r--src/guestfs.c13
4 files changed, 68 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 92b29b64..13f25e8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -94,6 +94,7 @@ java/com/redhat/et/libguestfs/LV.java
java/com/redhat/et/libguestfs/PV.java
java/com/redhat/et/libguestfs/Stat.java
java/com/redhat/et/libguestfs/StatVFS.java
+java/com/redhat/et/libguestfs/Version.java
java/com/redhat/et/libguestfs/VG.java
java/doc-stamp
*.la
diff --git a/configure.ac b/configure.ac
index 48b57ede..7f965b2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,13 +15,26 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-AC_INIT([libguestfs],[1.0.57])
+# major/minor/release must be numbers
+m4_define([libguestfs_major], [1])
+m4_define([libguestfs_minor], [0])
+m4_define([libguestfs_release], [57])
+# extra can be any string
+m4_define([libguestfs_extra], [])
+
+AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release[]libguestfs_extra)
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LIBTOOL
+dnl Split up the version string.
+AC_DEFINE([PACKAGE_VERSION_MAJOR],[libguestfs_major],[Major version number])
+AC_DEFINE([PACKAGE_VERSION_MINOR],[libguestfs_minor],[Minor version number])
+AC_DEFINE([PACKAGE_VERSION_RELEASE],[libguestfs_release],[Release number])
+AC_DEFINE([PACKAGE_VERSION_EXTRA],["libguestfs_extra"],[Extra version string])
+
dnl Check for basic C environment.
AC_PROG_CC_STDC
AC_PROG_INSTALL
diff --git a/src/generator.ml b/src/generator.ml
index 7c0e5662..0904afc0 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -636,6 +636,36 @@ qemu subprocess, then this will return an error.
This is an internal call used for debugging and testing.");
+ ("version", (RStruct ("version", "version"), []), -1, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["version"]], [CompareWithInt ("major", 1)])],
+ "get the library version number",
+ "\
+Return the libguestfs version number that the program is linked
+against.
+
+Note that because of dynamic linking this is not necessarily
+the version of libguestfs that you compiled against. You can
+compile the program, and then at runtime dynamically link
+against a completely different C<libguestfs.so> library.
+
+This call was added in version C<1.0.58>. In previous
+versions of libguestfs there was no way to get the version
+number. From C code you can use ELF weak linking tricks to find out if
+this symbol exists (if it doesn't, then it's an earlier version).
+
+The call returns a structure with four elements. The first
+three (C<major>, C<minor> and C<release>) are numbers and
+correspond to the usual version triplet. The fourth element
+(C<extra>) is a string and is normally empty, but may be
+used for distro-specific information.
+
+To construct the original version string:
+C<$major.$minor.$release$extra>
+
+I<Note:> Don't use this call to test for availability
+of features. Distro backports makes this unreliable.");
+
]
(* daemon_functions are any functions which cause some action
@@ -2928,6 +2958,14 @@ let structs = [
"ftyp", FChar;
"name", FString;
];
+
+ (* Version numbers. *)
+ "version", [
+ "major", FInt64;
+ "minor", FInt64;
+ "release", FInt64;
+ "extra", FString;
+ ];
] (* end of structs *)
(* Ugh, Java has to be different ..
@@ -2940,7 +2978,8 @@ let java_structs = [
"lvm_lv", "LV";
"stat", "Stat";
"statvfs", "StatVFS";
- "dirent", "Dirent"
+ "dirent", "Dirent";
+ "version", "Version";
]
(* Used for testing language bindings. *)
diff --git a/src/guestfs.c b/src/guestfs.c
index 7ab72006..f445adab 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -697,6 +697,19 @@ guestfs_get_pid (guestfs_h *g)
}
}
+struct guestfs_version *
+guestfs_version (guestfs_h *g)
+{
+ struct guestfs_version *r;
+
+ r = safe_malloc (g, sizeof *r);
+ r->major = PACKAGE_VERSION_MAJOR;
+ r->minor = PACKAGE_VERSION_MINOR;
+ r->release = PACKAGE_VERSION_RELEASE;
+ r->extra = safe_strdup (g, PACKAGE_VERSION_EXTRA);
+ return r;
+}
+
/* Add a string to the current command line. */
static void
incr_cmdline_size (guestfs_h *g)