gnu: Add cdrtools.
[jackhill/guix/guix.git] / gnu / packages / patches / cdrtools-3.01-mkisofs-isoinfo.patch
CommitLineData
ded59665
TD
1Patch for version 3.01, taken from upstream at
2https://sourceforge.net/projects/cdrtools/files/cdrtools-3.01-fix-20151126-mkisofs-isoinfo.patch
3
4--- cdrtools-3.01.orig/mkisofs/diag/isoinfo.c 2015-07-22 20:36:45.000000000 +0000
5+++ cdrtools-3.01/mkisofs/diag/isoinfo.c 2015-11-17 19:35:40.000000000 +0000
6@@ -1,8 +1,8 @@
7-/* @(#)isoinfo.c 1.95 15/07/22 joerg */
8+/* @(#)isoinfo.c 1.100 15/11/17 joerg */
9 #include <schily/mconfig.h>
10 #ifndef lint
11 static UConst char sccsid[] =
12- "@(#)isoinfo.c 1.95 15/07/22 joerg";
13+ "@(#)isoinfo.c 1.100 15/11/17 joerg";
14 #endif
15 /*
16 * File isodump.c - dump iso9660 directory information.
17@@ -148,8 +148,10 @@ LOCAL char er_id[256];
18 LOCAL int su_version = 0;
19 LOCAL int rr_version = 0;
20 LOCAL int aa_version = 0;
21+LOCAL int cl_extent = 0;
22 LOCAL int ucs_level = 0;
23 LOCAL BOOL iso9660_inodes = FALSE;
24+LOCAL uid_t myuid;
25
26 #ifdef USE_FIND
27 LOCAL findn_t *find_node; /* syntaxtree from find_parse() */
28@@ -208,6 +210,9 @@ LOCAL void extract __PR((char *rootname
29 LOCAL void extract_file __PR((int f,
30 struct iso_directory_record * idr,
31 char *fname));
32+LOCAL void parse_cl_dir __PR((struct iso_directory_record *idr,
33+ int extent));
34+LOCAL BOOL parse_de __PR((struct iso_directory_record *idr));
35 LOCAL void parse_dir __PR((char * rootname, int extent, int len));
36 LOCAL void usage __PR((int excode));
37 EXPORT int main __PR((int argc, char *argv[]));
38@@ -459,7 +464,6 @@ parse_rr(pnt, len, cont_flag)
39 int slen;
40 int xlen;
41 int ncount;
42- int cl_extent;
43 int pl_extent;
44 int cont_extent, cont_offset, cont_size;
45 int flag1, flag2;
46@@ -469,7 +473,7 @@ parse_rr(pnt, len, cont_flag)
47
48 symlinkname[0] = 0;
49
50- cont_extent = cont_offset = cont_size = 0;
51+ cl_extent = cont_extent = cont_offset = cont_size = 0;
52
53 ncount = 0;
54 flag1 = -1;
55@@ -714,6 +718,7 @@ struct todo
56 };
57
58 LOCAL struct todo *todo_idr = NULL;
59+LOCAL struct todo **todo_pp = &todo_idr;
60
61 LOCAL char *months[12] = {"Jan", "Feb", "Mar", "Apr",
62 "May", "Jun", "Jul",
63@@ -962,8 +967,14 @@ static BOOL isfirst = TRUE;
64 close(f);
65 return;
66 setmode:
67- fchmodat(AT_FDCWD, fname, fstat_buf.st_mode, AT_SYMLINK_NOFOLLOW);
68 fchownat(AT_FDCWD, fname, fstat_buf.st_uid, fstat_buf.st_gid, AT_SYMLINK_NOFOLLOW);
69+ if (myuid != 0 && S_ISDIR(fstat_buf.st_mode)) {
70+ /*
71+ * Temporary hack until we have a dirstack like star.
72+ */
73+ fstat_buf.st_mode |= S_IWUSR;
74+ }
75+ fchmodat(AT_FDCWD, fname, fstat_buf.st_mode, AT_SYMLINK_NOFOLLOW);
76 times[0].tv_sec = fstat_buf.st_atime;
77 times[0].tv_nsec = stat_ansecs(&fstat_buf);
78 times[1].tv_sec = fstat_buf.st_mtime;
79@@ -1001,6 +1012,143 @@ extract_file(f, idr, fname)
80 }
81 }
82
83+
84+LOCAL void
85+parse_cl_dir(idr, extent)
86+ struct iso_directory_record *idr;
87+ int extent;
88+{
89+ char cl_name_buf[256*3];
90+
91+ strlcpy(cl_name_buf, name_buf, sizeof (cl_name_buf));
92+#ifdef USE_SCG
93+ readsecs(extent - sector_offset, idr, 1);
94+#else
95+ lseek(fileno(infile), ((off_t)(extent - sector_offset)) << 11, SEEK_SET);
96+ read(fileno(infile), idr, 2048);
97+#endif
98+
99+ if (parse_de(idr) && use_rock)
100+ dump_rr(idr);
101+ strlcpy(name_buf, cl_name_buf, sizeof (name_buf));
102+}
103+
104+LOCAL BOOL
105+parse_de(idr)
106+ struct iso_directory_record *idr;
107+{
108+ unsigned char uc;
109+
110+ if (idr->length[0] == 0)
111+ return (FALSE);
112+ memset(&fstat_buf, 0, sizeof (fstat_buf));
113+ found_rr = 0;
114+ name_buf[0] = xname[0] = 0;
115+ fstat_buf.st_size = (off_t)(unsigned)isonum_733((unsigned char *)idr->size);
116+ if (idr->flags[0] & 2)
117+ fstat_buf.st_mode |= S_IFDIR;
118+ else
119+ fstat_buf.st_mode |= S_IFREG;
120+ if (idr->name_len[0] == 1 && idr->name[0] == 0)
121+ strcpy(name_buf, ".");
122+ else if (idr->name_len[0] == 1 && idr->name[0] == 1)
123+ strcpy(name_buf, "..");
124+ else {
125+ switch (ucs_level) {
126+ case 3:
127+ case 2:
128+ case 1:
129+ /*
130+ * Unicode name. Convert as best we can.
131+ */
132+ {
133+ int j;
134+ name_buf[0] = '\0';
135+#ifdef USE_ICONV
136+ if (use_iconv(unls)) {
137+ int u;
138+ char *to = name_buf;
139+
140+ for (j = 0, u = 0; j < (int)idr->name_len[0] / 2; j++) {
141+ char *ibuf = (char *)&idr->name[j*2];
142+ size_t isize = 2; /* UCS-2 character size */
143+ size_t osize = 4;
144+
145+ if (iconv(unls->sic_uni2cd, (__IC_CONST char **)&ibuf, &isize,
146+ (char **)&to, &osize) == -1) {
147+ int err = geterrno();
148+
149+ if ((err == EINVAL || err == EILSEQ) &&
150+ osize == 4) {
151+ *to = '_';
152+ u += 1;
153+ to++;
154+ }
155+ } else {
156+ u += 4 - osize;
157+ to = &name_buf[u];
158+ }
159+ }
160+ j = u;
161+ } else
162+#endif
163+ for (j = 0; j < (int)idr->name_len[0] / 2; j++) {
164+ UInt16_t unichar;
165+
166+ unichar = (idr->name[j*2] & 0xFF) * 256 +
167+ (idr->name[j*2+1] & 0xFF);
168+
169+ /*
170+ * Get the backconverted char
171+ */
172+ if (unls)
173+ uc = sic_uni2c(unls, unichar);
174+ else
175+ uc = unichar > 255 ? '_' : unichar;
176+
177+ name_buf[j] = uc ? uc : '_';
178+ }
179+ name_buf[j] = '\0';
180+ }
181+ break;
182+ case 0:
183+ /*
184+ * Normal non-Unicode name.
185+ */
186+ strncpy(name_buf, idr->name, idr->name_len[0]);
187+ name_buf[idr->name_len[0]] = 0;
188+ break;
189+ default:
190+ /*
191+ * Don't know how to do these yet. Maybe they are the same
192+ * as one of the above.
193+ */
194+ exit(1);
195+ }
196+ }
197+ memcpy(date_buf, idr->date, 9);
198+ /*
199+ * Always first set up time stamps and file modes from
200+ * ISO-9660. This is used as a fallback in case that
201+ * there is no related Rock Ridge based data.
202+ */
203+ fstat_buf.st_atime =
204+ fstat_buf.st_mtime =
205+ fstat_buf.st_ctime = iso9660_time(date_buf, NULL, FALSE);
206+ fstat_buf.st_mode |= S_IRUSR|S_IXUSR |
207+ S_IRGRP|S_IXGRP |
208+ S_IROTH|S_IXOTH;
209+ fstat_buf.st_nlink = 1;
210+ fstat_buf.st_ino = 0;
211+ fstat_buf.st_uid = 0;
212+ fstat_buf.st_gid = 0;
213+ if (iso9660_inodes) {
214+ fstat_buf.st_ino = (unsigned long)
215+ isonum_733((unsigned char *)idr->extent);
216+ }
217+ return (TRUE);
218+}
219+
220 LOCAL void
221 parse_dir(rootname, extent, len)
222 char *rootname;
223@@ -1012,12 +1160,13 @@ parse_dir(rootname, extent, len)
224 struct iso_directory_record * idr;
225 struct iso_directory_record didr;
226 struct stat dstat;
227- unsigned char uc;
228+ unsigned char cl_buffer[2048];
229 unsigned char flags = 0;
230 Llong size = 0;
231 int sextent = 0;
232 int rlen;
233 int blen;
234+ int rr_flags = 0;
235 static char *n = 0;
236 static int nlen = 0;
237
238@@ -1039,115 +1188,23 @@ static int nlen = 0;
239 i = 0;
240 while (1 == 1) {
241 idr = (struct iso_directory_record *) &buffer[i];
242- if (idr->length[0] == 0) break;
243- memset(&fstat_buf, 0, sizeof (fstat_buf));
244- found_rr = 0;
245- name_buf[0] = xname[0] = 0;
246- fstat_buf.st_size = (off_t)(unsigned)isonum_733((unsigned char *)idr->size);
247- if (idr->flags[0] & 2)
248- fstat_buf.st_mode |= S_IFDIR;
249- else
250- fstat_buf.st_mode |= S_IFREG;
251- if (idr->name_len[0] == 1 && idr->name[0] == 0)
252- strcpy(name_buf, ".");
253- else if (idr->name_len[0] == 1 && idr->name[0] == 1)
254- strcpy(name_buf, "..");
255- else {
256- switch (ucs_level) {
257- case 3:
258- case 2:
259- case 1:
260- /*
261- * Unicode name. Convert as best we can.
262- */
263- {
264- int j;
265-
266- name_buf[0] = '\0';
267-#ifdef USE_ICONV
268- if (use_iconv(unls)) {
269- int u;
270- char *to = name_buf;
271-
272- for (j = 0, u = 0; j < (int)idr->name_len[0] / 2; j++) {
273- char *ibuf = (char *)&idr->name[j*2];
274- size_t isize = 2; /* UCS-2 character size */
275- size_t osize = 4;
276-
277- if (iconv(unls->sic_uni2cd, (__IC_CONST char **)&ibuf, &isize,
278- (char **)&to, &osize) == -1) {
279- int err = geterrno();
280-
281- if ((err == EINVAL || err == EILSEQ) &&
282- osize == 4) {
283- *to = '_';
284- u += 1;
285- to++;
286- }
287- } else {
288- u += 4 - osize;
289- to = &name_buf[u];
290- }
291- }
292- j = u;
293- } else
294-#endif
295- for (j = 0; j < (int)idr->name_len[0] / 2; j++) {
296- UInt16_t unichar;
297-
298- unichar = (idr->name[j*2] & 0xFF) * 256 +
299- (idr->name[j*2+1] & 0xFF);
300-
301- /*
302- * Get the backconverted char
303- */
304- if (unls)
305- uc = sic_uni2c(unls, unichar);
306- else
307- uc = unichar > 255 ? '_' : unichar;
308+ if (idr->length[0] == 0)
309+ break;
310+ parse_de(idr);
311+ if (use_rock) {
312+ rr_flags = dump_rr(idr);
313
314- name_buf[j] = uc ? uc : '_';
315- }
316- name_buf[j] = '\0';
317- }
318- break;
319- case 0:
320+ if (rr_flags & RR_FLAG_CL) {
321 /*
322- * Normal non-Unicode name.
323+ * Need to reparse the child link
324+ * but note that we parse "CL/."
325+ * so we get no usable file name.
326 */
327- strncpy(name_buf, idr->name, idr->name_len[0]);
328- name_buf[idr->name_len[0]] = 0;
329- break;
330- default:
331- /*
332- * Don't know how to do these yet. Maybe they are the same
333- * as one of the above.
334- */
335- exit(1);
336- }
337+ idr = (struct iso_directory_record *) cl_buffer;
338+ parse_cl_dir(idr, cl_extent);
339+ } else if (rr_flags & RR_FLAG_RE)
340+ goto cont; /* skip rr_moved */
341 }
342- memcpy(date_buf, idr->date, 9);
343- /*
344- * Always first set up time stamps and file modes from
345- * ISO-9660. This is used as a fallback in case that
346- * there is no related Rock Ridge based data.
347- */
348- fstat_buf.st_atime =
349- fstat_buf.st_mtime =
350- fstat_buf.st_ctime = iso9660_time(date_buf, NULL, FALSE);
351- fstat_buf.st_mode |= S_IRUSR|S_IXUSR |
352- S_IRGRP|S_IXGRP |
353- S_IROTH|S_IXOTH;
354- fstat_buf.st_nlink = 1;
355- fstat_buf.st_ino = 0;
356- fstat_buf.st_uid = 0;
357- fstat_buf.st_gid = 0;
358- if (iso9660_inodes) {
359- fstat_buf.st_ino = (unsigned long)
360- isonum_733((unsigned char *)idr->extent);
361- }
362- if (use_rock)
363- dump_rr(idr);
364 if (Xtract &&
365 (idr->flags[0] & 2) != 0 &&
366 idr->name_len[0] == 1 &&
367@@ -1170,30 +1227,30 @@ static int nlen = 0;
368 n[rlen] = '\0';
369
370 if ((idr->flags[0] & 2) != 0 &&
371- (idr->name_len[0] != 1 ||
372+ ((rr_flags & RR_FLAG_CL) ||
373+ idr->name_len[0] != 1 ||
374 (idr->name[0] != 0 && idr->name[0] != 1))) {
375 /*
376 * This is a plain directory (neither "xxx/."
377 * nor "xxx/..").
378 * Add this directory to the todo list.
379 */
380- td = todo_idr;
381- if (td != NULL) {
382- while (td->next != NULL)
383- td = td->next;
384- td->next = (struct todo *) malloc(sizeof (*td));
385- td = td->next;
386- } else {
387- todo_idr = td = (struct todo *) malloc(sizeof (*td));
388- }
389+ td = (struct todo *) malloc(sizeof (*td));
390+ if (td == NULL)
391+ comerr(_("No memory.\n"));
392 td->next = NULL;
393 td->extent = isonum_733((unsigned char *)idr->extent);
394 td->length = isonum_733((unsigned char *)idr->size);
395 td->name = (char *) malloc(strlen(rootname)
396 + strlen(name_buf) + 2);
397+ if (td->name == NULL)
398+ comerr(_("No memory.\n"));
399 strcpy(td->name, rootname);
400 strcat(td->name, name_buf);
401 strcat(td->name, "/");
402+
403+ *todo_pp = td;
404+ todo_pp = &td->next;
405 } else {
406 if (xtract && strcmp(xtract, n) == 0) {
407 extract_file(STDOUT_FILENO, idr, "stdout");
408@@ -1253,6 +1310,7 @@ static int nlen = 0;
409 if ((idr->flags[0] & ISO_MULTIEXTENT) == 0)
410 size = 0;
411 }
412+ cont:
413 i += buffer[i];
414 if (i > 2048 - offsetof(struct iso_directory_record, name[0])) break;
415 }
416@@ -1381,12 +1439,13 @@ main(argc, argv)
417 usage(0);
418 if (prvers) {
419 printf(_("isoinfo %s (%s-%s-%s) Copyright (C) 1993-1999 %s (C) 1999-2015 %s\n"),
420- VERSION,
421+ "3.02a02",
422 HOST_CPU, HOST_VENDOR, HOST_OS,
423 _("Eric Youngdale"),
424 _("Joerg Schilling"));
425 exit(0);
426 }
427+ myuid = getuid();
428 #ifdef USE_FIND
429 if (do_find) {
430 finda_t fa;
431--- cdrtools-3.01.orig/mkisofs/udf.c 2013-04-24 20:45:18.000000000 +0000
432+++ cdrtools-3.01/mkisofs/udf.c 2015-11-25 22:07:30.000000000 +0000
433@@ -1,15 +1,15 @@
434-/* @(#)udf.c 1.42 13/04/24 Copyright 2001-2013 J. Schilling */
435+/* @(#)udf.c 1.43 15/11/25 Copyright 2001-2015 J. Schilling */
436 #include <schily/mconfig.h>
437 #ifndef lint
438 static UConst char sccsid[] =
439- "@(#)udf.c 1.42 13/04/24 Copyright 2001-2013 J. Schilling";
440+ "@(#)udf.c 1.43 15/11/25 Copyright 2001-2015 J. Schilling";
441 #endif
442 /*
443 * udf.c - UDF support for mkisofs
444 *
445 * Written by Ben Rudiak-Gould (2001).
446 *
447- * Copyright 2001-2013 J. Schilling.
448+ * Copyright 2001-2015 J. Schilling.
449 */
450 /*
451 * This program is free software; you can redistribute it and/or modify
452@@ -98,7 +98,7 @@ static UConst char sccsid[] =
453 extern int use_sparcboot;
454
455 extern struct directory *root;
456-extern time_t begun;
457+extern struct timeval tv_begun;
458
459 static unsigned lba_main_seq;
460 static unsigned lba_main_seq_copy;
461@@ -110,7 +110,7 @@ static unsigned lba_end_anchor_vol_desc;
462 static unsigned num_udf_files;
463 static unsigned num_udf_directories;
464
465-static unsigned volume_set_id[2];
466+static unsigned volume_set_id[2] = { 0, 0 };
467
468 #define UDF_MAIN_SEQ_LENGTH (16)
469 #define UDF_INTEG_SEQ_LENGTH (2)
470@@ -723,7 +723,7 @@ set_primary_vol_desc(buf, lba)
471 /*pvd->volume_abstract;*/
472 /*pvd->volume_copyright_notice;*/
473 /*pvd->application_ident;*/
474- set_timestamp_from_time_t(&pvd->recording_date_and_time, begun);
475+ set_timestamp_from_time_t(&pvd->recording_date_and_time, tv_begun.tv_sec);
476 set_impl_ident(&pvd->impl_ident);
477 set_tag(&pvd->desc_tag, UDF_TAGID_PRIMARY_VOLUME_DESC, lba, 512);
478 }
479@@ -831,7 +831,7 @@ set_logical_vol_integrity_desc(buf, lba)
480 udf_logical_volume_integrity_desc *lvid =
481 (udf_logical_volume_integrity_desc *)buf;
482
483- set_timestamp_from_time_t(&lvid->recording_date, begun);
484+ set_timestamp_from_time_t(&lvid->recording_date, tv_begun.tv_sec);
485 set32(&lvid->integrity_type, UDF_INTEGRITY_TYPE_CLOSE);
486 /*lvid->next_integrity_extent;*/
487 set64(&lvid->logical_volume_contents_use.unique_id,
488@@ -859,7 +859,7 @@ set_file_set_desc(buf, rba)
489 {
490 udf_file_set_desc *fsd = (udf_file_set_desc *)buf;
491
492- set_timestamp_from_time_t(&fsd->recording_date_and_time, begun);
493+ set_timestamp_from_time_t(&fsd->recording_date_and_time, tv_begun.tv_sec);
494 set16(&fsd->interchange_level, 3);
495 set16(&fsd->maximum_interchange_level, 3);
496 set32(&fsd->character_set_list, 1);
497@@ -1986,8 +1986,10 @@ udf_main_seq_write(out)
498 * volume_set_id needs to be set to a (64-bit) "unique" number.
499 * This will have to do for now.
500 */
501- volume_set_id[0] = begun;
502- volume_set_id[1] = (unsigned)clock(); /* XXX Maybe non-portable */
503+ if (volume_set_id[0] == 0) {
504+ volume_set_id[0] = tv_begun.tv_sec;
505+ volume_set_id[1] = (unsigned)tv_begun.tv_usec;
506+ }
507
508 memset(buf, 0, sizeof (buf));
509 set_primary_vol_desc(buf, last_extent_written++);
510--- cdrtools-3.01.orig/mkisofs/mkisofs.c 2015-01-01 14:19:51.000000000 +0000
511+++ cdrtools-3.01/mkisofs/mkisofs.c
512@@ -69 +69 @@ int path_ind;
513-char version_string[] = VERSION;
514+char version_string[] = "3.01-fix-20151126";