git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More ideas on a quick Perl one-liner syntax for TODO file.
[libguestfs.git]
/
examples
/
to-xml.c
diff --git
a/examples/to-xml.c
b/examples/to-xml.c
index
b438d34
..
d6422e0
100644
(file)
--- a/
examples/to-xml.c
+++ b/
examples/to-xml.c
@@
-13,6
+13,7
@@
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
+#include <ctype.h>
#include <guestfs.h>
#include <guestfs.h>
@@
-25,7
+26,7
@@
static void display_partition (guestfs_h *g, const char *dev);
static void display_partitions (guestfs_h *g, const char *dev);
static void display_partition (guestfs_h *g, const char *dev);
static void display_partitions (guestfs_h *g, const char *dev);
-static void display_ext23 (guestfs_h *g, const char *dev, const char *fstype);
+static void display_ext23
4
(guestfs_h *g, const char *dev, const char *fstype);
int
main (int argc, char *argv[])
int
main (int argc, char *argv[])
@@
-61,7
+62,7
@@
main (int argc, char *argv[])
int64_t size;
CALL (size = guestfs_blockdev_getsize64 (g, devices[i]), -1);
printf ("<device dev=\"%s\" size=\"%" PRIi64 "\">\n", devices[i], size);
int64_t size;
CALL (size = guestfs_blockdev_getsize64 (g, devices[i]), -1);
printf ("<device dev=\"%s\" size=\"%" PRIi64 "\">\n", devices[i], size);
- display_partition (g, devices[i]);
+ display_partition
s
(g, devices[i]);
free (devices[i]);
printf ("</device>\n");
}
free (devices[i]);
printf ("</device>\n");
}
@@
-117,14
+118,19
@@
display_partition (guestfs_h *g, const char *dev)
CALL (what = guestfs_file (g, dev), NULL);
CALL (what = guestfs_file (g, dev), NULL);
- if (strstr (what, "boot sector") != NULL)
+ if (strcmp (what, "x86 boot sector") == 0)
+ /* This is what 'file' program shows for Windows/NTFS partitions. */
+ printf ("<windows/>\n");
+ else if (strstr (what, "boot sector") != NULL)
display_partitions (g, dev);
else if (strncmp (what, "LVM2", 4) == 0)
printf ("<physvol/>\n");
else if (strstr (what, "ext2 filesystem data") != NULL)
display_partitions (g, dev);
else if (strncmp (what, "LVM2", 4) == 0)
printf ("<physvol/>\n");
else if (strstr (what, "ext2 filesystem data") != NULL)
- display_ext23 (g, dev, "ext2");
+ display_ext23
4
(g, dev, "ext2");
else if (strstr (what, "ext3 filesystem data") != NULL)
else if (strstr (what, "ext3 filesystem data") != NULL)
- display_ext23 (g, dev, "ext3");
+ display_ext234 (g, dev, "ext3");
+ else if (strstr (what, "ext4 filesystem data") != NULL)
+ display_ext234 (g, dev, "ext4");
else if (strstr (what, "Linux/i386 swap file") != NULL)
printf ("<linux-swap/>\n");
else
else if (strstr (what, "Linux/i386 swap file") != NULL)
printf ("<linux-swap/>\n");
else
@@
-137,11
+143,11
@@
display_partition (guestfs_h *g, const char *dev)
static void
display_partitions (guestfs_h *g, const char *dev)
{
static void
display_partitions (guestfs_h *g, const char *dev)
{
- /* We can't look into a boot sector which is an LV
. That's
- *
a limitation of sorts of the Linux kernel. (Actually, we
- * could do this if we add the kpartx program to libguestfs).
+ /* We can't look into a boot sector which is an LV
or partition.
+ *
That's a limitation of sorts of the Linux kernel. (Actually,
+ *
we
could do this if we add the kpartx program to libguestfs).
*/
*/
- if (strncmp (dev, "/dev/sd", 7) != 0) {
+ if (strncmp (dev, "/dev/sd", 7) != 0
|| isdigit (dev[strlen(dev)-1])
) {
printf ("<vm-image dev=\"%s\"/>\n", dev);
return;
}
printf ("<vm-image dev=\"%s\"/>\n", dev);
return;
}
@@
-156,7
+162,7
@@
display_partitions (guestfs_h *g, const char *dev)
/* Only display partition if it's in the device. */
if (strncmp (parts[i], dev, len) == 0) {
int64_t size;
/* Only display partition if it's in the device. */
if (strncmp (parts[i], dev, len) == 0) {
int64_t size;
- CALL (size = guestfs_blockdev_getsize64 (g,
dev
), -1);
+ CALL (size = guestfs_blockdev_getsize64 (g,
parts[i]
), -1);
printf ("<partition dev=\"%s\" size=\"%" PRIi64 "\">\n", parts[i], size);
display_partition (g, parts[i]);
printf ("</partition>\n");
printf ("<partition dev=\"%s\" size=\"%" PRIi64 "\">\n", parts[i], size);
display_partition (g, parts[i]);
printf ("</partition>\n");
@@
-168,9
+174,9
@@
display_partitions (guestfs_h *g, const char *dev)
printf ("</partitions>\n");
}
printf ("</partitions>\n");
}
-/* Display some details on the ext2/3 filesystem on dev. */
+/* Display some details on the ext2/3
/4
filesystem on dev. */
static void
static void
-display_ext23 (guestfs_h *g, const char *dev, const char *fstype)
+display_ext23
4
(guestfs_h *g, const char *dev, const char *fstype)
{
char **sbfields;
int i;
{
char **sbfields;
int i;