Esempio n. 1
0
char *
guestfs__inspect_get_package_format (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    char *ret;
    switch (fs->package_format) {
    case OS_PACKAGE_FORMAT_RPM:
        ret = safe_strdup (g, "rpm");
        break;
    case OS_PACKAGE_FORMAT_DEB:
        ret = safe_strdup (g, "deb");
        break;
    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");
        break;
    }

    return ret;
}
Esempio n. 2
0
char *
guestfs__inspect_get_format (guestfs_h *g, const char *root)
{
    char *ret = NULL;
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    switch (fs->format) {
    case OS_FORMAT_INSTALLED:
        ret = safe_strdup (g, "installed");
        break;
    case OS_FORMAT_INSTALLER:
        ret = safe_strdup (g, "installer");
        break;
    case OS_FORMAT_UNKNOWN:
        ret = safe_strdup (g, "unknown");
        break;
    }

    if (ret == NULL)
        abort ();

    return ret;
}
Esempio n. 3
0
char *
guestfs__inspect_get_hostname (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    return safe_strdup (g, fs->hostname ? : "unknown");
}
Esempio n. 4
0
int
guestfs__inspect_is_multipart (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return -1;

    return fs->is_multipart_disk;
}
Esempio n. 5
0
char *
guestfs__inspect_get_product_variant (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    return safe_strdup (g, fs->product_variant ? : "unknown");
}
Esempio n. 6
0
int
guestfs__inspect_get_minor_version (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return -1;

    return fs->minor_version;
}
Esempio n. 7
0
char *
guestfs__inspect_get_windows_systemroot (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    if (!fs->windows_systemroot) {
        error (g, _("not a Windows guest, or systemroot could not be determined"));
        return NULL;
    }

    return safe_strdup (g, fs->windows_systemroot);
}
Esempio n. 8
0
char *
guestfs__inspect_get_package_management (guestfs_h *g, const char *root)
{
    char *ret = NULL;
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    if (!fs)
        return NULL;

    switch (fs->package_management) {
    case OS_PACKAGE_MANAGEMENT_YUM:
        ret = safe_strdup (g, "yum");
        break;
    case OS_PACKAGE_MANAGEMENT_UP2DATE:
        ret = safe_strdup (g, "up2date");
        break;
    case OS_PACKAGE_MANAGEMENT_APT:
        ret = safe_strdup (g, "apt");
        break;
    case OS_PACKAGE_MANAGEMENT_PACMAN:
        ret = safe_strdup (g, "pacman");
        break;
    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:
        ret = safe_strdup (g, "unknown");
        break;
    }

    if (ret == NULL)
        abort ();

    return ret;
}
Esempio n. 9
0
char *
guestfs__inspect_get_type (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    char *ret = NULL;

    if (!fs)
        return NULL;

    switch (fs->type) {
    case OS_TYPE_DOS:
        ret = safe_strdup (g, "dos");
        break;
    case OS_TYPE_FREEBSD:
        ret = safe_strdup (g, "freebsd");
        break;
    case OS_TYPE_HURD:
        ret = safe_strdup (g, "hurd");
        break;
    case OS_TYPE_LINUX:
        ret = safe_strdup (g, "linux");
        break;
    case OS_TYPE_NETBSD:
        ret = safe_strdup (g, "netbsd");
        break;
    case OS_TYPE_OPENBSD:
        ret = safe_strdup (g, "openbsd");
        break;
    case OS_TYPE_WINDOWS:
        ret = safe_strdup (g, "windows");
        break;
    case OS_TYPE_UNKNOWN:
        ret = safe_strdup (g, "unknown");
        break;
    }

    if (ret == NULL)
        abort ();

    return ret;
}
Esempio n. 10
0
/* For the unexpected legal consequences of this function, see:
 * http://lists.fedoraproject.org/pipermail/legal/2011-April/001615.html
 *
 * Returns an RBufferOut, so the length of the returned buffer is
 * returned in *size_r.
 *
 * Check optargs for the optional argument.
 */
