Blame SOURCES/0008-RHEL-Remove-9p-APIs-from-RHEL-RHBZ-921710.patch

d03fcc
From 8d426264789f4b2ab5557087a39973e6fbc20983 Mon Sep 17 00:00:00 2001
d64dff
From: "Richard W.M. Jones" <rjones@redhat.com>
d64dff
Date: Thu, 18 Jul 2013 18:31:53 +0100
d64dff
Subject: [PATCH] RHEL: Remove 9p APIs from RHEL (RHBZ#921710).
d64dff
d64dff
---
d64dff
 daemon/9p.c               | 182 --------------------------------------
d64dff
 daemon/Makefile.am        |   1 -
d64dff
 docs/C_SOURCE_FILES       |   1 -
d64dff
 generator/actions_core.ml |  21 -----
d64dff
 generator/proc_nr.ml      |   2 -
d64dff
 gobject/Makefile.inc      |   2 -
d64dff
 po/POTFILES               |   2 -
d64dff
 tests/Makefile.am         |   1 -
d64dff
 8 files changed, 212 deletions(-)
d64dff
 delete mode 100644 daemon/9p.c
d64dff
d64dff
diff --git a/daemon/9p.c b/daemon/9p.c
d64dff
deleted file mode 100644
d03fcc
index 9a3a5cfdf..000000000
d64dff
--- a/daemon/9p.c
d64dff
+++ /dev/null
d64dff
@@ -1,182 +0,0 @@
d64dff
-/* libguestfs - the guestfsd daemon
d64dff
- * Copyright (C) 2011 Red Hat Inc.
d64dff
- *
d64dff
- * This program is free software; you can redistribute it and/or modify
d64dff
- * it under the terms of the GNU General Public License as published by
d64dff
- * the Free Software Foundation; either version 2 of the License, or
d64dff
- * (at your option) any later version.
d64dff
- *
d64dff
- * This program is distributed in the hope that it will be useful,
d64dff
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
d64dff
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d64dff
- * GNU General Public License for more details.
d64dff
- *
d64dff
- * You should have received a copy of the GNU General Public License
d64dff
- * along with this program; if not, write to the Free Software
d64dff
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d64dff
- */
d64dff
-
d64dff
-#include <config.h>
d64dff
-
d64dff
-#include <stdio.h>
d64dff
-#include <stdlib.h>
d64dff
-#include <string.h>
d64dff
-#include <unistd.h>
d64dff
-#include <limits.h>
d64dff
-#include <errno.h>
d64dff
-#include <sys/types.h>
d64dff
-#include <sys/stat.h>
d64dff
-#include <dirent.h>
d64dff
-#include <fcntl.h>
d64dff
-
d64dff
-#include "ignore-value.h"
d64dff
-
d64dff
-#include "daemon.h"
d64dff
-#include "actions.h"
d64dff
-
d64dff
-#define BUS_PATH "/sys/bus/virtio/drivers/9pnet_virtio"
d64dff
-
d64dff
-static void
d64dff
-modprobe_9pnet_virtio (void)
d64dff
-{
d64dff
-  /* Required with Linux 5.6 and maybe earlier kernels.  For unclear
d64dff
-   * reasons the module is not an automatic dependency of the 9p
d64dff
-   * module so doesn't get loaded automatically.
d64dff
-   */
d64dff
-  ignore_value (command (NULL, NULL, "modprobe", "9pnet_virtio", NULL));
d64dff
-}
d64dff
-
d64dff
-/* https://bugzilla.redhat.com/show_bug.cgi?id=714981#c1 */
d64dff
-char **
d64dff
-do_list_9p (void)
d64dff
-{
d64dff
-  CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r);
d64dff
-  DIR *dir;
d64dff
-
d64dff
-  modprobe_9pnet_virtio ();
d64dff
-
d64dff
-  dir = opendir (BUS_PATH);
d64dff
-  if (!dir) {
d64dff
-    perror ("opendir: " BUS_PATH);
d64dff
-    if (errno != ENOENT) {
d64dff
-      reply_with_perror ("opendir: " BUS_PATH);
d64dff
-      return NULL;
d64dff
-    }
d64dff
-
d64dff
-    /* If this directory doesn't exist, it probably means that
d64dff
-     * the virtio driver isn't loaded.  Don't return an error
d64dff
-     * in this case, but return an empty list.
d64dff
-     */
d64dff
-    if (end_stringsbuf (&r) == -1)
d64dff
-      return NULL;
d64dff
-
d64dff
-    return take_stringsbuf (&r);
d64dff
-  }
d64dff
-
d64dff
-  while (1) {
d64dff
-    struct dirent *d;
d64dff
-
d64dff
-    errno = 0;
d64dff
-    d = readdir (dir);
d64dff
-    if (d == NULL) break;
d64dff
-
d64dff
-    if (STRPREFIX (d->d_name, "virtio")) {
d64dff
-      CLEANUP_FREE char *mount_tag_path = NULL;
d64dff
-      if (asprintf (&mount_tag_path, BUS_PATH "/%s/mount_tag",
d64dff
-                    d->d_name) == -1) {
d64dff
-        reply_with_perror ("asprintf");
d64dff
-        closedir (dir);
d64dff
-        return NULL;
d64dff
-      }
d64dff
-
d64dff
-      /* A bit unclear, but it looks like the virtio transport allows
d64dff
-       * the mount tag length to be unlimited (or up to 65536 bytes).
d64dff
-       * See: linux/include/linux/virtio_9p.h
d64dff
-       */
d64dff
-      CLEANUP_FREE char *mount_tag = read_whole_file (mount_tag_path, NULL);
d64dff
-      if (mount_tag == 0)
d64dff
-        continue;
d64dff
-
d64dff
-      if (add_string (&r, mount_tag) == -1) {
d64dff
-        closedir (dir);
d64dff
-        return NULL;
d64dff
-      }
d64dff
-    }
d64dff
-  }
d64dff
-
d64dff
-  /* Check readdir didn't fail */
d64dff
-  if (errno != 0) {
d03fcc
-    reply_with_perror ("readdir: " BUS_PATH);
d64dff
-    closedir (dir);
d64dff
-    return NULL;
d64dff
-  }
d64dff
-
d64dff
-  /* Close the directory handle */
d64dff
-  if (closedir (dir) == -1) {
d03fcc
-    reply_with_perror ("closedir: " BUS_PATH);
d64dff
-    return NULL;
d64dff
-  }
d64dff
-
d64dff
-  /* Sort the tags. */
d64dff
-  if (r.size > 0)
d64dff
-    sort_strings (r.argv, r.size);
d64dff
-
d64dff
-  /* NULL terminate the list */
d64dff
-  if (end_stringsbuf (&r) == -1)
d64dff
-    return NULL;
d64dff
-
d64dff
-  return take_stringsbuf (&r);
d64dff
-}
d64dff
-
d64dff
-/* Takes optional arguments, consult optargs_bitmask. */
d64dff
-int
d64dff
-do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
d64dff
-{
d64dff
-  CLEANUP_FREE char *mp = NULL, *opts = NULL, *err = NULL;
d64dff
-  struct stat statbuf;
d64dff
-  int r;
d64dff
-
d64dff
-  ABS_PATH (mountpoint, 0, return -1);
d64dff
-
d64dff
-  mp = sysroot_path (mountpoint);
d64dff
-  if (!mp) {
d64dff
-    reply_with_perror ("malloc");
d64dff
-    return -1;
d64dff
-  }
d64dff
-
d64dff
-  /* Check the mountpoint exists and is a directory. */
d64dff
-  if (stat (mp, &statbuf) == -1) {
d64dff
-    reply_with_perror ("%s", mountpoint);
d64dff
-    return -1;
d64dff
-  }
d64dff
-  if (!S_ISDIR (statbuf.st_mode)) {
d64dff
-    reply_with_perror ("%s: mount point is not a directory", mountpoint);
d64dff
-    return -1;
d64dff
-  }
d64dff
-
d64dff
-  /* Add trans=virtio to the options. */
d64dff
-  if ((optargs_bitmask & GUESTFS_MOUNT_9P_OPTIONS_BITMASK) &&
d64dff
-      STRNEQ (options, "")) {
d64dff
-    if (asprintf (&opts, "trans=virtio,%s", options) == -1) {
d64dff
-      reply_with_perror ("asprintf");
d64dff
-      return -1;
d64dff
-    }
d64dff
-  }
d64dff
-  else {
d64dff
-    opts = strdup ("trans=virtio");
d64dff
-    if (opts == NULL) {
d64dff
-      reply_with_perror ("strdup");
d64dff
-      return -1;
d64dff
-    }
d64dff
-  }
d64dff
-
d64dff
-  modprobe_9pnet_virtio ();
d64dff
-  r = command (NULL, &err,
d64dff
-               "mount", "-o", opts, "-t", "9p", mount_tag, mp, NULL);
d64dff
-  if (r == -1) {
d64dff
-    reply_with_error ("%s on %s: %s", mount_tag, mountpoint, err);
d64dff
-    return -1;
d64dff
-  }
d64dff
-
d64dff
-  return 0;
d64dff
-}
d64dff
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
fa73fa
index 7322bfa5d..872eaa8bc 100644
d64dff
--- a/daemon/Makefile.am
d64dff
+++ b/daemon/Makefile.am
d64dff
@@ -84,7 +84,6 @@ guestfsd_SOURCES = \
d64dff
 	../common/protocol/guestfs_protocol.h \
