/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
char **ret = NULL;
int size = 0, alloc = 0;
- IS_DEVICE (device, NULL);
-
r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL);
if (r == -1) {
reply_with_error ("tune2fs: %s", err);
do { colon++; } while (*colon && isspace (*colon));
if (add_string (&ret, &size, &alloc, p) == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
if (strcmp (colon, "<none>") == 0 ||
- strcmp (colon, "<not available>") == 0 ||
- strcmp (colon, "(none)") == 0) {
- if (add_string (&ret, &size, &alloc, "") == -1) {
- free (out);
- return NULL;
- }
+ strcmp (colon, "<not available>") == 0 ||
+ strcmp (colon, "(none)") == 0) {
+ if (add_string (&ret, &size, &alloc, "") == -1) {
+ free (out);
+ return NULL;
+ }
} else {
- if (add_string (&ret, &size, &alloc, colon) == -1) {
- free (out);
- return NULL;
- }
+ if (add_string (&ret, &size, &alloc, colon) == -1) {
+ free (out);
+ return NULL;
+ }
}
}
else {
if (add_string (&ret, &size, &alloc, p) == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
if (add_string (&ret, &size, &alloc, "") == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
}
free (out);
return p; /* caller frees */
}
+
+int
+do_resize2fs (const char *device)
+{
+ char *err;
+ int r;
+
+ r = command (NULL, &err, "/sbin/resize2fs", device, NULL);
+ if (r == -1) {
+ reply_with_error ("resize2fs: %s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}
+
+int
+do_e2fsck_f (const char *device)
+{
+ char *err;
+ int r;
+
+ r = command (NULL, &err, "/sbin/e2fsck", "-p", "-f", device, NULL);
+ if (r == -1) {
+ reply_with_error ("e2fsck: %s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}