Exemplo n.º 1
0
guestfs_int_xfsinfo *
do_xfs_info (const char *pathordevice)
{
  int r;
  CLEANUP_FREE char *buf = NULL;
  CLEANUP_FREE char *out = NULL, *err = NULL;
  CLEANUP_FREE_STRING_LIST char **lines = NULL;
  int is_dev;

  is_dev = STREQLEN (pathordevice, "/dev/", 5);
  buf = is_dev ? strdup (pathordevice)
               : sysroot_path (pathordevice);
  if (buf == NULL) {
    reply_with_perror ("malloc");
    return NULL;
  }

  r = command (&out, &err, str_xfs_info, buf, NULL);
  if (r == -1) {
    reply_with_error ("%s", err);
    return NULL;
  }

  lines = split_lines (out);
  if (lines == NULL)
    return NULL;

  return parse_xfs_info (lines);
}
Exemplo n.º 2
0
guestfs_int_xfsinfo *
do_xfs_info (const char *pathordevice)
{
  int r;
  char *buf;
  char *out = NULL, *err = NULL;
  char **lines = NULL;
  guestfs_int_xfsinfo *ret = NULL;
  int is_dev;

  is_dev = STREQLEN (pathordevice, "/dev/", 5);
  buf = is_dev ? strdup (pathordevice)
               : sysroot_path (pathordevice);
  if (buf == NULL) {
    reply_with_perror ("malloc");
    return NULL;
  }

  r = command (&out, &err, "xfs_info", buf, NULL);
  free (buf);
  if (r == -1) {
    reply_with_error ("%s", err);
    goto error;
  }

  lines = split_lines (out);
  if (lines == NULL)
    goto error;

  ret = parse_xfs_info (lines);

error:
  free (err);
  free (out);
  if (lines)
    free_strings (lines);
  return ret;
}