Skip to content

Commit

Permalink
daemon: Move gdisk function to a new file
Browse files Browse the repository at this point in the history
After subsequent commits, this will be the only remaining use of
gdisk, so put it in its own file now.
  • Loading branch information
rwmjones committed May 10, 2024
1 parent 2811e42 commit d5c6e15
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
1 change: 1 addition & 0 deletions daemon/Makefile.am
Expand Up @@ -130,6 +130,7 @@ guestfsd_SOURCES = \
fs-min-size.c \
fsck.c \
fstrim.c \
gdisk.c \
glob.c \
grep.c \
grub.c \
Expand Down
48 changes: 48 additions & 0 deletions 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 <config.h>

#include <stdio.h>
#include <stdlib.h>

#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;
}
22 changes: 0 additions & 22 deletions daemon/parted.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

0 comments on commit d5c6e15

Please sign in to comment.