summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch')
-rw-r--r--meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch312
1 files changed, 312 insertions, 0 deletions
diff --git a/meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch b/meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch
new file mode 100644
index 0000000000..c212bddf7d
--- /dev/null
+++ b/meta/recipes-extended/cpio/cpio-2.13/0004-Fix-appending-to-archives-bigger-than-2G.patch
@@ -0,0 +1,312 @@
1From 8513495ab5cfb63eb7c4c933fdf0b78c6196cd27 Mon Sep 17 00:00:00 2001
2From: Sergey Poznyakoff <gray@gnu.org>
3Date: Fri, 28 Apr 2023 15:23:46 +0300
4Subject: [PATCH 4/4] Fix appending to archives bigger than 2G
5
6* src/extern.h (last_header_start): Change type to off_t.
7* src/global.c: Likewise.
8* src/util.c (prepare_append): Use off_t for file offsets.
9
10Upstream-Status: Backport [0987d63384f0419b4b14aecdc6a61729b75ce86a]
11Signed-off-by: Marek Vasut <marex@denx.de>
12---
13 src/extern.h | 11 ++++-----
14 src/global.c | 2 +-
15 src/util.c | 66 ++++++++++++++++++++++++++--------------------------
16 3 files changed, 39 insertions(+), 40 deletions(-)
17
18diff --git a/src/extern.h b/src/extern.h
19index 11ac6bf..12f14a9 100644
20--- a/src/extern.h
21+++ b/src/extern.h
22@@ -67,7 +67,7 @@ extern int ignore_devno_option;
23
24 extern bool to_stdout_option;
25
26-extern int last_header_start;
27+extern off_t last_header_start;
28 extern int copy_matching_files;
29 extern int numeric_uid;
30 extern char *pattern_file_name;
31@@ -123,7 +123,7 @@ void field_width_error (const char *filename, const char *fieldname,
32
33 /* copypass.c */
34 void process_copy_pass (void);
35-int link_to_maj_min_ino (char *file_name, int st_dev_maj,
36+int link_to_maj_min_ino (char *file_name, int st_dev_maj,
37 int st_dev_min, ino_t st_ino);
38 int link_to_name (char const *link_name, char const *link_target);
39
40@@ -171,7 +171,7 @@ void copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes);
41 void copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, char *filename);
42 void copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, char *filename);
43 void warn_if_file_changed (char *file_name, off_t old_file_size,
44- time_t old_file_mtime);
45+ time_t old_file_mtime);
46 void create_all_directories (char const *name);
47 void prepare_append (int out_file_des);
48 char *find_inode_file (ino_t node_num,
49@@ -185,7 +185,7 @@ void set_new_media_message (char *message);
50 #ifdef HPUX_CDF
51 char *add_cdf_double_slashes (char *filename);
52 #endif
53-void write_nuls_to_file (off_t num_bytes, int out_des,
54+void write_nuls_to_file (off_t num_bytes, int out_des,
55 void (*writer) (char *in_buf,
56 int out_des, off_t num_bytes));
57 #define DISK_IO_BLOCK_SIZE 512
58@@ -229,6 +229,5 @@ void delay_set_stat (char const *file_name, struct stat *st,
59 mode_t invert_permissions);
60 int repair_delayed_set_stat (struct cpio_file_stat *file_hdr);
61 void apply_delayed_set_stat (void);
62-
63-int arf_stores_inode_p (enum archive_format arf);
64
65+int arf_stores_inode_p (enum archive_format arf);
66diff --git a/src/global.c b/src/global.c
67index fb3abe9..5c9fc05 100644
68--- a/src/global.c
69+++ b/src/global.c
70@@ -114,7 +114,7 @@ int debug_flag = false;
71
72 /* File position of last header read. Only used during -A to determine
73 where the old TRAILER!!! record started. */
74-int last_header_start = 0;
75+off_t last_header_start = 0;
76
77 /* With -i; if true, copy only files that match any of the given patterns;
78 if false, copy only files that do not match any of the patterns. (-f) */
79diff --git a/src/util.c b/src/util.c
80index 4421b20..3be89a4 100644
81--- a/src/util.c
82+++ b/src/util.c
83@@ -60,8 +60,8 @@ tape_empty_output_buffer (int out_des)
84 static long output_bytes_before_lseek = 0;
85
86 /* Some tape drivers seem to have a signed internal seek pointer and
87- they lose if it overflows and becomes negative (e.g. when writing
88- tapes > 2Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
89+ they lose if it overflows and becomes negative (e.g. when writing
90+ tapes > 2Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
91 seek pointer and prevent it from overflowing. */
92 if (output_is_special
93 && ( (output_bytes_before_lseek += output_size) >= 1073741824L) )
94@@ -106,7 +106,7 @@ static ssize_t sparse_write (int fildes, char *buf, size_t nbyte, bool flush);
95 descriptor OUT_DES and reset `output_size' and `out_buff'.
96 If `swapping_halfwords' or `swapping_bytes' is set,
97 do the appropriate swapping first. Our callers have
98- to make sure to only set these flags if `output_size'
99+ to make sure to only set these flags if `output_size'
100 is appropriate (a multiple of 4 for `swapping_halfwords',
101 2 for `swapping_bytes'). The fact that DISK_IO_BLOCK_SIZE
102 must always be a multiple of 4 helps us (and our callers)
103@@ -188,8 +188,8 @@ tape_fill_input_buffer (int in_des, int num_bytes)
104 {
105 #ifdef BROKEN_LONG_TAPE_DRIVER
106 /* Some tape drivers seem to have a signed internal seek pointer and
107- they lose if it overflows and becomes negative (e.g. when writing
108- tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
109+ they lose if it overflows and becomes negative (e.g. when writing
110+ tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
111 seek pointer and prevent it from overflowing. */
112 if (input_is_special
113 && ( (input_bytes_before_lseek += num_bytes) >= 1073741824L) )
114@@ -332,8 +332,8 @@ tape_buffered_peek (char *peek_buf, int in_des, int num_bytes)
115
116 #ifdef BROKEN_LONG_TAPE_DRIVER
117 /* Some tape drivers seem to have a signed internal seek pointer and
118- they lose if it overflows and becomes negative (e.g. when writing
119- tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
120+ they lose if it overflows and becomes negative (e.g. when writing
121+ tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
122 seek pointer and prevent it from overflowing. */
123 if (input_is_special
124 && ( (input_bytes_before_lseek += num_bytes) >= 1073741824L) )
125@@ -404,7 +404,7 @@ tape_toss_input (int in_des, off_t num_bytes)
126
127 if (crc_i_flag && only_verify_crc_flag)
128 {
129- int k;
130+ int k;
131 for (k = 0; k < space_left; ++k)
132 crc += in_buff[k] & 0xff;
133 }
134@@ -416,14 +416,14 @@ tape_toss_input (int in_des, off_t num_bytes)
135 }
136
137 void
138-write_nuls_to_file (off_t num_bytes, int out_des,
139- void (*writer) (char *in_buf, int out_des, off_t num_bytes))
140+write_nuls_to_file (off_t num_bytes, int out_des,
141+ void (*writer) (char *in_buf, int out_des, off_t num_bytes))
142 {
143 off_t blocks;
144 off_t extra_bytes;
145 off_t i;
146 static char zeros_512[512];
147-
148+
149 blocks = num_bytes / sizeof zeros_512;
150 extra_bytes = num_bytes % sizeof zeros_512;
151 for (i = 0; i < blocks; ++i)
152@@ -603,7 +603,7 @@ create_all_directories (char const *name)
153 char *dir;
154
155 dir = dir_name (name);
156-
157+
158 if (dir == NULL)
159 error (PAXEXIT_FAILURE, 0, _("virtual memory exhausted"));
160
161@@ -637,9 +637,9 @@ create_all_directories (char const *name)
162 void
163 prepare_append (int out_file_des)
164 {
165- int start_of_header;
166- int start_of_block;
167- int useful_bytes_in_block;
168+ off_t start_of_header;
169+ off_t start_of_block;
170+ size_t useful_bytes_in_block;
171 char *tmp_buf;
172
173 start_of_header = last_header_start;
174@@ -697,8 +697,8 @@ inode_val_compare (const void *val1, const void *val2)
175 const struct inode_val *ival1 = val1;
176 const struct inode_val *ival2 = val2;
177 return ival1->inode == ival2->inode
178- && ival1->major_num == ival2->major_num
179- && ival1->minor_num == ival2->minor_num;
180+ && ival1->major_num == ival2->major_num
181+ && ival1->minor_num == ival2->minor_num;
182 }
183
184 static struct inode_val *
185@@ -706,10 +706,10 @@ find_inode_val (ino_t node_num, unsigned long major_num,
186 unsigned long minor_num)
187 {
188 struct inode_val sample;
189-
190+
191 if (!hash_table)
192 return NULL;
193-
194+
195 sample.inode = node_num;
196 sample.major_num = major_num;
197 sample.minor_num = minor_num;
198@@ -734,7 +734,7 @@ add_inode (ino_t node_num, char *file_name, unsigned long major_num,
199 {
200 struct inode_val *temp;
201 struct inode_val *e = NULL;
202-
203+
204 /* Create new inode record. */
205 temp = (struct inode_val *) xmalloc (sizeof (struct inode_val));
206 temp->inode = node_num;
207@@ -1007,7 +1007,7 @@ buf_all_zeros (char *buf, int bufsize)
208
209 /* Write NBYTE bytes from BUF to file descriptor FILDES, trying to
210 create holes instead of writing blockfuls of zeros.
211-
212+
213 Return the number of bytes written (including bytes in zero
214 regions) on success, -1 on error.
215
216@@ -1027,7 +1027,7 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
217
218 enum { begin, in_zeros, not_in_zeros } state =
219 delayed_seek_count ? in_zeros : begin;
220-
221+
222 while (nbytes)
223 {
224 size_t rest = nbytes;
225@@ -1042,7 +1042,7 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
226 if (state == not_in_zeros)
227 {
228 ssize_t bytes = buf - start_ptr + rest;
229-
230+
231 n = write (fildes, start_ptr, bytes);
232 if (n == -1)
233 return -1;
234@@ -1091,8 +1091,8 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
235 if (n != 1)
236 return n;
237 delayed_seek_count = 0;
238- }
239-
240+ }
241+
242 return nwritten + seek_count;
243 }
244
245@@ -1222,7 +1222,7 @@ set_perms (int fd, struct cpio_file_stat *header)
246 if (!no_chown_flag)
247 {
248 uid_t uid = CPIO_UID (header->c_uid);
249- gid_t gid = CPIO_GID (header->c_gid);
250+ gid_t gid = CPIO_GID (header->c_gid);
251 if ((fchown_or_chown (fd, header->c_name, uid, gid) < 0)
252 && errno != EPERM)
253 chown_error_details (header->c_name, uid, gid);
254@@ -1239,13 +1239,13 @@ set_file_times (int fd,
255 const char *name, unsigned long atime, unsigned long mtime)
256 {
257 struct timespec ts[2];
258-
259+
260 memset (&ts, 0, sizeof ts);
261
262 ts[0].tv_sec = atime;
263 ts[1].tv_sec = mtime;
264
265- /* Silently ignore EROFS because reading the file won't have upset its
266+ /* Silently ignore EROFS because reading the file won't have upset its
267 timestamp if it's on a read-only filesystem. */
268 if (fdutimens (fd, name, ts) < 0 && errno != EROFS)
269 utime_error (name);
270@@ -1297,7 +1297,7 @@ cpio_safer_name_suffix (char *name, bool link_target, bool absolute_names,
271
272 /* This is a simplified form of delayed set_stat used by GNU tar.
273 With the time, both forms will merge and pass to paxutils
274-
275+
276 List of directories whose statuses we need to extract after we've
277 finished extracting their subsidiary files. If you consider each
278 contiguous subsequence of elements of the form [D]?[^D]*, where [D]
279@@ -1415,7 +1415,7 @@ cpio_mkdir (struct cpio_file_stat *file_hdr, int *setstat_delayed)
280 {
281 int rc;
282 mode_t mode = file_hdr->c_mode;
283-
284+
285 if (!(file_hdr->c_mode & S_IWUSR))
286 {
287 rc = mkdir (file_hdr->c_name, mode | S_IWUSR);
288@@ -1438,10 +1438,10 @@ cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir)
289 {
290 int res; /* Result of various function calls. */
291 int setstat_delayed = 0;
292-
293+
294 if (to_stdout_option)
295 return 0;
296-
297+
298 /* Strip any trailing `/'s off the filename; tar puts
299 them on. We might as well do it here in case anybody
300 else does too, since they cause strange things to happen. */
301@@ -1530,7 +1530,7 @@ arf_stores_inode_p (enum archive_format arf)
302 }
303 return 1;
304 }
305-
306+
307 void
308 cpio_file_stat_init (struct cpio_file_stat *file_hdr)
309 {
310--
3112.39.2
312