|
|
e9bfca |
From 98c7c205306eb27e63b3eccc930ceab88e15be25 Mon Sep 17 00:00:00 2001
|
|
|
151578 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
151578 |
Date: Thu, 18 Jul 2013 18:31:53 +0100
|
|
|
151578 |
Subject: [PATCH] RHEL 7: Remove 9p APIs from RHEL (RHBZ#921710).
|
|
|
151578 |
|
|
|
151578 |
---
|
|
|
151578 |
Makefile.am | 2 +-
|
|
|
e9bfca |
daemon/9p.c | 224 --------------------------------------
|
|
|
151578 |
daemon/Makefile.am | 1 -
|
|
|
151578 |
docs/C_SOURCE_FILES | 1 -
|
|
|
e9bfca |
generator/actions_core.ml | 21 ----
|
|
|
151578 |
generator/proc_nr.ml | 2 -
|
|
|
151578 |
gobject/Makefile.inc | 2 -
|
|
|
151578 |
po/POTFILES | 2 -
|
|
|
e9bfca |
8 files changed, 1 insertion(+), 254 deletions(-)
|
|
|
151578 |
delete mode 100644 daemon/9p.c
|
|
|
151578 |
|
|
|
151578 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
e9bfca |
index cc363341f..8fb25a57c 100644
|
|
|
151578 |
--- a/Makefile.am
|
|
|
151578 |
+++ b/Makefile.am
|
|
|
e9bfca |
@@ -78,7 +78,7 @@ SUBDIRS += tests/xfs
|
|
|
151578 |
SUBDIRS += tests/charsets
|
|
|
151578 |
SUBDIRS += tests/xml
|
|
|
151578 |
SUBDIRS += tests/mount-local
|
|
|
151578 |
-SUBDIRS += tests/9p
|
|
|
151578 |
+#SUBDIRS += tests/9p
|
|
|
151578 |
SUBDIRS += tests/rsync
|
|
|
151578 |
SUBDIRS += tests/bigdirs
|
|
|
151578 |
SUBDIRS += tests/disk-labels
|
|
|
151578 |
diff --git a/daemon/9p.c b/daemon/9p.c
|
|
|
151578 |
deleted file mode 100644
|
|
|
e9bfca |
index 55644249d..000000000
|
|
|
151578 |
--- a/daemon/9p.c
|
|
|
151578 |
+++ /dev/null
|
|
|
e9bfca |
@@ -1,224 +0,0 @@
|
|
|
151578 |
-/* libguestfs - the guestfsd daemon
|
|
|
151578 |
- * Copyright (C) 2011 Red Hat Inc.
|
|
|
151578 |
- *
|
|
|
151578 |
- * This program is free software; you can redistribute it and/or modify
|
|
|
151578 |
- * it under the terms of the GNU General Public License as published by
|
|
|
151578 |
- * the Free Software Foundation; either version 2 of the License, or
|
|
|
151578 |
- * (at your option) any later version.
|
|
|
151578 |
- *
|
|
|
151578 |
- * This program is distributed in the hope that it will be useful,
|
|
|
151578 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
151578 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
151578 |
- * GNU General Public License for more details.
|
|
|
151578 |
- *
|
|
|
151578 |
- * You should have received a copy of the GNU General Public License
|
|
|
151578 |
- * along with this program; if not, write to the Free Software
|
|
|
151578 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
151578 |
- */
|
|
|
151578 |
-
|
|
|
151578 |
-#include <config.h>
|
|
|
151578 |
-
|
|
|
151578 |
-#include <stdio.h>
|
|
|
151578 |
-#include <stdlib.h>
|
|
|
151578 |
-#include <string.h>
|
|
|
151578 |
-#include <unistd.h>
|
|
|
151578 |
-#include <limits.h>
|
|
|
151578 |
-#include <errno.h>
|
|
|
151578 |
-#include <sys/types.h>
|
|
|
151578 |
-#include <sys/stat.h>
|
|
|
151578 |
-#include <dirent.h>
|
|
|
151578 |
-#include <fcntl.h>
|
|
|
151578 |
-
|
|
|
151578 |
-#include "daemon.h"
|
|
|
151578 |
-#include "actions.h"
|
|
|
151578 |
-
|
|
|
151578 |
-#define BUS_PATH "/sys/bus/virtio/drivers/9pnet_virtio"
|
|
|
151578 |
-
|
|
|
151578 |
-static char *read_whole_file (const char *filename);
|
|
|
151578 |
-
|
|
|
151578 |
-/* https://bugzilla.redhat.com/show_bug.cgi?id=714981#c1 */
|
|
|
151578 |
-char **
|
|
|
151578 |
-do_list_9p (void)
|
|
|
151578 |
-{
|
|
|
151578 |
- CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r);
|
|
|
151578 |
-
|
|
|
151578 |
- DIR *dir;
|
|
|
151578 |
-
|
|
|
151578 |
- dir = opendir (BUS_PATH);
|
|
|
151578 |
- if (!dir) {
|
|
|
151578 |
- perror ("opendir: " BUS_PATH);
|
|
|
151578 |
- if (errno != ENOENT) {
|
|
|
151578 |
- reply_with_perror ("opendir: " BUS_PATH);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* If this directory doesn't exist, it probably means that
|
|
|
151578 |
- * the virtio driver isn't loaded. Don't return an error
|
|
|
151578 |
- * in this case, but return an empty list.
|
|
|
151578 |
- */
|
|
|
151578 |
- if (end_stringsbuf (&r) == -1)
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
-
|
|
|
151578 |
- return take_stringsbuf (&r);
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- while (1) {
|
|
|
151578 |
- struct dirent *d;
|
|
|
151578 |
-
|
|
|
151578 |
- errno = 0;
|
|
|
151578 |
- d = readdir (dir);
|
|
|
151578 |
- if (d == NULL) break;
|
|
|
151578 |
-
|
|
|
151578 |
- if (STRPREFIX (d->d_name, "virtio")) {
|
|
|
151578 |
- CLEANUP_FREE char *mount_tag_path = NULL;
|
|
|
151578 |
- if (asprintf (&mount_tag_path, BUS_PATH "/%s/mount_tag",
|
|
|
151578 |
- d->d_name) == -1) {
|
|
|
151578 |
- reply_with_perror ("asprintf");
|
|
|
151578 |
- closedir (dir);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* A bit unclear, but it looks like the virtio transport allows
|
|
|
151578 |
- * the mount tag length to be unlimited (or up to 65536 bytes).
|
|
|
151578 |
- * See: linux/include/linux/virtio_9p.h
|
|
|
151578 |
- */
|
|
|
151578 |
- CLEANUP_FREE char *mount_tag = read_whole_file (mount_tag_path);
|
|
|
151578 |
- if (mount_tag == 0)
|
|
|
151578 |
- continue;
|
|
|
151578 |
-
|
|
|
151578 |
- if (add_string (&r, mount_tag) == -1) {
|
|
|
151578 |
- closedir (dir);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
- }
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* Check readdir didn't fail */
|
|
|
151578 |
- if (errno != 0) {
|
|
|
151578 |
- reply_with_perror ("readdir: /sys/block");
|
|
|
151578 |
- closedir (dir);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* Close the directory handle */
|
|
|
151578 |
- if (closedir (dir) == -1) {
|
|
|
151578 |
- reply_with_perror ("closedir: /sys/block");
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* Sort the tags. */
|
|
|
151578 |
- if (r.size > 0)
|
|
|
151578 |
- sort_strings (r.argv, r.size);
|
|
|
151578 |
-
|
|
|
151578 |
- /* NULL terminate the list */
|
|
|
151578 |
- if (end_stringsbuf (&r) == -1)
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
-
|
|
|
151578 |
- return take_stringsbuf (&r);
|
|
|
151578 |
-}
|
|
|
151578 |
-
|
|
|
151578 |
-/* Read whole file into dynamically allocated array. If there is an
|
|
|
151578 |
- * error, DON'T call reply_with_perror, just return NULL. Returns a
|
|
|
151578 |
- * \0-terminated string.
|
|
|
151578 |
- */
|
|
|
151578 |
-static char *
|
|
|
151578 |
-read_whole_file (const char *filename)
|
|
|
151578 |
-{
|
|
|
151578 |
- char *r = NULL;
|
|
|
151578 |
- size_t alloc = 0, size = 0;
|
|
|
151578 |
- int fd;
|
|
|
151578 |
-
|
|
|
151578 |
- fd = open (filename, O_RDONLY|O_CLOEXEC);
|
|
|
151578 |
- if (fd == -1) {
|
|
|
151578 |
- perror (filename);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- while (1) {
|
|
|
151578 |
- alloc += 256;
|
|
|
151578 |
- char *r2 = realloc (r, alloc);
|
|
|
151578 |
- if (r2 == NULL) {
|
|
|
151578 |
- perror ("realloc");
|
|
|
151578 |
- free (r);
|
|
|
151578 |
- close (fd);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
- r = r2;
|
|
|
151578 |
-
|
|
|
151578 |
- /* The '- 1' in the size calculation ensures there is space below
|
|
|
151578 |
- * to add \0 to the end of the input.
|
|
|
151578 |
- */
|
|
|
151578 |
- ssize_t n = read (fd, r + size, alloc - size - 1);
|
|
|
151578 |
- if (n == -1) {
|
|
|
151578 |
- fprintf (stderr, "read: %s: %m\n", filename);
|
|
|
151578 |
- free (r);
|
|
|
151578 |
- close (fd);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
- if (n == 0)
|
|
|
151578 |
- break;
|
|
|
151578 |
- size += n;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- if (close (fd) == -1) {
|
|
|
151578 |
- fprintf (stderr, "close: %s: %m\n", filename);
|
|
|
151578 |
- free (r);
|
|
|
151578 |
- return NULL;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- r[size] = '\0';
|
|
|
151578 |
-
|
|
|
151578 |
- return r;
|
|
|
151578 |
-}
|
|
|
151578 |
-
|
|
|
151578 |
-/* Takes optional arguments, consult optargs_bitmask. */
|
|
|
151578 |
-int
|
|
|
151578 |
-do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
|
|
|
151578 |
-{
|
|
|
151578 |
- CLEANUP_FREE char *mp = NULL, *opts = NULL, *err = NULL;
|
|
|
151578 |
- struct stat statbuf;
|
|
|
151578 |
- int r;
|
|
|
151578 |
-
|
|
|
151578 |
- ABS_PATH (mountpoint, 0, return -1);
|
|
|
151578 |
-
|
|
|
151578 |
- mp = sysroot_path (mountpoint);
|
|
|
151578 |
- if (!mp) {
|
|
|
151578 |
- reply_with_perror ("malloc");
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* Check the mountpoint exists and is a directory. */
|
|
|
151578 |
- if (stat (mp, &statbuf) == -1) {
|
|
|
151578 |
- reply_with_perror ("%s", mountpoint);
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
- if (!S_ISDIR (statbuf.st_mode)) {
|
|
|
151578 |
- reply_with_perror ("%s: mount point is not a directory", mountpoint);
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- /* Add trans=virtio to the options. */
|
|
|
151578 |
- if ((optargs_bitmask & GUESTFS_MOUNT_9P_OPTIONS_BITMASK) &&
|
|
|
151578 |
- STRNEQ (options, "")) {
|
|
|
151578 |
- if (asprintf (&opts, "trans=virtio,%s", options) == -1) {
|
|
|
151578 |
- reply_with_perror ("asprintf");
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
- }
|
|
|
151578 |
- else {
|
|
|
151578 |
- opts = strdup ("trans=virtio");
|
|
|
151578 |
- if (opts == NULL) {
|
|
|
151578 |
- reply_with_perror ("strdup");
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- r = command (NULL, &err,
|
|
|
e9bfca |
- "mount", "-o", opts, "-t", "9p", mount_tag, mp, NULL);
|
|
|
151578 |
- if (r == -1) {
|
|
|
151578 |
- reply_with_error ("%s on %s: %s", mount_tag, mountpoint, err);
|
|
|
151578 |
- return -1;
|
|
|
151578 |
- }
|
|
|
151578 |
-
|
|
|
151578 |
- return 0;
|
|
|
151578 |
-}
|
|
|
151578 |
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
|
|
|
e9bfca |
index 6240f517d..29f3aa6df 100644
|
|
|
151578 |
--- a/daemon/Makefile.am
|
|
|
151578 |
+++ b/daemon/Makefile.am
|
|
|
e9bfca |
@@ -76,7 +76,6 @@ guestfsd_SOURCES = \
|
|
|
151578 |
../common/protocol/guestfs_protocol.h \
|
|
|
e9bfca |
../common/utils/cleanups.h \
|
|
|
e9bfca |
../common/utils/guestfs-utils.h \
|
|
|
151578 |
- 9p.c \
|
|
|
151578 |
acl.c \
|
|
|
151578 |
actions.h \
|
|
|
151578 |
available.c \
|
|
|
151578 |
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
|
|
|
e9bfca |
index f3ee61e0d..e8b1d5283 100644
|
|
|
151578 |
--- a/docs/C_SOURCE_FILES
|
|
|
151578 |
+++ b/docs/C_SOURCE_FILES
|
|
|
e9bfca |
@@ -70,7 +70,6 @@ common/windows/windows.h
|
|
|
151578 |
customize/crypt-c.c
|
|
|
151578 |
customize/dummy.c
|
|
|
151578 |
customize/perl_edit-c.c
|
|
|
151578 |
-daemon/9p.c
|
|
|
151578 |
daemon/acl.c
|
|
|
151578 |
daemon/actions.h
|
|
|
151578 |
daemon/augeas.c
|
|
|
151578 |
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
|
|
|
e9bfca |
index 2ae3ec1d9..237edafce 100644
|
|
|
151578 |
--- a/generator/actions_core.ml
|
|
|
151578 |
+++ b/generator/actions_core.ml
|
|
|
e9bfca |
@@ -6179,27 +6179,6 @@ This returns true iff the device exists and contains all zero bytes.
|
|
|
151578 |
|
|
|
151578 |
Note that for large devices this can take a long time to run." };
|
|
|
151578 |
|
|
|
151578 |
- { defaults with
|
|
|
151578 |
- name = "list_9p"; added = (1, 11, 12);
|
|
|
e9bfca |
- style = RStringList (RPlainString, "mounttags"), [], [];
|
|
|
151578 |
- shortdesc = "list 9p filesystems";
|
|
|
151578 |
- longdesc = "\
|
|
|
151578 |
-List all 9p filesystems attached to the guest. A list of
|
|
|
151578 |
-mount tags is returned." };
|
|
|
151578 |
-
|
|
|
151578 |
- { defaults with
|
|
|
151578 |
- name = "mount_9p"; added = (1, 11, 12);
|
|
|
e9bfca |
- style = RErr, [String (PlainString, "mounttag"); String (PlainString, "mountpoint")], [OString "options"];
|
|
|
151578 |
- camel_name = "Mount9P";
|
|
|
151578 |
- shortdesc = "mount 9p filesystem";
|
|
|
151578 |
- longdesc = "\
|
|
|
151578 |
-Mount the virtio-9p filesystem with the tag C<mounttag> on the
|
|
|
151578 |
-directory C<mountpoint>.
|
|
|
151578 |
-
|
|
|
151578 |
-If required, C<trans=virtio> will be automatically added to the options.
|
|
|
151578 |
-Any other options required can be passed in the optional C<options>
|
|
|
151578 |
-parameter." };
|
|
|
151578 |
-
|
|
|
151578 |
{ defaults with
|
|
|
151578 |
name = "list_dm_devices"; added = (1, 11, 15);
|
|
|
e9bfca |
style = RStringList (RDevice, "devices"), [], [];
|
|
|
151578 |
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
|
|
|
e9bfca |
index 9e16ab14a..e6b018c62 100644
|
|
|
151578 |
--- a/generator/proc_nr.ml
|
|
|
151578 |
+++ b/generator/proc_nr.ml
|
|
|
151578 |
@@ -295,8 +295,6 @@ let proc_nr = [
|
|
|
151578 |
282, "internal_autosync";
|
|
|
151578 |
283, "is_zero";
|
|
|
151578 |
284, "is_zero_device";
|
|
|
151578 |
-285, "list_9p";
|
|
|
151578 |
-286, "mount_9p";
|
|
|
151578 |
287, "list_dm_devices";
|
|
|
151578 |
288, "ntfsresize";
|
|
|
151578 |
289, "btrfs_filesystem_resize";
|
|
|
151578 |
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
|
|
|
e9bfca |
index 5aa2dcafe..b8f8e9226 100644
|
|
|
151578 |
--- a/gobject/Makefile.inc
|
|
|
151578 |
+++ b/gobject/Makefile.inc
|
|
|
e9bfca |
@@ -93,7 +93,6 @@ guestfs_gobject_headers= \
|
|
|
151578 |
include/guestfs-gobject/optargs-mksquashfs.h \
|
|
|
151578 |
include/guestfs-gobject/optargs-mkswap.h \
|
|
|
151578 |
include/guestfs-gobject/optargs-mktemp.h \
|
|
|
151578 |
- include/guestfs-gobject/optargs-mount_9p.h \
|
|
|
151578 |
include/guestfs-gobject/optargs-mount_local.h \
|
|
|
151578 |
include/guestfs-gobject/optargs-ntfsclone_out.h \
|
|
|
151578 |
include/guestfs-gobject/optargs-ntfsfix.h \
|
|
|
e9bfca |
@@ -186,7 +185,6 @@ guestfs_gobject_sources= \
|
|
|
151578 |
src/optargs-mksquashfs.c \
|
|
|
151578 |
src/optargs-mkswap.c \
|
|
|
151578 |
src/optargs-mktemp.c \
|
|
|
151578 |
- src/optargs-mount_9p.c \
|
|
|
151578 |
src/optargs-mount_local.c \
|
|
|
151578 |
src/optargs-ntfsclone_out.c \
|
|
|
151578 |
src/optargs-ntfsfix.c \
|
|
|
151578 |
diff --git a/po/POTFILES b/po/POTFILES
|
|
|
e9bfca |
index a049d66fe..5daec8a89 100644
|
|
|
151578 |
--- a/po/POTFILES
|
|
|
151578 |
+++ b/po/POTFILES
|
|
|
e9bfca |
@@ -58,7 +58,6 @@ customize/crypt-c.c
|
|
|
151578 |
customize/dummy.c
|
|
|
151578 |
customize/perl_edit-c.c
|
|
|
151578 |
customize/test-password.pl
|
|
|
151578 |
-daemon/9p.c
|
|
|
151578 |
daemon/acl.c
|
|
|
151578 |
daemon/augeas.c
|
|
|
151578 |
daemon/available.c
|
|
|
e9bfca |
@@ -290,7 +289,6 @@ gobject/src/optargs-mkfs_btrfs.c
|
|
|
151578 |
gobject/src/optargs-mksquashfs.c
|
|
|
151578 |
gobject/src/optargs-mkswap.c
|
|
|
151578 |
gobject/src/optargs-mktemp.c
|
|
|
151578 |
-gobject/src/optargs-mount_9p.c
|
|
|
151578 |
gobject/src/optargs-mount_local.c
|
|
|
151578 |
gobject/src/optargs-ntfsclone_out.c
|
|
|
151578 |
gobject/src/optargs-ntfsfix.c
|
|
|
151578 |
--
|
|
|
e9bfca |
2.17.1
|
|
|
151578 |
|