>From 163e030ee13644ad9efe1e078aff47b879657333 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 30 Aug 2012 17:29:36 +0100 Subject: [PATCH] daemon: Remove e2prog hack (only needed for RHEL 5). Instead this patch will be carried out of tree in the oldlinux branch. --- daemon/daemon.h | 2 - daemon/ext2.c | 112 ++++++++----------------------------------------------- daemon/labels.c | 6 +-- daemon/mkfs.c | 8 +--- 4 files changed, 18 insertions(+), 110 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index bbe77f9..d17dcbd 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -171,8 +171,6 @@ extern int filesystem_available (const char *filesystem); extern int sync_disks (void); /*-- in ext2.c --*/ -extern int e2prog (char *name); /* Massive hack for RHEL 5. */ - /* Confirmed this is true up to ext4 from the Linux sources. */ #define EXT2_LABEL_MAX 16 diff --git a/daemon/ext2.c b/daemon/ext2.c index 7876e66..943b441 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -31,32 +31,6 @@ #define MAX_ARGS 64 -/* Choose which tools like mke2fs to use. For RHEL 5 (only) there - * is a special set of tools which support ext2/3/4. eg. On RHEL 5, - * mke2fs only supports ext2/3, but mke4fs supports ext2/3/4. - * - * We specify e4fsprogs in the package list to ensure it is loaded - * if it exists. - */ -int -e2prog (char *name) -{ - char *p = strstr (name, "e2"); - if (!p) return 0; - p++; - - *p = '4'; - if (prog_exists (name)) - return 0; - - *p = '2'; - if (prog_exists (name)) - return 0; - - reply_with_error ("cannot find required program %s", name); - return -1; -} - char ** do_tune2fs_l (const char *device) { @@ -65,11 +39,7 @@ do_tune2fs_l (const char *device) char *p, *pend, *colon; DECLARE_STRINGSBUF (ret); - char prog[] = "tune2fs"; - if (e2prog (prog) == -1) - return NULL; - - r = command (&out, &err, prog, "-l", device, NULL); + r = command (&out, &err, "tune2fs", "-l", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -165,11 +135,7 @@ do_set_e2uuid (const char *device, const char *uuid) int r; char *err; - char prog[] = "tune2fs"; - if (e2prog (prog) == -1) - return -1; - - r = command (NULL, &err, prog, "-U", uuid, device, NULL); + r = command (NULL, &err, "tune2fs", "-U", uuid, device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -192,17 +158,13 @@ if_not_mounted_run_e2fsck (const char *device) { char *err; int r, mounted; - char prog[] = "e2fsck"; - - if (e2prog (prog) == -1) - return -1; mounted = is_device_mounted (device); if (mounted == -1) return -1; if (!mounted) { - r = command (NULL, &err, prog, "-fy", device, NULL); + r = command (NULL, &err, "e2fsck", "-fy", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -220,14 +182,10 @@ do_resize2fs (const char *device) char *err; int r; - char prog[] = "resize2fs"; - if (e2prog (prog) == -1) - return -1; - if (if_not_mounted_run_e2fsck (device) == -1) return -1; - r = command (NULL, &err, prog, device, NULL); + r = command (NULL, &err, "resize2fs", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -244,10 +202,6 @@ do_resize2fs_size (const char *device, int64_t size) char *err; int r; - char prog[] = "resize2fs"; - if (e2prog (prog) == -1) - return -1; - /* resize2fs itself may impose additional limits. Since we are * going to use the 'K' suffix however we can only work with whole * kilobytes. @@ -265,7 +219,7 @@ do_resize2fs_size (const char *device, int64_t size) char buf[32]; snprintf (buf, sizeof buf, "%" PRIi64 "K", size); - r = command (NULL, &err, prog, device, buf, NULL); + r = command (NULL, &err, "resize2fs", device, buf, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -282,14 +236,10 @@ do_resize2fs_M (const char *device) char *err; int r; - char prog[] = "resize2fs"; - if (e2prog (prog) == -1) - return -1; - if (if_not_mounted_run_e2fsck (device) == -1) return -1; - r = command (NULL, &err, prog, "-M", device, NULL); + r = command (NULL, &err, "resize2fs", "-M", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -310,10 +260,6 @@ do_e2fsck (const char *device, char *err; size_t i = 0; int r; - char prog[] = "e2fsck"; - - if (e2prog (prog) == -1) - return -1; /* Default if not selected. */ if (!(optargs_bitmask & GUESTFS_E2FSCK_CORRECT_BITMASK)) @@ -326,7 +272,7 @@ do_e2fsck (const char *device, return -1; } - ADD_ARG (argv, i, prog); + ADD_ARG (argv, i, "e2fsck"); ADD_ARG (argv, i, "-f"); if (correct) @@ -369,15 +315,11 @@ do_mke2journal (int blocksize, const char *device) char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); r = command (NULL, &err, - prog, "-F", "-O", "journal_dev", "-b", blocksize_s, + "mke2fs", "-F", "-O", "journal_dev", "-b", blocksize_s, device, NULL); if (r == -1) { reply_with_error ("%s", err); @@ -395,10 +337,6 @@ do_mke2journal_L (int blocksize, const char *label, const char *device) char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - if (strlen (label) > EXT2_LABEL_MAX) { reply_with_error ("%s: ext2 labels are limited to %d bytes", label, EXT2_LABEL_MAX); @@ -409,7 +347,7 @@ do_mke2journal_L (int blocksize, const char *label, const char *device) snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); r = command (NULL, &err, - prog, "-F", "-O", "journal_dev", "-b", blocksize_s, + "mke2fs", "-F", "-O", "journal_dev", "-b", blocksize_s, "-L", label, device, NULL); if (r == -1) { @@ -428,15 +366,11 @@ do_mke2journal_U (int blocksize, const char *uuid, const char *device) char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); r = command (NULL, &err, - prog, "-F", "-O", "journal_dev", "-b", blocksize_s, + "mke2fs", "-F", "-O", "journal_dev", "-b", blocksize_s, "-U", uuid, device, NULL); if (r == -1) { @@ -456,10 +390,6 @@ do_mke2fs_J (const char *fstype, int blocksize, const char *device, char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); @@ -468,7 +398,7 @@ do_mke2fs_J (const char *fstype, int blocksize, const char *device, snprintf (jdev, len+32, "device=%s", journal); r = command (NULL, &err, - prog, "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, + "mke2fs", "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { reply_with_error ("%s", err); @@ -487,10 +417,6 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device, char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - if (strlen (label) > EXT2_LABEL_MAX) { reply_with_error ("%s: ext2 labels are limited to %d bytes", label, EXT2_LABEL_MAX); @@ -505,7 +431,7 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device, snprintf (jdev, len+32, "device=LABEL=%s", label); r = command (NULL, &err, - prog, "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, + "mke2fs", "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { reply_with_error ("%s", err); @@ -524,10 +450,6 @@ do_mke2fs_JU (const char *fstype, int blocksize, const char *device, char *err; int r; - char prog[] = "mke2fs"; - if (e2prog (prog) == -1) - return -1; - char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); @@ -536,7 +458,7 @@ do_mke2fs_JU (const char *fstype, int blocksize, const char *device, snprintf (jdev, len+32, "device=UUID=%s", uuid); r = command (NULL, &err, - prog, "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, + "mke2fs", "-F", "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { reply_with_error ("%s", err); @@ -566,7 +488,6 @@ do_tune2fs (const char *device, /* only required parameter */ size_t i = 0; int r; char *err; - char prog[] = "tune2fs"; char maxmountcount_s[64]; char mountcount_s[64]; char group_s[64]; @@ -575,10 +496,7 @@ do_tune2fs (const char *device, /* only required parameter */ char reservedblockscount_s[64]; char user_s[64]; - if (e2prog (prog) == -1) - return -1; - - ADD_ARG (argv, i, prog); + ADD_ARG (argv, i, "tune2fs"); if (optargs_bitmask & GUESTFS_TUNE2FS_FORCE_BITMASK) { if (force) @@ -686,7 +604,7 @@ do_tune2fs (const char *device, /* only required parameter */ r = commandv (NULL, &err, argv); if (r == -1) { - reply_with_error ("%s: %s: %s", prog, device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } diff --git a/daemon/labels.c b/daemon/labels.c index b28d1b2..5c59a4c 100644 --- a/daemon/labels.c +++ b/daemon/labels.c @@ -33,17 +33,13 @@ e2label (const char *device, const char *label) int r; char *err; - char prog[] = "e2label"; - if (e2prog (prog) == -1) - return -1; - if (strlen (label) > EXT2_LABEL_MAX) { reply_with_error ("%s: ext2 labels are limited to %d bytes", label, EXT2_LABEL_MAX); return -1; } - r = command (NULL, &err, prog, device, label, NULL); + r = command (NULL, &err, "e2label", device, label, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); diff --git a/daemon/mkfs.c b/daemon/mkfs.c index c7ae50d..7d28061 100644 --- a/daemon/mkfs.c +++ b/daemon/mkfs.c @@ -43,7 +43,6 @@ do_mkfs (const char *fstype, const char *device, int blocksize, char sectorsize_str[32]; int r; char *err; - char mke2fs[] = "mke2fs"; int extfs = 0; if (STREQ (fstype, "ext2") || STREQ (fstype, "ext3") || @@ -54,11 +53,8 @@ do_mkfs (const char *fstype, const char *device, int blocksize, * the mkfs program "eats" some options, in particular the -F * option. */ - if (extfs) { - if (e2prog (mke2fs) == -1) - return -1; - ADD_ARG (argv, i, mke2fs); - } + if (extfs) + ADD_ARG (argv, i, "mke2fs"); else ADD_ARG (argv, i, "mkfs"); -- 1.7.10.4