d64dff
 	../common/utils/cleanups.h \
d64dff
 	../common/utils/guestfs-utils.h \
d64dff
-	9p.c \
d64dff
 	acl.c \
d64dff
 	actions.h \
d64dff
 	available.c \
d64dff
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
d64dff
index 6a97d8b0e..896314e7e 100644
d64dff
--- a/docs/C_SOURCE_FILES
d64dff
+++ b/docs/C_SOURCE_FILES
d64dff
@@ -43,7 +43,6 @@ common/visit/visit.c
d64dff
 common/visit/visit.h
d64dff
 common/windows/windows.c
d64dff
 common/windows/windows.h
d64dff
-daemon/9p.c
d64dff
 daemon/acl.c
d64dff
 daemon/actions.h
d64dff
 daemon/augeas.c
d64dff
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
d03fcc
index 226fb860a..05320fcd3 100644
d64dff
--- a/generator/actions_core.ml
d64dff
+++ b/generator/actions_core.ml
d64dff
@@ -6157,27 +6157,6 @@ This returns true iff the device exists and contains all zero bytes.
d64dff
 
d64dff
 Note that for large devices this can take a long time to run." };
d64dff
 
d64dff
-  { defaults with
d64dff
-    name = "list_9p"; added = (1, 11, 12);
d64dff
-    style = RStringList (RPlainString, "mounttags"), [], [];
d64dff
-    shortdesc = "list 9p filesystems";
d64dff
-    longdesc = "\
d64dff
-List all 9p filesystems attached to the guest.  A list of
d64dff
-mount tags is returned." };
d64dff
-
d64dff
-  { defaults with
d64dff
-    name = "mount_9p"; added = (1, 11, 12);
d64dff
-    style = RErr, [String (PlainString, "mounttag"); String (PlainString, "mountpoint")], [OString "options"];
d64dff
-    camel_name = "Mount9P";
d64dff
-    shortdesc = "mount 9p filesystem";
d64dff
-    longdesc = "\
d64dff
-Mount the virtio-9p filesystem with the tag C<mounttag> on the
d64dff
-directory C<mountpoint>.
d64dff
-
d64dff
-If required, C<trans=virtio> will be automatically added to the options.
d64dff
-Any other options required can be passed in the optional C<options>
d64dff
-parameter." };
d64dff
-
d64dff
   { defaults with
d64dff
     name = "list_dm_devices"; added = (1, 11, 15);
d64dff
     style = RStringList (RDevice, "devices"), [], [];
d64dff
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
d64dff
index 74b95baf7..6b6cb7353 100644
d64dff
--- a/generator/proc_nr.ml
d64dff
+++ b/generator/proc_nr.ml
d64dff
@@ -295,8 +295,6 @@ let proc_nr = [
d64dff
 282, "internal_autosync";
d64dff
 283, "is_zero";
d64dff
 284, "is_zero_device";
d64dff
-285, "list_9p";
d64dff
-286, "mount_9p";
d64dff
 287, "list_dm_devices";
d64dff
 288, "ntfsresize";
d64dff
 289, "btrfs_filesystem_resize";
d64dff
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
d64dff
index 650f8ddac..c4e735967 100644
d64dff
--- a/gobject/Makefile.inc
d64dff
+++ b/gobject/Makefile.inc
d64dff
@@ -94,7 +94,6 @@ guestfs_gobject_headers= \
d64dff
   include/guestfs-gobject/optargs-mksquashfs.h \
d64dff
   include/guestfs-gobject/optargs-mkswap.h \
d64dff
   include/guestfs-gobject/optargs-mktemp.h \
d64dff
-  include/guestfs-gobject/optargs-mount_9p.h \
d64dff
   include/guestfs-gobject/optargs-mount_local.h \
d64dff
   include/guestfs-gobject/optargs-ntfsclone_out.h \
d64dff
   include/guestfs-gobject/optargs-ntfsfix.h \
d64dff
@@ -188,7 +187,6 @@ guestfs_gobject_sources= \
d64dff
   src/optargs-mksquashfs.c \
d64dff
   src/optargs-mkswap.c \
d64dff
   src/optargs-mktemp.c \
d64dff
-  src/optargs-mount_9p.c \
d64dff
   src/optargs-mount_local.c \
d64dff
   src/optargs-ntfsclone_out.c \
d64dff
   src/optargs-ntfsfix.c \
d64dff
diff --git a/po/POTFILES b/po/POTFILES
d64dff
index 29205b6a6..23afe619c 100644
d64dff
--- a/po/POTFILES
d64dff
+++ b/po/POTFILES
d64dff
@@ -26,7 +26,6 @@ common/utils/stringlists-utils.c
d64dff
 common/utils/utils.c
d64dff
 common/visit/visit.c
d64dff
 common/windows/windows.c
d64dff
-daemon/9p.c
d64dff
 daemon/acl.c
d64dff
 daemon/augeas.c
d64dff
 daemon/available.c
d64dff
@@ -264,7 +263,6 @@ gobject/src/optargs-mkfs_btrfs.c
d64dff
 gobject/src/optargs-mksquashfs.c
d64dff
 gobject/src/optargs-mkswap.c
d64dff
 gobject/src/optargs-mktemp.c
d64dff
-gobject/src/optargs-mount_9p.c
d64dff
 gobject/src/optargs-mount_local.c
d64dff
 gobject/src/optargs-ntfsclone_out.c
d64dff
 gobject/src/optargs-ntfsfix.c
d64dff
diff --git a/tests/Makefile.am b/tests/Makefile.am
d64dff
index 919e2f248..e3613fec4 100644
d64dff
--- a/tests/Makefile.am
d64dff
+++ b/tests/Makefile.am
d64dff
@@ -43,7 +43,6 @@ check-slow:
d64dff
 check-valgrind:
d64dff
 	$(MAKE) VG="@VG@" check
d64dff
 
d64dff
-TESTS += 9p/test-9p.sh
d64dff
 EXTRA_DIST += 9p/test-9p.sh
d64dff
 
d64dff
 SLOW_TESTS += bigdirs/test-big-dirs.pl
d64dff
-- 
d03fcc
2.19.1.3.g30247aa5d201
d64dff