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

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