mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0003-daemon-Implement-set-label-for-XFS-and-fix-it-for-bt.patch

022f11
From 6d4a1c16c88e8a728183590fee2867aabe8a15d8 Mon Sep 17 00:00:00 2001
022f11
From: "Richard W.M. Jones" <rjones@redhat.com>
022f11
Date: Mon, 22 Jul 2013 11:29:42 +0100
022f11
Subject: [PATCH] daemon: Implement set-label for XFS and fix it for btrfs
022f11
 (RHBZ#986875).
022f11
022f11
Implement 'set-label' for XFS filesystems.
022f11
022f11
Fix the call for btrfs.  Previous
022f11
commit d5817537fa6c51a7f851ecc5e4e63e60609e0c03 added some bogus
022f11
documentation implying this call would work for btrfs, but it did
022f11
not.
022f11
022f11
Add tests.
022f11
022f11
(cherry picked from commit 091d22f49e7fcb53fb3bb23e2ba94ca12eb88eab)
022f11
---
022f11
 Makefile.am                    |  1 +
022f11
 configure.ac                   |  1 +
022f11
 tests/btrfs/Makefile.am        |  1 +
022f11
 tests/btrfs/test-btrfs-misc.pl | 51 ++++++++++++++++++++++++++++++++++++++++++
022f11
 tests/xfs/Makefile.am          | 26 +++++++++++++++++++++
022f11
 tests/xfs/test-xfs-misc.pl     | 50 +++++++++++++++++++++++++++++++++++++++++
022f11
 6 files changed, 130 insertions(+)
022f11
 create mode 100755 tests/btrfs/test-btrfs-misc.pl
022f11
 create mode 100644 tests/xfs/Makefile.am
022f11
 create mode 100755 tests/xfs/test-xfs-misc.pl
022f11
022f11
diff --git a/Makefile.am b/Makefile.am
022f11
index de747b0..c36f028 100644
022f11
--- a/Makefile.am
022f11
+++ b/Makefile.am
022f11
@@ -49,6 +49,7 @@ SUBDIRS += tests/md
022f11
 SUBDIRS += tests/selinux
022f11
 SUBDIRS += tests/ntfsclone
022f11
 SUBDIRS += tests/btrfs
022f11
+SUBDIRS += tests/xfs
022f11
 SUBDIRS += tests/charsets
022f11
 SUBDIRS += tests/xml
022f11
 SUBDIRS += tests/mount-local
022f11
diff --git a/configure.ac b/configure.ac
022f11
index 62d558f..75232e8 100644
022f11
--- a/configure.ac
022f11
+++ b/configure.ac
022f11
@@ -1654,6 +1654,7 @@ AC_CONFIG_FILES([Makefile
022f11
                  tests/selinux/Makefile
022f11
                  tests/syslinux/Makefile
022f11
                  tests/tmpdirs/Makefile
022f11
+                 tests/xfs/Makefile
022f11
                  tests/xml/Makefile
022f11
                  tools/Makefile])
022f11
 AC_OUTPUT
022f11
diff --git a/tests/btrfs/Makefile.am b/tests/btrfs/Makefile.am
022f11
index 32a2d65..87854ac 100644
022f11
--- a/tests/btrfs/Makefile.am
022f11
+++ b/tests/btrfs/Makefile.am
022f11
@@ -18,6 +18,7 @@
022f11
 include $(top_srcdir)/subdir-rules.mk
022f11
 
022f11
 TESTS = \
022f11
+	test-btrfs-misc.pl \
022f11
 	test-btrfs-devices.sh \
022f11
 	test-btrfs-subvolume-default.pl
022f11
 
022f11
diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl
022f11
new file mode 100755
022f11
index 0000000..2fe7c59
022f11
--- /dev/null
022f11
+++ b/tests/btrfs/test-btrfs-misc.pl
022f11
@@ -0,0 +1,51 @@
022f11
+#!/usr/bin/perl
022f11
+# libguestfs
022f11
+# Copyright (C) 2013 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
+# Miscellaneous btrfs features.
022f11
+
022f11
+use strict;
022f11
+use warnings;
022f11
+
022f11
+use Sys::Guestfs;
022f11
+
022f11
+# Allow the test to be skipped since btrfs is often broken.
022f11
+exit 77 if $ENV{SKIP_TEST_BTRFS_MISC_PL};
022f11
+
022f11
+my $g = Sys::Guestfs->new ();
022f11
+
022f11
+$g->add_drive_scratch (1024*1024*1024);
022f11
+$g->launch ();
022f11
+
022f11
+# If btrfs is not available, bail.
022f11
+unless ($g->feature_available (["btrfs"])) {
022f11
+    warn "$0: skipping test because btrfs is not available\n";
022f11
+    exit 77;
022f11
+}
022f11
+
022f11
+$g->part_disk ("/dev/sda", "mbr");
022f11
+
022f11
+$g->mkfs_btrfs (["/dev/sda1"]);
022f11
+
022f11
+# Setting label.
022f11
+$g->set_label ("/dev/sda1", "newlabel");
022f11
+my $label = $g->vfs_label ("/dev/sda1");
022f11
+die "unexpected label: expecting 'newlabel' but got '$label'"
022f11
+    unless $label eq "newlabel";
022f11
+
022f11
+$g->shutdown ();
022f11
+$g->close ();
022f11
diff --git a/tests/xfs/Makefile.am b/tests/xfs/Makefile.am
022f11
new file mode 100644
022f11
index 0000000..fbe0e15
022f11
--- /dev/null
022f11
+++ b/tests/xfs/Makefile.am
022f11
@@ -0,0 +1,26 @@
022f11
+# libguestfs
022f11
+# Copyright (C) 2013 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
+include $(top_srcdir)/subdir-rules.mk
022f11
+
022f11
+TESTS = \
022f11
+	test-xfs-misc.pl
022f11
+
022f11
+TESTS_ENVIRONMENT = $(top_builddir)/run --test
022f11
+
022f11
+EXTRA_DIST = \
022f11
+	$(TESTS)
022f11
diff --git a/tests/xfs/test-xfs-misc.pl b/tests/xfs/test-xfs-misc.pl
022f11
new file mode 100755
022f11
index 0000000..4036708
022f11
--- /dev/null
022f11
+++ b/tests/xfs/test-xfs-misc.pl
022f11
@@ -0,0 +1,50 @@
022f11
+#!/usr/bin/perl
022f11
+# libguestfs
022f11
+# Copyright (C) 2013 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
+# Miscellaneous xfs features.
022f11
+
022f11
+use strict;
022f11
+use warnings;
022f11
+
022f11
+use Sys::Guestfs;
022f11
+
022f11
+exit 77 if $ENV{SKIP_TEST_XFS_MISC_PL};
022f11
+
022f11
+my $g = Sys::Guestfs->new ();
022f11
+
022f11
+$g->add_drive_scratch (1024*1024*1024);
022f11
+$g->launch ();
022f11
+
022f11
+# If xfs is not available, bail.
022f11
+unless ($g->feature_available (["xfs"])) {
022f11
+    warn "$0: skipping test because xfs is not available\n";
022f11
+    exit 77;
022f11
+}
022f11
+
022f11
+$g->part_disk ("/dev/sda", "mbr");
022f11
+
022f11
+$g->mkfs ("xfs", "/dev/sda1");
022f11
+
022f11
+# Setting label.
022f11
+$g->set_label ("/dev/sda1", "newlabel");
022f11
+my $label = $g->vfs_label ("/dev/sda1");
022f11
+die "unexpected label: expecting 'newlabel' but got '$label'"
022f11
+    unless $label eq "newlabel";
022f11
+
022f11
+$g->shutdown ();
022f11
+$g->close ();
022f11
-- 
022f11
1.8.3.1
022f11