X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fext2.c;h=f181b8d7e594dad28329969696625c46e71f71d9;hb=a0bb8e69de762aa88144c7a4825e13c446c2bbcb;hp=99c12f091088fa8aa59efe85e588064b9738a950;hpb=668d27b56857230fb81c04d1663a5aca1b9e77b9;p=libguestfs.git diff --git a/daemon/ext2.c b/daemon/ext2.c index 99c12f0..f181b8d 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -1,5 +1,5 @@ /* 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 @@ -36,8 +36,6 @@ do_tune2fs_l (const char *device) 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); @@ -77,31 +75,31 @@ do_tune2fs_l (const char *device) 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, "") == 0 || - strcmp (colon, "") == 0 || - strcmp (colon, "(none)") == 0) { - if (add_string (&ret, &size, &alloc, "") == -1) { - free (out); - return NULL; - } + strcmp (colon, "") == 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; } } @@ -234,3 +232,37 @@ do_get_e2uuid (const char *device) 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; +}