* added the Unlicense as valid in misc/share/REGISTER
[t2sde.git] / package / archiver / mine / short-reads.patch
blob8d755bb383b499ca070d9d048030d2b1d521ef7e
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/mine/short-reads.patch
3 # Copyright (C) 2021 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 Musl returns short reads for pipes, so deal with that.
15 Also increase the buffer size to 4k for a little better
16 performance while at it.
18 --- mine-0.23/install.c.vanilla 2021-10-15 22:38:22.519423662 +0200
19 +++ mine-0.23/install.c 2021-10-15 22:51:39.237464764 +0200
20 @@ -60,7 +60,7 @@
22 char *filename = 0;
23 char *decompressor = 0;
24 - char buffer[1024];
25 + char buffer[4*1024];
26 char buffer2[1024];
27 char buffer3[1024];
28 TAR *t = NULL;
29 @@ -183,7 +183,7 @@
30 if ( ! mode_force )
31 md5sum_initdb(root, mode_verbose);
33 - if (tar_fdopen(&t, bunzip2tar[0], "pipe", NULL,
34 + if (tar_fdopen(&t, bunzip2tar[0], "-", NULL,
35 O_RDONLY, 0, 0) == -1) goto error_errno;
36 if ( mode_test && mode_verbose ) printf("-- %s --\n", pname);
38 --- mine-0.23/libtar-1.2.11/lib/handle.c.vanilla 2021-10-15 23:47:57.270639034 +0200
39 +++ mine-0.23/libtar-1.2.11/lib/handle.c 2021-10-15 23:55:00.511660869 +0200
40 @@ -27,7 +27,23 @@
42 const char libtar_version[] = PACKAGE_VERSION;
44 -static tartype_t default_type = { open, close, read, write };
45 +ssize_t readfn(int fd, void* _buf, size_t n) {
46 + char* buf = (char*)_buf;
47 + ssize_t off = 0, ret;
48 + while (off < n) {
49 + ret = read(fd, buf + off, n - off);
50 + if (ret > 0) {
51 + off += ret;
52 + } else {
53 + if (off == 0)
54 + off = ret;
55 + break;
56 + }
57 + }
58 + return off;
61 +static tartype_t default_type = { open, close, readfn, write };
64 static int