libguestfs PHP support in 1.5.8

A build for Fedora Rawhide is here.

The following PHP program displays the name of the operating system found in any disk image you give it:

<?php

$disk = "f13.img";

$g = guestfs_create ();
if ($g == false) {
  die ("Failed to create guestfs_php handle.\n");
}

if (! guestfs_add_drive_ro ($g, $disk) ||
    ! guestfs_launch ($g)) {
  die ("Error: " . guestfs_last_error ($g) . "\n");
}

$roots = guestfs_inspect_os ($g);
$name = guestfs_inspect_get_product_name ($g, $roots[0]);
echo ("$disk: ".$name."\n");

?>

When you run it:

$ php inspect.php
f13.img: Fedora release 13 (Goddard)

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.