char *
guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r,
                           const struct guestfs_inspect_get_icon_argv *optargs)
{
  struct inspect_fs *fs;
  char *r = NOT_FOUND;
  int favicon, highquality;
  size_t size;

  fs = guestfs___search_for_root (g, root);
  if (!fs)
    return NULL;

  /* Get optargs, or defaults. */
  favicon =
    optargs->bitmask & GUESTFS_INSPECT_GET_ICON_FAVICON_BITMASK ?
    optargs->favicon : 1;

  highquality =
    optargs->bitmask & GUESTFS_INSPECT_GET_ICON_HIGHQUALITY_BITMASK ?
    optargs->highquality : 0;

  /* Favicons are never high quality, so ... */
  if (highquality)
    favicon = 0;

  /* Try looking for a favicon first. */
  if (favicon) {
    r = icon_favicon (g, fs, &size);
    if (!r)
      return NULL;

    if (r != NOT_FOUND) {
      /* try_favicon succeeded in finding a favicon. */
      *size_r = size;
      return r;
    }
  }

  /* Favicon failed, so let's try a method based on the detected operating
   * system.
   */
  switch (fs->type) {
  case OS_TYPE_LINUX:
  case OS_TYPE_HURD:
    switch (fs->distro) {
    case OS_DISTRO_FEDORA:
      r = icon_fedora (g, fs, &size);
      break;

    case OS_DISTRO_RHEL:
    case OS_DISTRO_REDHAT_BASED:
    case OS_DISTRO_CENTOS:
    case OS_DISTRO_SCIENTIFIC_LINUX:
      r = icon_rhel (g, fs, &size);
      break;

    case OS_DISTRO_DEBIAN:
      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;

    case OS_DISTRO_SUSE_BASED:
    case OS_DISTRO_OPENSUSE:
    case OS_DISTRO_SLES:
      r = icon_opensuse (g, fs, &size);
      break;

    case OS_DISTRO_CIRROS:
#if CAN_DO_CIRROS
      r = icon_cirros (g, fs, &size);
#endif
      break;

      /* These are just to keep gcc warnings happy. */
    case OS_DISTRO_ARCHLINUX:
    case OS_DISTRO_BUILDROOT:
    case OS_DISTRO_FREEDOS:
    case OS_DISTRO_GENTOO:
    case OS_DISTRO_LINUX_MINT:
    case OS_DISTRO_MANDRIVA:
    case OS_DISTRO_MEEGO:
    case OS_DISTRO_PARDUS:
    case OS_DISTRO_SLACKWARE:
    case OS_DISTRO_TTYLINUX:
    case OS_DISTRO_WINDOWS:
    case OS_DISTRO_UNKNOWN:
    default: ;
    }
    break;

  case OS_TYPE_WINDOWS:
#if CAN_DO_WINDOWS
    /* We don't know how to get high quality icons from a Windows guest,
     * so disable this if high quality was specified.
     */
    if (!highquality)
      r = icon_windows (g, fs, &size);
#endif
    break;

  case OS_TYPE_FREEBSD:
  case OS_TYPE_NETBSD:
  case OS_TYPE_DOS:
  case OS_TYPE_UNKNOWN:
  default: ;
  }

  if (r == NOT_FOUND) {
    /* Not found, but not an error.  So return the special zero-length
     * buffer.  Use malloc(1) here to ensure that malloc won't return
     * NULL.
     */
    r = safe_malloc (g, 1);
    size = 0;
  }

  *size_r = size;
  return r;
}
Esempio n. 11
0
char *
guestfs__inspect_get_distro (guestfs_h *g, const char *root)
{
    struct inspect_fs *fs = guestfs___search_for_root (g, root);
    char *ret = NULL;

    if (!fs)
        return NULL;

    switch (fs->distro) {
    case OS_DISTRO_ARCHLINUX:
        ret = safe_strdup (g, "archlinux");
        break;
    case OS_DISTRO_BUILDROOT:
        ret = safe_strdup (g, "buildroot");
        break;
    case OS_DISTRO_CENTOS:
        ret = safe_strdup (g, "centos");
        break;
    case OS_DISTRO_CIRROS:
        ret = safe_strdup (g, "cirros");
        break;
    case OS_DISTRO_DEBIAN:
        ret = safe_strdup (g, "debian");
        break;
    case OS_DISTRO_FEDORA:
        ret = safe_strdup (g, "fedora");
        break;
    case OS_DISTRO_FREEDOS:
        ret = safe_strdup (g, "freedos");
        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_OPENBSD:
        ret = safe_strdup (g, "openbsd");
        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;
    case OS_DISTRO_SCIENTIFIC_LINUX:
        ret = safe_strdup (g, "scientificlinux");
        break;
    case OS_DISTRO_SLACKWARE:
        ret = safe_strdup (g, "slackware");
        break;
    case OS_DISTRO_SLES:
        ret = safe_strdup (g, "sles");
        break;
    case OS_DISTRO_SUSE_BASED:
        ret = safe_strdup (g, "suse-based");
        break;
    case OS_DISTRO_TTYLINUX:
        ret = safe_strdup (g, "ttylinux");
        break;
    case OS_DISTRO_WINDOWS:
        ret = safe_strdup (g, "windows");
        break;
    case OS_DISTRO_UBUNTU:
        ret = safe_strdup (g, "ubuntu");
        break;
    case OS_DISTRO_UNKNOWN:
        ret = safe_strdup (g, "unknown");
        break;
    }

    if (ret == NULL)
        abort ();

    return ret;
}