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

022f11
From 3001eccab8e8907128ffd73745fdfeb82493809c Mon Sep 17 00:00:00 2001
022f11
From: "Richard W.M. Jones" <rjones@redhat.com>
022f11
Date: Thu, 18 Jul 2013 18:31:53 +0100
022f11
Subject: [PATCH] RHEL 7: Remove 9p APIs from RHEL (RHBZ#921710).
022f11
022f11
---
022f11
 Makefile.am          |   2 +-
022f11
 daemon/9p.c          | 221 ---------------------------------------------------
022f11
 daemon/Makefile.am   |   1 -
022f11
 generator/actions.ml |  23 ------
022f11
 gobject/Makefile.inc |   2 -
022f11
 po/POTFILES          |   2 -
022f11
 6 files changed, 1 insertion(+), 250 deletions(-)
022f11
 delete mode 100644 daemon/9p.c
022f11
022f11
diff --git a/Makefile.am b/Makefile.am
022f11
index c36f028..a09bd82 100644
022f11
--- a/Makefile.am
022f11
+++ b/Makefile.am
022f11
@@ -53,7 +53,7 @@ SUBDIRS += tests/xfs
022f11
 SUBDIRS += tests/charsets
022f11
 SUBDIRS += tests/xml
022f11
 SUBDIRS += tests/mount-local
022f11
-SUBDIRS += tests/9p
022f11
+#SUBDIRS += tests/9p
022f11
 SUBDIRS += tests/rsync
022f11
 SUBDIRS += tests/bigdirs
022f11
 SUBDIRS += tests/disk-labels
022f11
diff --git a/daemon/9p.c b/daemon/9p.c
022f11
deleted file mode 100644
022f11
index 024ac24..0000000
022f11
--- a/daemon/9p.c
022f11
+++ /dev/null
022f11
@@ -1,221 +0,0 @@
022f11
-/* libguestfs - the guestfsd daemon
022f11
- * Copyright (C) 2011 Red Hat Inc.
022f11
- *
022f11
- * This program is free software; you can redistribute it and/or modify
022f11
- * it under the terms of the GNU General Public License as published by
022f11
- * the Free Software Foundation; either version 2 of the License, or
022f11
- * (at your option) any later version.
022f11
- *
022f11
- * This program is distributed in the hope that it will be useful,
022f11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
022f11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
022f11
- * GNU General Public License for more details.
022f11
- *
022f11
- * You should have received a copy of the GNU General Public License
022f11
- * along with this program; if not, write to the Free Software
022f11
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
022f11
- */
022f11
-
022f11
-#include <config.h>
022f11
-
022f11
-#include <stdio.h>
022f11
-#include <stdlib.h>
022f11
-#include <string.h>
022f11
-#include <unistd.h>
022f11
-#include <limits.h>
022f11
-#include <errno.h>
022f11
-#include <sys/types.h>
022f11
-#include <sys/stat.h>
022f11
-#include <dirent.h>
022f11
-#include <fcntl.h>
022f11
-
022f11
-#include "daemon.h"
022f11
-#include "actions.h"
022f11
-
022f11
-#define BUS_PATH "/sys/bus/virtio/drivers/9pnet_virtio"
022f11
-GUESTFSD_EXT_CMD(str_mount, mount);
022f11
-
022f11
-static char *read_whole_file (const char *filename);
022f11
-
022f11
-/* https://bugzilla.redhat.com/show_bug.cgi?id=714981#c1 */
022f11
-char **
022f11
-do_list_9p (void)
022f11
-{
022f11
-  DECLARE_STRINGSBUF (r);
022f11
-
022f11
-  DIR *dir;
022f11
-
022f11
-  dir = opendir (BUS_PATH);
022f11
-  if (!dir) {
022f11
-    perror ("opendir: " BUS_PATH);
022f11
-    if (errno != ENOENT) {
022f11
-      reply_with_perror ("opendir: " BUS_PATH);
022f11
-      return NULL;
022f11
-    }
022f11
-
022f11
-    /* If this directory doesn't exist, it probably means that
022f11
-     * the virtio driver isn't loaded.  Don't return an error
022f11
-     * in this case, but return an empty list.
022f11
-     */
022f11
-    if (end_stringsbuf (&r) == -1)
022f11
-      return NULL;
022f11
-
022f11
-    return r.argv;
022f11
-  }
022f11
-
022f11
-  while (1) {
022f11
-    errno = 0;
022f11
-    struct dirent *d = readdir (dir);
022f11
-    if (d == NULL) break;
022f11
-
022f11
-    if (STRPREFIX (d->d_name, "virtio")) {
022f11
-      char mount_tag_path[256];
022f11
-      snprintf (mount_tag_path, sizeof mount_tag_path,
022f11
-                BUS_PATH "/%s/mount_tag", d->d_name);
022f11
-
022f11
-      /* A bit unclear, but it looks like the virtio transport allows
022f11
-       * the mount tag length to be unlimited (or up to 65536 bytes).
022f11
-       * See: linux/include/linux/virtio_9p.h
022f11
-       */
022f11
-      CLEANUP_FREE char *mount_tag = read_whole_file (mount_tag_path);
022f11
-      if (mount_tag == 0)
022f11
-        continue;
022f11
-
022f11
-      if (add_string (&r, mount_tag) == -1) {
022f11
-        closedir (dir);
022f11
-        return NULL;
022f11
-      }
022f11
-    }
022f11
-  }
022f11
-
022f11
-  /* Check readdir didn't fail */
022f11
-  if (errno != 0) {
022f11
-    reply_with_perror ("readdir: /sys/block");
022f11
-    free_stringslen (r.argv, r.size);
022f11
-    closedir (dir);
022f11
-    return NULL;
022f11
-  }
022f11
-
022f11
-  /* Close the directory handle */
022f11
-  if (closedir (dir) == -1) {
022f11
-    reply_with_perror ("closedir: /sys/block");
022f11
-    free_stringslen (r.argv, r.size);
022f11
-    return NULL;
022f11
-  }
022f11
-
022f11
-  /* Sort the tags. */
022f11
-  if (r.size > 0)
022f11
-    sort_strings (r.argv, r.size);
022f11
-
022f11
-  /* NULL terminate the list */
022f11
-  if (end_stringsbuf (&r) == -1)
022f11
-    return NULL;
022f11
-
022f11
-  return r.argv;
022f11
-}
022f11
-
022f11
-/* Read whole file into dynamically allocated array.  If there is an
022f11
- * error, DON'T call reply_with_perror, just return NULL.  Returns a
022f11
- * \0-terminated string.
022f11
- */
022f11
-static char *
022f11
-read_whole_file (const char *filename)
022f11
-{
022f11
-  char *r = NULL;
022f11
-  size_t alloc = 0, size = 0;
022f11
-  int fd;
022f11
-
022f11
-  fd = open (filename, O_RDONLY|O_CLOEXEC);
022f11
-  if (fd == -1) {
022f11
-    perror (filename);
022f11
-    return NULL;
022f11
-  }
022f11
-
022f11
-  while (1) {
022f11
-    alloc += 256;
022f11
-    char *r2 = realloc (r, alloc);
022f11
-    if (r2 == NULL) {
022f11
-      perror ("realloc");
022f11
-      free (r);
022f11
-      close (fd);
022f11
-      return NULL;
022f11
-    }
022f11
-    r = r2;
022f11
-
022f11
-    /* The '- 1' in the size calculation ensures there is space below
022f11
-     * to add \0 to the end of the input.
022f11
-     */
022f11
-    ssize_t n = read (fd, r + size, alloc - size - 1);
022f11
-    if (n == -1) {
022f11
-      fprintf (stderr, "read: %s: %m\n", filename);
022f11
-      free (r);
022f11
-      close (fd);
022f11
-      return NULL;
022f11
-    }
022f11
-    if (n == 0)
022f11
-      break;
022f11
-    size += n;
022f11
-  }
022f11
-
022f11
-  if (close (fd) == -1) {
022f11
-    fprintf (stderr, "close: %s: %m\n", filename);
022f11
-    free (r);
022f11
-    return NULL;
022f11
-  }
022f11
-
022f11
-  r[size] = '\0';
022f11
-
022f11
-  return r;
022f11
-}
022f11
-
022f11
-/* Takes optional arguments, consult optargs_bitmask. */
022f11
-int
022f11
-do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
022f11
-{
022f11
-  CLEANUP_FREE char *mp = NULL, *opts = NULL, *err = NULL;
022f11
-  struct stat statbuf;
022f11
-  int r;
022f11
-
022f11
-  ABS_PATH (mountpoint, , return -1);
022f11
-
022f11
-  mp = sysroot_path (mountpoint);
022f11
-  if (!mp) {
022f11
-    reply_with_perror ("malloc");
022f11
-    return -1;
022f11
-  }
022f11
-
022f11
-  /* Check the mountpoint exists and is a directory. */
022f11
-  if (stat (mp, &statbuf) == -1) {
022f11
-    reply_with_perror ("%s", mountpoint);
022f11
-    return -1;
022f11
-  }
022f11
-  if (!S_ISDIR (statbuf.st_mode)) {
022f11
-    reply_with_perror ("%s: mount point is not a directory", mountpoint);
022f11
-    return -1;
022f11
-  }
022f11
-
022f11
-  /* Add trans=virtio to the options. */
022f11
-  if ((optargs_bitmask & GUESTFS_MOUNT_9P_OPTIONS_BITMASK) &&
022f11
-      STRNEQ (options, "")) {
022f11
-    if (asprintf (&opts, "trans=virtio,%s", options) == -1) {
022f11
-      reply_with_perror ("asprintf");
022f11
-      return -1;
022f11
-    }
022f11
-  }
022f11
-  else {
022f11
-    opts = strdup ("trans=virtio");
022f11
-    if (opts == NULL) {
022f11
-      reply_with_perror ("strdup");
022f11
-      return -1;
022f11
-    }
022f11
-  }
022f11
-
022f11
-  r = command (NULL, &err,
022f11
-               str_mount, "-o", opts, "-t", "9p", mount_tag, mp, NULL);
022f11
-  if (r == -1) {
022f11
-    reply_with_error ("%s on %s: %s", mount_tag, mountpoint, err);
022f11
-    return -1;
022f11
-  }
022f11
-
022f11
-  return 0;
022f11
-}
022f11
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
022f11
index d077dab..13a04ac 100644
022f11
--- a/daemon/Makefile.am
022f11
+++ b/daemon/Makefile.am
022f11
@@ -77,7 +77,6 @@ noinst_PROGRAMS = guestfsd
022f11
 endif
022f11
 
022f11
 guestfsd_SOURCES = \
022f11
-	9p.c \
022f11
 	acl.c \
022f11
 	actions.h \
022f11
 	available.c \
022f11
diff --git a/generator/actions.ml b/generator/actions.ml
022f11
index 24f4468..ccd9e95 100644
022f11
--- a/generator/actions.ml
022f11
+++ b/generator/actions.ml
022f11
@@ -8886,29 +8886,6 @@ This returns true iff the device exists and contains all zero bytes.
022f11
 Note that for large devices this can take a long time to run." };
022f11
 
022f11
   { defaults with
022f11
-    name = "list_9p";
022f11
-    style = RStringList "mounttags", [], [];
022f11
-    proc_nr = Some 285;
022f11
-    shortdesc = "list 9p filesystems";
022f11
-    longdesc = "\
022f11
-List all 9p filesystems attached to the guest.  A list of
022f11
-mount tags is returned." };
022f11
-
022f11
-  { defaults with
022f11
-    name = "mount_9p";
022f11
-    style = RErr, [String "mounttag"; String "mountpoint"], [OString "options"];
022f11
-    proc_nr = Some 286;
022f11
-    camel_name = "Mount9P";
022f11
-    shortdesc = "mount 9p filesystem";
022f11
-    longdesc = "\
022f11
-Mount the virtio-9p filesystem with the tag C<mounttag> on the
022f11
-directory C<mountpoint>.
022f11
-
022f11
-If required, C<trans=virtio> will be automatically added to the options.
022f11
-Any other options required can be passed in the optional C<options>
022f11
-parameter." };
022f11
-
022f11
-  { defaults with
022f11
     name = "list_dm_devices";
022f11
     style = RStringList "devices", [], [];
022f11
     proc_nr = Some 287;
022f11
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
022f11
index 19c771f..47360cb 100644
022f11
--- a/gobject/Makefile.inc
022f11
+++ b/gobject/Makefile.inc
022f11
@@ -64,7 +64,6 @@ guestfs_gobject_headers= \
022f11
   include/guestfs-gobject/optargs-is_fifo.h \
022f11
   include/guestfs-gobject/optargs-is_socket.h \
022f11
   include/guestfs-gobject/optargs-mkfs.h \
022f11
-  include/guestfs-gobject/optargs-mount_9p.h \
022f11
   include/guestfs-gobject/optargs-ntfsresize.h \
022f11
   include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \
022f11
   include/guestfs-gobject/optargs-compress_out.h \
022f11
@@ -138,7 +137,6 @@ guestfs_gobject_sources= \
022f11
   src/optargs-is_fifo.c \
022f11
   src/optargs-is_socket.c \
022f11
   src/optargs-mkfs.c \
022f11
-  src/optargs-mount_9p.c \
022f11
   src/optargs-ntfsresize.c \
022f11
   src/optargs-btrfs_filesystem_resize.c \
022f11
   src/optargs-compress_out.c \
022f11
diff --git a/po/POTFILES b/po/POTFILES
022f11
index 53b660d..cc4e917 100644
022f11
--- a/po/POTFILES
022f11
+++ b/po/POTFILES
022f11
@@ -2,7 +2,6 @@ align/scan.c
022f11
 cat/virt-cat.c
022f11
 cat/virt-filesystems.c
022f11
 cat/virt-ls.c
022f11
-daemon/9p.c
022f11
 daemon/acl.c
022f11
 daemon/augeas.c
022f11
 daemon/available.c
022f11
@@ -180,7 +179,6 @@ gobject/src/optargs-mkfs.c
022f11
 gobject/src/optargs-mkfs_btrfs.c
022f11
 gobject/src/optargs-mkswap.c
022f11
 gobject/src/optargs-mktemp.c
022f11
-gobject/src/optargs-mount_9p.c
022f11
 gobject/src/optargs-mount_local.c
022f11
 gobject/src/optargs-ntfsclone_out.c
022f11
 gobject/src/optargs-ntfsfix.c
022f11
-- 
022f11
1.8.3.1
022f11