diff --git a/daemon/Makefile.am b/daemon/Makefile.am index b44d7712f..04370b7cd 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -130,6 +130,7 @@ guestfsd_SOURCES = \ fs-min-size.c \ fsck.c \ fstrim.c \ + gdisk.c \ glob.c \ grep.c \ grub.c \ diff --git a/daemon/gdisk.c b/daemon/gdisk.c new file mode 100644 index 000000000..0bf3b282a --- /dev/null +++ b/daemon/gdisk.c @@ -0,0 +1,48 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009-2024 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include +#include + +#include "daemon.h" +#include "actions.h" +#include "optgroups.h" + +int +optgroup_gdisk_available (void) +{ + return prog_exists ("sgdisk"); +} + +int +do_part_expand_gpt(const char *device) +{ + CLEANUP_FREE char *err = NULL; + + int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, + "sgdisk", "-e", device, NULL); + + if (r == -1) { + reply_with_error ("%s -e %s: %s", "sgdisk", device, err); + return -1; + } + + return 0; +} diff --git a/daemon/parted.c b/daemon/parted.c index d0f2ce03b..9af5556c9 100644 --- a/daemon/parted.c +++ b/daemon/parted.c @@ -456,12 +456,6 @@ do_part_set_mbr_id (const char *device, int partnum, int idbyte) return 0; } -int -optgroup_gdisk_available (void) -{ - return prog_exists ("sgdisk"); -} - int do_part_set_gpt_type (const char *device, int partnum, const char *guid) { @@ -662,19 +656,3 @@ do_part_set_disk_guid_random (const char *device) return 0; } - -int -do_part_expand_gpt(const char *device) -{ - CLEANUP_FREE char *err = NULL; - - int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, - "sgdisk", "-e", device, NULL); - - if (r == -1) { - reply_with_error ("%s -e %s: %s", "sgdisk", device, err); - return -1; - } - - return 0; -}