misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 1/9] Partially fix --disable-erlang
From: Michael Scherer <misc at zarb.org> Without this, configure will always enable erlang, no matter what argument are passed. Now, we can disable it, even if configure still need the erlang compiler for some obscure reason. --- configure.ac | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 337a3ed..e0bed2f 100644 --- a/configure.ac +++ b/configure.ac @@ -892,12 +892,14 @@ AS_IF([test "x$enable_php" != "xno"], AM_CONDITIONAL([HAVE_PHP], [test "x$PHP" != "xno" && test "x$PHPIZE" != "xno"]) dnl Erlang +ERLANG=no AC_ARG_ENABLE([erlang], - AS_HELP_STRING([--disable-erlang], [Disable Erlang language bindings]), - [], - [enable_erlang=yes]) + AS_HELP_STRING([--disable-erlang], [Disable Erlang language bindings]), + [], + [enable_erlang=yes]) AS_IF([test "x$enable_erlang" != "xno"], [ + ERLANG AC_ERLANG_PATH_ERLC([no]) if test "x$ERLC" != "xno"; then @@ -906,7 +908,7 @@ AS_IF([test "x$enable_erlang" != "xno"], AC_ERLANG_SUBST_LIB_DIR fi ]) -AM_CONDITIONAL([HAVE_ERLANG], [test "x$ERLC" != "xno"]) +AM_CONDITIONAL([HAVE_ERLANG], [test "x$ERLANG" != "xno" && test "x$ERLC" != "xno"]) dnl Check for Perl modules needed by Perl virt tools (virt-df, etc.) AS_IF([test "x$PERL" != "xno"], -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 2/9] Detect Mageia distribution
From: Michael Scherer <misc at zarb.org> --- src/guestfs-internal.h | 1 + src/inspect.c | 1 + src/inspect_fs.c | 2 ++ src/inspect_fs_unix.c | 5 +++++ src/inspect_icon.c | 12 ++++++++++++ 5 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 64cf696..58d06e5 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -274,6 +274,7 @@ enum inspect_os_distro { OS_DISTRO_CENTOS, OS_DISTRO_SCIENTIFIC_LINUX, OS_DISTRO_TTYLINUX, + OS_DISTRO_MAGEIA, }; enum inspect_os_package_format { diff --git a/src/inspect.c b/src/inspect.c index f3e2186..be06fde 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -197,6 +197,7 @@ guestfs__inspect_get_distro (guestfs_h *g, const char *root) case OS_DISTRO_FEDORA: ret = safe_strdup (g, "fedora"); break; case OS_DISTRO_GENTOO: ret = safe_strdup (g, "gentoo"); break; case OS_DISTRO_LINUX_MINT: ret = safe_strdup (g, "linuxmint"); break; + case OS_DISTRO_MAGEIA: ret = safe_strdup (g, "mageia"); break; case OS_DISTRO_MANDRIVA: ret = safe_strdup (g, "mandriva"); break; case OS_DISTRO_MEEGO: ret = safe_strdup (g, "meego"); break; case OS_DISTRO_PARDUS: ret = safe_strdup (g, "pardus"); break; diff --git a/src/inspect_fs.c b/src/inspect_fs.c index e317e46..81b3008 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -361,6 +361,7 @@ check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_MEEGO: case OS_DISTRO_REDHAT_BASED: case OS_DISTRO_RHEL: + case OS_DISTRO_MAGEIA: case OS_DISTRO_MANDRIVA: case OS_DISTRO_CENTOS: case OS_DISTRO_SCIENTIFIC_LINUX: @@ -427,6 +428,7 @@ check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_PARDUS: fs->package_management = OS_PACKAGE_MANAGEMENT_PISI; break; + case OS_DISTRO_MAGEIA: case OS_DISTRO_MANDRIVA: fs->package_management = OS_PACKAGE_MANAGEMENT_URPMI; break; diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index 00d3cd7..689fdb5 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -214,6 +214,11 @@ parse_lsb_release (guestfs_h *g, struct inspect_fs *fs) fs->distro = OS_DISTRO_MANDRIVA; r = 1; } + else if (fs->distro == 0 && + STREQ (lines[i], "DISTRIB_ID=\"Mageia\"")) { + fs->distro = OS_DISTRO_MAGEIA; + r = 1; + } else if (STRPREFIX (lines[i], "DISTRIB_RELEASE=")) { char *major, *minor; if (match2 (g, &lines[i][16], re_major_minor, &major, &minor)) { diff --git a/src/inspect_icon.c b/src/inspect_icon.c index d9e2ee9..f418e4a 100644 --- a/src/inspect_icon.c +++ b/src/inspect_icon.c @@ -53,6 +53,7 @@ static char *icon_favicon (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_fedora (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_rhel (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); +static char *icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); /* Dummy static object. */ @@ -126,6 +127,10 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, r = icon_debian (g, fs, &size); break; + case OS_DISTRO_MAGEIA: + r = icon_mageia (g, fs, &size); + break; + /* These are just to keep gcc warnings happy. */ case OS_DISTRO_ARCHLINUX: case OS_DISTRO_GENTOO: @@ -286,6 +291,13 @@ icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) return get_png (g, fs, DEBIAN_ICON, size_r, 2048); } +#define MAGEIA_ICON "/usr/share/icons/mageia.png" + +static char * +icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) +{ + return get_png (g, fs, MAGEIA_ICON, size_r, 2048); +} /* Windows, as usual, has to be much more complicated and stupid than * anything else. * -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 3/9] Add support for Ubuntu logo
From: Michael Scherer <misc at zarb.org> Ths logo is present on Lucid Lynx, but may not always be installed, like in case of a minimal installation ( or server ). While Edubuntu and Kubuntu have different logo, I didn't check where it would be placed. --- src/inspect_icon.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/inspect_icon.c b/src/inspect_icon.c index f418e4a..d04e2d4 100644 --- a/src/inspect_icon.c +++ b/src/inspect_icon.c @@ -53,6 +53,7 @@ static char *icon_favicon (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_fedora (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_rhel (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); +static char *icon_ubuntu (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); @@ -127,6 +128,10 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, r = icon_debian (g, fs, &size); break; + case OS_DISTRO_UBUNTU: + r = icon_ubuntu (g, fs, &size); + break; + case OS_DISTRO_MAGEIA: r = icon_mageia (g, fs, &size); break; @@ -140,7 +145,6 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, case OS_DISTRO_PARDUS: case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: - case OS_DISTRO_UBUNTU: case OS_DISTRO_WINDOWS: case OS_DISTRO_UNKNOWN: default: ; @@ -282,7 +286,6 @@ icon_rhel (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) return get_png (g, fs, SHADOWMAN_ICON, size_r, max_size); } -/* NB: I've not located an Ubuntu logo yet. */ #define DEBIAN_ICON "/usr/share/pixmaps/debian-logo.png" static char * @@ -291,6 +294,14 @@ icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) return get_png (g, fs, DEBIAN_ICON, size_r, 2048); } +#define UBUNTU_ICON "/usr/share/icons/gnome/24x24/places/ubuntu-logo.png" + +static char * +icon_ubuntu (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) +{ + return get_png (g, fs, UBUNTU_ICON, size_r, 2048); +} + #define MAGEIA_ICON "/usr/share/icons/mageia.png" static char * -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 4/9] Add Opensuse and zypper detection support
From: Michael Scherer <misc at zarb.org> This would also erronously detect SLES as Opensuse. --- src/guestfs-internal.h | 2 ++ src/inspect.c | 2 ++ src/inspect_fs.c | 5 +++++ src/inspect_fs_unix.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 58d06e5..cee3048 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -275,6 +275,7 @@ enum inspect_os_distro { OS_DISTRO_SCIENTIFIC_LINUX, OS_DISTRO_TTYLINUX, OS_DISTRO_MAGEIA, + OS_DISTRO_OPENSUSE, }; enum inspect_os_package_format { @@ -295,6 +296,7 @@ enum inspect_os_package_management { OS_PACKAGE_MANAGEMENT_PORTAGE, OS_PACKAGE_MANAGEMENT_PISI, OS_PACKAGE_MANAGEMENT_URPMI, + OS_PACKAGE_MANAGEMENT_ZYPPER, }; struct inspect_fs { diff --git a/src/inspect.c b/src/inspect.c index be06fde..62cbc85 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -200,6 +200,7 @@ guestfs__inspect_get_distro (guestfs_h *g, const char *root) case OS_DISTRO_MAGEIA: ret = safe_strdup (g, "mageia"); break; case OS_DISTRO_MANDRIVA: ret = safe_strdup (g, "mandriva"); break; case OS_DISTRO_MEEGO: ret = safe_strdup (g, "meego"); break; + case OS_DISTRO_OPENSUSE: ret = safe_strdup (g, "opensuse"); break; case OS_DISTRO_PARDUS: ret = safe_strdup (g, "pardus"); break; case OS_DISTRO_REDHAT_BASED: ret = safe_strdup (g, "redhat-based"); break; case OS_DISTRO_RHEL: ret = safe_strdup (g, "rhel"); break; @@ -480,6 +481,7 @@ guestfs__inspect_get_package_management (guestfs_h *g, const char *root) case OS_PACKAGE_MANAGEMENT_PORTAGE: ret = safe_strdup (g, "portage"); break; case OS_PACKAGE_MANAGEMENT_PISI: ret = safe_strdup (g, "pisi"); break; case OS_PACKAGE_MANAGEMENT_URPMI: ret = safe_strdup (g, "urpmi"); break; + case OS_PACKAGE_MANAGEMENT_ZYPPER: ret = safe_strdup (g, "zypper"); break; case OS_PACKAGE_MANAGEMENT_UNKNOWN: default: ret = safe_strdup (g, "unknown"); diff --git a/src/inspect_fs.c b/src/inspect_fs.c index 81b3008..2533626 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -363,6 +363,7 @@ check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_RHEL: case OS_DISTRO_MAGEIA: case OS_DISTRO_MANDRIVA: + case OS_DISTRO_OPENSUSE: case OS_DISTRO_CENTOS: case OS_DISTRO_SCIENTIFIC_LINUX: fs->package_format = OS_PACKAGE_FORMAT_RPM; @@ -433,6 +434,10 @@ check_package_management (guestfs_h *g, struct inspect_fs *fs) fs->package_management = OS_PACKAGE_MANAGEMENT_URPMI; break; + case OS_DISTRO_OPENSUSE: + fs->package_management = OS_PACKAGE_MANAGEMENT_ZYPPER; + break; + case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: case OS_DISTRO_WINDOWS: diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index 689fdb5..20c164e 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -419,6 +419,16 @@ guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs) if (guestfs___parse_major_minor (g, fs) == -1) return -1; } + else if (guestfs_exists (g, "/etc/SuSE-release") > 0) { + fs->distro = OS_DISTRO_OPENSUSE; + + if (parse_release_file (g, fs, "/etc/SuSE-release") == -1) + return -1; + + if (guestfs___parse_major_minor (g, fs) == -1) + return -1; + } + skip_release_checks:; -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 5/9] Add the Opensuse logo ( thanks to Vincent Untz )
From: Michael Scherer <misc at zarb.org> Like Ubuntu one, it may not be always present. --- src/inspect_icon.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/inspect_icon.c b/src/inspect_icon.c index d04e2d4..7d08a00 100644 --- a/src/inspect_icon.c +++ b/src/inspect_icon.c @@ -55,6 +55,7 @@ static char *icon_rhel (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_ubuntu (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); +static char *icon_opensuse (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); /* Dummy static object. */ @@ -136,6 +137,10 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, r = icon_mageia (g, fs, &size); break; + case OS_DISTRO_OPENSUSE: + r = icon_opensuse(g, fs, &size); + break; + /* These are just to keep gcc warnings happy. */ case OS_DISTRO_ARCHLINUX: case OS_DISTRO_GENTOO: @@ -309,6 +314,15 @@ icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) { return get_png (g, fs, MAGEIA_ICON, size_r, 2048); } + +#define OPENSUSE_ICON "/usr/share/icons/hicolor/24x24/apps/distributor.png" + +static char * +icon_opensuse (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) +{ + return get_png (g, fs, OPENSUSE_ICON, size_r, 2048); +} + /* Windows, as usual, has to be much more complicated and stupid than * anything else. * -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 6/9] Add basic support for netbsd detection
From: Michael Scherer <misc at zarb.org> --- src/guestfs-internal.h | 1 + src/inspect.c | 1 + src/inspect_apps.c | 1 + 3 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index cee3048..3b4d2a4 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -254,6 +254,7 @@ enum inspect_os_type { OS_TYPE_LINUX, OS_TYPE_WINDOWS, OS_TYPE_FREEBSD, + OS_TYPE_NETBSD, }; enum inspect_os_distro { diff --git a/src/inspect.c b/src/inspect.c index 62cbc85..fde434e 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -166,6 +166,7 @@ guestfs__inspect_get_type (guestfs_h *g, const char *root) case OS_TYPE_LINUX: ret = safe_strdup (g, "linux"); break; case OS_TYPE_WINDOWS: ret = safe_strdup (g, "windows"); break; case OS_TYPE_FREEBSD: ret = safe_strdup (g, "freebsd"); break; + case OS_TYPE_NETBSD: ret = safe_strdup (g, "netbsd"); break; case OS_TYPE_UNKNOWN: default: ret = safe_strdup (g, "unknown"); break; } diff --git a/src/inspect_apps.c b/src/inspect_apps.c index ba27247..44db344 100644 --- a/src/inspect_apps.c +++ b/src/inspect_apps.c @@ -103,6 +103,7 @@ guestfs__inspect_list_applications (guestfs_h *g, const char *root) break; case OS_TYPE_FREEBSD: + case OS_TYPE_NETBSD: case OS_TYPE_UNKNOWN: default: /* nothing - keep GCC happy */; -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 7/9] Add support for mounting ufs from NetBSD, and fix FreeBSD detection on Fedora 16
From: Michael Scherer <misc at zarb.org> While testing on Fedora 16, I noticed that Linux will mount the disk without trouble by using automatically ufstype=old, and yet do not let us read the directories. So we should start directly with usftype=ufs2, and if it fail, try 44bsd, as used for netbsd and openbsd ( as seen on http://wiki-static.aydogan.net/How_to_mount_FFS_partition_under_Linux ). --- src/inspect_fs.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/inspect_fs.c b/src/inspect_fs.c index 2533626..68e2ddb 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -120,9 +120,16 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, /* Try mounting the device. As above, ignore errors. */ g->error_cb = NULL; - int r = guestfs_mount_ro (g, device, "/"); - if (r == -1 && vfs_type && STREQ (vfs_type, "ufs")) /* Hack for the *BSDs. */ + int r; + if (vfs_type && STREQ (vfs_type, "ufs")) { /* Hack for the *BSDs. */ + /* FreeBSD fs is a variant of ufs called ufs2 ... */ r = guestfs_mount_vfs (g, "ro,ufstype=ufs2", "ufs", device, "/"); + if (r == -1) + /* while NetBSD and OpenBSD use another variant labeled 44bsd */ + r = guestfs_mount_vfs (g, "ro,ufstype=44bsd", "ufs", device, "/"); + } else { + r = guestfs_mount_ro (g, device, "/"); + } free (vfs_type); g->error_cb = old_error_cb; if (r == -1) -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 8/9] Add support for pkgsrc, default NetBSD package manager.
From: Michael Scherer <misc at zarb.org> For now, only detect the tool, but support from reading installed package could be added later ( may require either a package of pkgsrc, or a smaller tool to read the db ). --- src/guestfs-internal.h | 3 ++- src/inspect.c | 1 + src/inspect_apps.c | 1 + 3 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 3b4d2a4..52e3963 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -285,7 +285,8 @@ enum inspect_os_package_format { OS_PACKAGE_FORMAT_DEB, OS_PACKAGE_FORMAT_PACMAN, OS_PACKAGE_FORMAT_EBUILD, - OS_PACKAGE_FORMAT_PISI + OS_PACKAGE_FORMAT_PISI, + OS_PACKAGE_FORMAT_PKGSRC, }; enum inspect_os_package_management { diff --git a/src/inspect.c b/src/inspect.c index fde434e..7b6dc8e 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -457,6 +457,7 @@ guestfs__inspect_get_package_format (guestfs_h *g, const char *root) case OS_PACKAGE_FORMAT_PACMAN: ret = safe_strdup (g, "pacman"); break; case OS_PACKAGE_FORMAT_EBUILD: ret = safe_strdup (g, "ebuild"); break; case OS_PACKAGE_FORMAT_PISI: ret = safe_strdup (g, "pisi"); break; + case OS_PACKAGE_FORMAT_PKGSRC: ret = safe_strdup (g, "pkgsrc"); break; case OS_PACKAGE_FORMAT_UNKNOWN: default: ret = safe_strdup (g, "unknown"); diff --git a/src/inspect_apps.c b/src/inspect_apps.c index 44db344..c6ddd05 100644 --- a/src/inspect_apps.c +++ b/src/inspect_apps.c @@ -90,6 +90,7 @@ guestfs__inspect_list_applications (guestfs_h *g, const char *root) case OS_PACKAGE_FORMAT_PACMAN: case OS_PACKAGE_FORMAT_EBUILD: case OS_PACKAGE_FORMAT_PISI: + case OS_PACKAGE_FORMAT_PKGSRC: case OS_PACKAGE_FORMAT_UNKNOWN: default: /* nothing - keep GCC happy */; -- 1.7.1
misc at zarb.org
2011-Oct-13 23:05 UTC
[Libguestfs] [PATCH 9/9] Check for netbsd root filesystem
From: Michael Scherer <misc at zarb.org> --- src/guestfs-internal.h | 1 + src/inspect_fs.c | 17 +++++++++++++++++ src/inspect_fs_unix.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 52e3963..0e60175 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -239,6 +239,7 @@ enum inspect_fs_content { FS_CONTENT_LINUX_USR_LOCAL, FS_CONTENT_LINUX_VAR, FS_CONTENT_FREEBSD_ROOT, + FS_CONTENT_NETBSD_ROOT, FS_CONTENT_INSTALLER, }; diff --git a/src/inspect_fs.c b/src/inspect_fs.c index 68e2ddb..25bb492 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -190,6 +190,23 @@ check_filesystem (guestfs_h *g, const char *device, if (guestfs___check_freebsd_root (g, fs) == -1) return -1; } + else if (is_dir_etc && + is_dir_bin && + guestfs_is_file (g, "/etc/fstab") > 0 && + guestfs_is_file (g, "/etc/release") > 0) { + /* Ignore /dev/sda1 which is a shadow of the real root filesystem + * that is probably /dev/sda5 (see: + * http://www.freebsd.org/doc/handbook/disk-organization.html) + */ + if (match (g, device, re_first_partition)) + return 0; + + fs->is_root = 1; + fs->content = FS_CONTENT_NETBSD_ROOT; + fs->format = OS_FORMAT_INSTALLED; + if (guestfs___check_netbsd_root (g, fs) == -1) + return -1; + } /* Linux root? */ else if (is_dir_etc && is_dir_bin && diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index 20c164e..c4aa6ef 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -66,6 +66,7 @@ static pcre *re_aug_seq; static pcre *re_xdev; static pcre *re_first_partition; static pcre *re_freebsd; +static pcre *re_netbsd; static void compile_regexps (void) __attribute__((constructor)); static void free_regexps (void) __attribute__((destructor)); @@ -108,6 +109,7 @@ compile_regexps (void) COMPILE (re_aug_seq, "/\\d+$", 0); COMPILE (re_xdev, "^/dev/(?:h|s|v|xv)d([a-z]\\d*)$", 0); COMPILE (re_freebsd, "^/dev/ad(\\d+)s(\\d+)([a-z])$", 0); + COMPILE (re_netbsd, "^NetBSD (\\d+)\\.(\\d+)", 0); } static void @@ -127,6 +129,7 @@ free_regexps (void) pcre_free (re_aug_seq); pcre_free (re_xdev); pcre_free (re_freebsd); + pcre_free (re_netbsd); } static void check_architecture (guestfs_h *g, struct inspect_fs *fs); @@ -483,6 +486,48 @@ guestfs___check_freebsd_root (guestfs_h *g, struct inspect_fs *fs) return 0; } +/* The currently mounted device is maybe to be a *BSD root. */ +int +guestfs___check_netbsd_root (guestfs_h *g, struct inspect_fs *fs) +{ + + if (guestfs_exists (g, "/etc/release") > 0) { + char *major, *minor; + if (parse_release_file (g, fs, "/etc/release") == -1) + return -1; + + if (match2 (g, fs->product_name, re_netbsd, &major, &minor)) { + fs->type = OS_TYPE_NETBSD; + fs->major_version = guestfs___parse_unsigned_int (g, major); + free (major); + if (fs->major_version == -1) { + free (minor); + return -1; + } + fs->minor_version = guestfs___parse_unsigned_int (g, minor); + free (minor); + if (fs->minor_version == -1) + return -1; + } + } else { + return -1; + } + + /* Determine the architecture. */ + check_architecture (g, fs); + + /* We already know /etc/fstab exists because it's part of the test above. */ + if (inspect_with_augeas (g, fs, "/etc/fstab", check_fstab) == -1) + return -1; + + /* Determine hostname. */ + if (check_hostname_unix (g, fs) == -1) + return -1; + + return 0; +} + + static void check_architecture (guestfs_h *g, struct inspect_fs *fs) { -- 1.7.1
Richard W.M. Jones
2011-Oct-14 09:36 UTC
[Libguestfs] [PATCH 1/9] Partially fix --disable-erlang
Thanks for the patches. I have pushed them all, with a few small modifications: - I updated the documentation (generator/generator_actions.ml) to reflect the new distros / package formats etc. - I rearranged and squashed together the NetBSD patches. They still compile, you might want to check they still work though. If you ./configure --enable-gcc-warnings then you'll get GCC warnings: there were one or two which I fixed. - Did you want "pkgsrc" to be the package format for NetBSD? At the moment that type is just added, but not used. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Possibly Parallel Threads
- [PATCH v10 00/10] Reimplement inspection in the daemon.
- [PATCH v9 00/11] Reimplement inspection in the daemon.
- [PATCH v11 00/10] Reimplement inspection in the daemon.
- [PATCH v12 00/11] Reimplement inspection in the daemon.
- [PATCH 0/3] library: improve handling of external tools