static void do_output_blockdevs (void) { size_t i; CLEANUP_FREE_STRING_LIST char **devices = guestfs_list_devices (g); if (devices == NULL) exit (EXIT_FAILURE); for (i = 0; devices[i] != NULL; ++i) { int64_t size = -1; CLEANUP_FREE_STRING_LIST char **parents = NULL; CLEANUP_FREE char *dev; dev = guestfs_canonical_device_name (g, devices[i]); if (!dev) exit (EXIT_FAILURE); if ((columns & COLUMN_SIZE)) { size = guestfs_blockdev_getsize64 (g, devices[i]); if (size == -1) exit (EXIT_FAILURE); } if (is_md (devices[i])) parents = parents_of_md (devices[i]); else parents = no_parents (); write_row (dev, "device", NULL, NULL, -1, size, parents, NULL); } }
static void do_output_filesystems (void) { size_t i; CLEANUP_FREE_STRING_LIST char **fses = guestfs_list_filesystems (g); if (fses == NULL) exit (EXIT_FAILURE); for (i = 0; fses[i] != NULL; i += 2) { CLEANUP_FREE char *dev = NULL, *vfs_label = NULL, *vfs_uuid = NULL; CLEANUP_FREE_STRING_LIST char **parents = NULL; int64_t size = -1; /* Skip swap and unknown, unless --extra flag was given. */ if (!(output & OUTPUT_FILESYSTEMS_EXTRA) && (STREQ (fses[i+1], "swap") || STREQ (fses[i+1], "unknown"))) continue; dev = guestfs_canonical_device_name (g, fses[i]); if (dev == NULL) exit (EXIT_FAILURE); /* Only bother to look these up if we will be displaying them, * otherwise pass them as NULL. */ if ((columns & COLUMN_VFS_LABEL)) { guestfs_push_error_handler (g, NULL, NULL); vfs_label = guestfs_vfs_label (g, fses[i]); guestfs_pop_error_handler (g); if (vfs_label == NULL) { vfs_label = strdup (""); if (!vfs_label) { perror ("strdup"); exit (EXIT_FAILURE); } } } if ((columns & COLUMN_UUID)) { guestfs_push_error_handler (g, NULL, NULL); vfs_uuid = guestfs_vfs_uuid (g, fses[i]); guestfs_pop_error_handler (g); if (vfs_uuid == NULL) { vfs_uuid = strdup (""); if (!vfs_uuid) { perror ("strdup"); exit (EXIT_FAILURE); } } } if ((columns & COLUMN_SIZE)) { size = guestfs_blockdev_getsize64 (g, fses[i]); if (size == -1) exit (EXIT_FAILURE); } if (is_md (fses[i])) parents = parents_of_md (fses[i]); else parents = no_parents (); write_row (dev, "filesystem", fses[i+1], vfs_label, -1, size, parents, vfs_uuid); } }
// //START VMD // void VMD::dump(Region * rg, UseDefMgr * mgr) { if (g_tfile == NULL) { return; } ASSERT0(is_md() && rg); fprintf(g_tfile, "(MD%dV%d", mdid(), version()); //Dump Def if (getDef() != NULL) { ASSERT0(!getDef()->is_phi()); if (getDef()->getPrev() != NULL) { fprintf(g_tfile, ",PrevDEF:MD%dV%d", getDef()->getPrev()->getResult()->mdid(), getDef()->getPrev()->getResult()->version()); } else { fprintf(g_tfile, ",-"); } if (getDef()->getNextSet() != NULL) { SEGIter * nit = NULL; bool first = true; for (INT w = getDef()->getNextSet()->get_first(&nit); w >= 0; w = getDef()->getNextSet()->get_next(w, &nit)) { if (first) { first = false; } else { fprintf(g_tfile, ","); } MDDef const* use = mgr->getMDDef(w); ASSERT(use, ("not such MDDef")); ASSERT0(use->getResult()); ASSERT(use->getPrev() == getDef(), ("insanity relation")); fprintf(g_tfile, ",NextDEF:MD%dV%d", use->getResult()->mdid(), use->getResult()->version()); } } } else { fprintf(g_tfile, ",-"); } fprintf(g_tfile, ")"); //Dump OccSet fprintf(g_tfile, "|UsedBy:"); SEGIter * vit = NULL; bool first = true; for (INT i2 = getOccSet()->get_first(&vit); i2 >= 0; i2 = getOccSet()->get_next(i2, &vit)) { if (first) { first = false; } else { fprintf(g_tfile, ","); } IR * use = rg->getIR(i2); ASSERT0(use && (use->isMemoryRef() || use->is_id())); fprintf(g_tfile, "%s(id:%d)", IRNAME(use), use->id()); } fflush(g_tfile); }