diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2019-01-10 14:57:24 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2019-01-10 14:57:24 +0000 |
commit | 6e465f74c5d66caced2d255001dbb8d393d90f6a (patch) | |
tree | 191d8e7c14b2825f60999b0d1994b677cb9cc735 /main/busybox | |
parent | d2bfa8f71e8555beb08af04d58bb2cea9138c779 (diff) | |
download | aports-6e465f74c5d66caced2d255001dbb8d393d90f6a.tar.bz2 aports-6e465f74c5d66caced2d255001dbb8d393d90f6a.tar.xz |
main/busybox: backport cp --reflink support
fixes #9334
Diffstat (limited to 'main/busybox')
-rw-r--r-- | main/busybox/0001-cp-optional-reflink-support.patch | 120 | ||||
-rw-r--r-- | main/busybox/APKBUILD | 6 | ||||
-rw-r--r-- | main/busybox/busyboxconfig | 5 |
3 files changed, 127 insertions, 4 deletions
diff --git a/main/busybox/0001-cp-optional-reflink-support.patch b/main/busybox/0001-cp-optional-reflink-support.patch new file mode 100644 index 0000000000..777d9b8bd3 --- /dev/null +++ b/main/busybox/0001-cp-optional-reflink-support.patch @@ -0,0 +1,120 @@ +From 79fb6ac7a5acc4178b66314c573aeada1d387ed9 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <vda.linux@googlemail.com> +Date: Fri, 13 Jul 2018 20:30:02 +0200 +Subject: [PATCH] cp: optional --reflink support + +function old new delta +cp_main 428 512 +84 +copy_file 1676 1742 +66 + +Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> +--- + coreutils/cp.c | 24 ++++++++++++++++++++++++ + include/libbb.h | 3 +++ + libbb/copy_file.c | 19 +++++++++++++++++++ + 3 files changed, 46 insertions(+) + +diff --git a/coreutils/cp.c b/coreutils/cp.c +index 455bffbba..b623aaf33 100644 +--- a/coreutils/cp.c ++++ b/coreutils/cp.c +@@ -24,6 +24,11 @@ + //config: help + //config: Enable long options. + //config: Also add support for --parents option. ++//config: ++//config:config FEATURE_CP_REFLINK ++//config: bool "Enable --reflink[=auto] ++//config: default y ++//config: depends on FEATURE_CP_LONG_OPTIONS + + //applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) + /* NOEXEC despite cases when it can be a "runner" (cp -r LARGE_DIR NEW_DIR) */ +@@ -72,10 +77,14 @@ int cp_main(int argc, char **argv) + #if ENABLE_FEATURE_CP_LONG_OPTIONS + /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */ + OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1), ++ OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2), + #endif + }; + + #if ENABLE_FEATURE_CP_LONG_OPTIONS ++# if ENABLE_FEATURE_CP_REFLINK ++ char *reflink = NULL; ++# endif + flags = getopt32long(argv, "^" + FILEUTILS_CP_OPTSTR + "\0" +@@ -99,7 +108,22 @@ int cp_main(int argc, char **argv) + "update\0" No_argument "u" + "remove-destination\0" No_argument "\xff" + "parents\0" No_argument "\xfe" ++# if ENABLE_FEATURE_CP_REFLINK ++ "reflink\0" Optional_argument "\xfd" ++ , &reflink ++# endif + ); ++# if ENABLE_FEATURE_CP_REFLINK ++ BUILD_BUG_ON(OPT_reflink != FILEUTILS_REFLINK); ++ if (flags & FILEUTILS_REFLINK) { ++ if (!reflink) ++ flags |= FILEUTILS_REFLINK_ALWAYS; ++ else if (strcmp(reflink, "always") == 0) ++ flags |= FILEUTILS_REFLINK_ALWAYS; ++ else if (strcmp(reflink, "auto") != 0) ++ bb_show_usage(); ++ } ++# endif + #else + flags = getopt32(argv, "^" + FILEUTILS_CP_OPTSTR +diff --git a/include/libbb.h b/include/libbb.h +index d4ba031df..94caba2bb 100644 +--- a/include/libbb.h ++++ b/include/libbb.h +@@ -410,6 +410,9 @@ enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th + FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 15, /* -c */ + #endif + FILEUTILS_RMDEST = 1 << (16 - !ENABLE_SELINUX), /* --remove-destination */ ++ /* bit 17 skipped for "cp --parents" */ ++ FILEUTILS_REFLINK = 1 << (18 - !ENABLE_SELINUX), /* cp --reflink=auto */ ++ FILEUTILS_REFLINK_ALWAYS = 1 << (19 - !ENABLE_SELINUX), /* cp --reflink[=always] */ + /* + * Hole. cp may have some bits set here, + * they should not affect remove_file()/copy_file() +diff --git a/libbb/copy_file.c b/libbb/copy_file.c +index 1b8befd65..98bd4fe72 100644 +--- a/libbb/copy_file.c ++++ b/libbb/copy_file.c +@@ -339,9 +339,28 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) + freecon(con); + } + } ++#endif ++#if ENABLE_FEATURE_CP_REFLINK ++# undef BTRFS_IOCTL_MAGIC ++# define BTRFS_IOCTL_MAGIC 0x94 ++# undef BTRFS_IOC_CLONE ++# define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int) ++ if (flags & FILEUTILS_REFLINK) { ++ retval = ioctl(dst_fd, BTRFS_IOC_CLONE, src_fd); ++ if (retval == 0) ++ goto do_close; ++ /* reflink did not work */ ++ if (flags & FILEUTILS_REFLINK_ALWAYS) { ++ bb_perror_msg("failed to clone '%s' from '%s'", dest, source); ++ goto do_close; ++ } ++ /* fall through to standard copy */ ++ retval = 0; ++ } + #endif + if (bb_copyfd_eof(src_fd, dst_fd) == -1) + retval = -1; ++ IF_FEATURE_CP_REFLINK(do_close:) + /* Careful with writing... */ + if (close(dst_fd) < 0) { + bb_perror_msg("error writing to '%s'", dest); +-- +2.20.1 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index 9837ffe15d..3b1198579a 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -3,7 +3,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=busybox pkgver=1.29.3 -pkgrel=5 +pkgrel=6 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -34,6 +34,7 @@ source="https://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 0013-testsuite-fix-cpio-tests.patch 0014-miscutils-microcom-Fixed-segfault.patch 0015-ip-print-dadfailed-flag.patch + 0001-cp-optional-reflink-support.patch acpid.logrotate busyboxconfig @@ -210,8 +211,9 @@ f96d66ce5a0295a2459a2c49c281b64e016de675ebd31a49af18cb06f3498fe27dfbc8667324b439 d8926f0e4ed7d2fe5af89ff2a944d781b45b109c9edf1ef2591e7bce2a8bbadd7c8ca814cb3c928ae09027d9603434fe70496f308d701f3d42260ebd1e9e9b29 0013-testsuite-fix-cpio-tests.patch 8cb91903f2be3620b5500a4e8f4190537c93601282510b82303c3b516141b36ab872aeff5a7f5ae00f270439abab862ceabda531bdf180643da165b2f3b35d9f 0014-miscutils-microcom-Fixed-segfault.patch 2fdf01e4bb26a3b6fd7ff73649f15eff599d38db1bc61a699576ec9caae2fb37c49d689baca8b1a3a7b2999fbe04751da897518c2fb42d6f21756b468aa7599d 0015-ip-print-dadfailed-flag.patch +c26e846dc4576a94c376132644ea26755f8cc531fa03b975f2f7e874e2fcbaaca3804ba46849c29b69061b1f411aebedef451418063ec457f88636198dae3be9 0001-cp-optional-reflink-support.patch aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate -8fc1b81f39cb73430ebc9bca8706a71ae82b51efd2fee8ac15b4abe9b0899239075a46234cb7eae58f906c7499d1f75d11b29bcb9ca8dada8b34822df0948e73 busyboxconfig +924ff0dac14b4f7213618bd1503ae1b251fea9c3ce11dd87a6ad23ac4fca9b3f765afefdc50f39613579f56b200547320977ec815f87f2c69e20b5aeb484116c busyboxconfig 1dc5c94708fc4d4129015c0cdd64fbe0edd2794bb10422ac2686db8a4ef06182d306ec89560d0310190c1ed86b8422c13594d2cc2b9281c8895145d5a233cc0c busyboxconfig-extras 0becc2186d6c32fb0c401cf7bc0e46268b38ce8892db33be1daf40273024c1c02d518283f44086a313a2ccef34230a1d945ec148cc173f26e6aa9d88a7426e54 bbsuid.c b993ce589685d5d1f806153d0b7f71657f2d37556654ec60884130a40f09acc4944a13e0a4d02914000bedd779e5a35da08c760fed5f7ca5b601243aff7ba2c9 dad.if-up diff --git a/main/busybox/busyboxconfig b/main/busybox/busyboxconfig index aa26fc8037..72da2cf39d 100644 --- a/main/busybox/busyboxconfig +++ b/main/busybox/busyboxconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.29.2 -# Sat Aug 4 15:10:57 2018 +# Busybox version: 1.29.3 +# Thu Jan 10 14:55:56 2019 # CONFIG_HAVE_DOT_CONFIG=y @@ -205,6 +205,7 @@ CONFIG_CKSUM=y CONFIG_COMM=y CONFIG_CP=y CONFIG_FEATURE_CP_LONG_OPTIONS=y +CONFIG_FEATURE_CP_REFLINK=y CONFIG_CUT=y CONFIG_DATE=y CONFIG_FEATURE_DATE_ISOFMT=y |