|
1 --- cdrtools-3.00/mkisofs/mkisofs.c.orig Tue Jun 28 15:31:06 2011 |
|
2 +++ cdrtools-3.00/mkisofs/mkisofs.c Tue Jun 28 15:32:46 2011 |
|
3 @@ -66,7 +66,7 @@ |
|
4 struct directory *root = NULL; |
|
5 int path_ind; |
|
6 |
|
7 -char version_string[] = VERSION; |
|
8 +char version_string[] = VERSION "+eltorito-platform"; |
|
9 |
|
10 char *outfile; |
|
11 FILE *discimage; |
|
12 @@ -110,6 +110,8 @@ |
|
13 int osecsize = 0; /* Output-sector size, 0 means default secsize 2048 */ |
|
14 int use_Joliet = 0; |
|
15 int jlen = JMAX; /* maximum Joliet file name length */ |
|
16 + |
|
17 +int def_platid = EL_TORITO_ARCH_x86; |
|
18 /* |
|
19 * Verbose levels currently used: |
|
20 * |
|
21 @@ -182,6 +184,7 @@ |
|
22 int help; /* CLI Parameter for -help option */ |
|
23 int joliet_long; /* CLI Parameter for -joliet-long option */ |
|
24 char *jcharset; /* CLI Parameter for -jcharset option */ |
|
25 +char *modification_date; /* CLI Parameter for -modification-date */ |
|
26 int max_filenames; /* CLI Parameter for -max-iso9660-filenames option */ |
|
27 char *log_file; /* CLI Parameter for -log-file option */ |
|
28 char *dir_mode_str; /* CLI Parameter for -new-dir-mode option */ |
|
29 @@ -446,7 +449,374 @@ |
|
30 return (1); |
|
31 } |
|
32 |
|
33 +#define IS_SEPARATOR1(c) (c == '/' || c == '-') |
|
34 + |
|
35 +LOCAL boolean_t |
|
36 +isalldigits(char *p, int n) |
|
37 +{ |
|
38 + int i; |
|
39 + if (p == NULL) |
|
40 + return (B_FALSE); |
|
41 + for (i = 0; i < n; i++) { |
|
42 + if (p[i] == 0) |
|
43 + return (B_FALSE); |
|
44 + if ((p[i] < '0') || (p[i] > '9')) |
|
45 + return (B_FALSE); |
|
46 + } |
|
47 + return (B_TRUE); |
|
48 +} |
|
49 + |
|
50 +LOCAL char * |
|
51 +findnextsep(char *p, char *matches) |
|
52 +{ |
|
53 + char *mp; |
|
54 + while (*p) { |
|
55 + if (matches == NULL) { |
|
56 + if ((*p < '0') || (*p > '9')) |
|
57 + return (p); |
|
58 + } else { |
|
59 + mp = matches; |
|
60 + while (*mp) { |
|
61 + if (*mp == *p) |
|
62 + return (p); |
|
63 + mp++; |
|
64 + } |
|
65 + } |
|
66 + p++; |
|
67 + } |
|
68 + if (*p == NULL) |
|
69 + return (NULL); |
|
70 + return (p); |
|
71 +} |
|
72 + |
|
73 +LOCAL boolean_t |
|
74 +check_n_get_val(char *s, int n, long *val, int checklower, long lower, |
|
75 +int checkupper, long upper) |
|
76 +{ |
|
77 + char c; |
|
78 + long l; |
|
79 + |
|
80 + if (isalldigits(s, n) != B_TRUE) |
|
81 + return (B_FALSE); |
|
82 + |
|
83 + if (n > 20) |
|
84 + return (B_FALSE); |
|
85 + |
|
86 + c = *(s+n); |
|
87 + *(s + n) = 0; |
|
88 + |
|
89 + errno = 0; |
|
90 + l = strtol(s, NULL, 10); |
|
91 + |
|
92 + *(s+n) = c; |
|
93 + |
|
94 + if (errno) |
|
95 + return (B_FALSE); |
|
96 + |
|
97 + if (val != NULL) |
|
98 + *val = l; |
|
99 + |
|
100 + if (checklower) |
|
101 + if (l < lower) |
|
102 + return (B_FALSE); |
|
103 + if (checkupper) |
|
104 + if (l > upper) |
|
105 + return (B_FALSE); |
|
106 + |
|
107 + return (B_TRUE); |
|
108 +} |
|
109 + |
|
110 LOCAL int |
|
111 +get_gmt() |
|
112 +{ |
|
113 + time_t now; |
|
114 + struct tm gmt, *gmp, *localp, localt; |
|
115 + time_t gmtoffsetsec = 0; |
|
116 + |
|
117 + now = time(NULL); |
|
118 + if (now == -1) |
|
119 + comerrno(EX_BAD, "time failed internal error\n"); |
|
120 + |
|
121 + localp = localtime(&now); |
|
122 + if (localp == NULL) |
|
123 + comerrno(EX_BAD, "localtime failed internal error\n"); |
|
124 + |
|
125 + localt = *localp; |
|
126 + |
|
127 + gmp = gmtime(&now); |
|
128 + if (gmp == NULL) |
|
129 + comerrno(EX_BAD, "gmtime failed internal error\n"); |
|
130 + |
|
131 + gmt = *gmp; |
|
132 + |
|
133 + gmtoffsetsec = mktime(&localt) - mktime(&gmt); |
|
134 + |
|
135 + return ((int)(gmtoffsetsec /(60 * 15))); |
|
136 +} |
|
137 + |
|
138 + |
|
139 + |
|
140 +char modbuf[18]; |
|
141 +LOCAL int |
|
142 +get_modification_date(opt_arg) |
|
143 + char *opt_arg; |
|
144 +{ |
|
145 + int len; |
|
146 + char *optp = opt_arg; |
|
147 + char *dotp = NULL; |
|
148 + char *signp = NULL; |
|
149 + char *bufp = modbuf; |
|
150 + char *tmpp = NULL; |
|
151 + char *default_mod = "00010101000000000"; |
|
152 + char tmpstr[5]; |
|
153 + int gmtset = 0; |
|
154 + |
|
155 + strncpy(modbuf, default_mod, 17); |
|
156 + modbuf[17] = 0; |
|
157 + |
|
158 + |
|
159 + len = strlen(opt_arg); |
|
160 + |
|
161 + /* first find the gmt */ |
|
162 + tmpp = strrchr(optp, '+'); |
|
163 + |
|
164 + if (tmpp != NULL || ((tmpp = strrchr(optp, '-')) != NULL)) { |
|
165 + /* it has to be the last 4 digits */ |
|
166 + if ((tmpp - optp) != (len - 5)) { |
|
167 + if (*tmpp == '+') |
|
168 + comerrno(EX_BAD, "Bad modification date\n"); |
|
169 + /* if '-' take it as a separator */ |
|
170 + } else { |
|
171 + long gh, gm, val; |
|
172 + if (check_n_get_val(tmpp + 1, 2, &gh, 0, 0, 0, 0) |
|
173 + != B_TRUE) |
|
174 + comerrno(EX_BAD, "Bad modification date:gh\n"); |
|
175 + |
|
176 + if (check_n_get_val(tmpp + 3, 2, &gm, 0, 0, 0, 0) |
|
177 + != B_TRUE) |
|
178 + comerrno(EX_BAD, "Bad modification date:gm\n"); |
|
179 + |
|
180 + val = (((gh * 60) + gm) / 15) * |
|
181 + ((*tmpp == '-') ? -1 : 1); |
|
182 + |
|
183 + |
|
184 + if (val < -48 || val > 52) |
|
185 + comerrno(EX_BAD, "Bad modification date:" |
|
186 + " gmt offset\n"); |
|
187 + modbuf[16] = val; |
|
188 + gmtset = 1; |
|
189 + |
|
190 + /* get rid of gmt in input str, we are done with it */ |
|
191 + *tmpp = 0; |
|
192 + } |
|
193 + } |
|
194 + if (gmtset == 0) { |
|
195 + modbuf[16] = get_gmt(); |
|
196 + } |
|
197 + |
|
198 + len = strlen(optp); |
|
199 + |
|
200 + if ((tmpp = strrchr(optp, '.')) != NULL) { |
|
201 + |
|
202 + if ((tmpp - optp) != (len - 3)) { |
|
203 + comerrno(EX_BAD, "Bad modification date:hundredth " |
|
204 + "of sec\n"); |
|
205 + } |
|
206 + |
|
207 + if (check_n_get_val(tmpp + 1, 2, NULL, 0, 0, 0, 0) != B_TRUE) |
|
208 + comerrno(EX_BAD, "Bad modification date:hundredth of" |
|
209 + " second length\n"); |
|
210 + |
|
211 + /* since all digits, can not be > 99 */ |
|
212 + modbuf[14] = *(tmpp + 1); |
|
213 + modbuf[15] = *(tmpp + 2); |
|
214 + |
|
215 + /* get rid of hh in input str, we are done with it */ |
|
216 + *tmpp = 0; |
|
217 + } |
|
218 + |
|
219 + tmpp = findnextsep(optp, "/-"); |
|
220 + |
|
221 + if (tmpp) { |
|
222 + if (tmpp - optp == 2) { |
|
223 + long year; |
|
224 + /* 2 digit year YY- */ |
|
225 + if (check_n_get_val(optp, 2, &year, 0, 0, 0, 0) |
|
226 + != B_TRUE) |
|
227 + comerrno(EX_BAD, "Bad modification date:year" |
|
228 + "length \n"); |
|
229 + /* 69-99 1969-1999, 00-68 2000 to 2068 */ |
|
230 + if (year > 68) |
|
231 + strncpy(bufp, "19", 2); |
|
232 + else |
|
233 + strncpy(bufp, "20", 2); |
|
234 + bufp += 2; |
|
235 + strncpy(bufp, optp, 2); |
|
236 + bufp += 2; |
|
237 + optp = tmpp + 1; |
|
238 + |
|
239 + } else if (tmpp - optp == 4) { |
|
240 + long year; |
|
241 + |
|
242 + /* 4 digit year YYYY- */ |
|
243 + if (check_n_get_val(optp, 4, &year, 1, 1, 0, 0) |
|
244 + != B_TRUE) |
|
245 + comerrno(EX_BAD, "Bad modification date:" |
|
246 + "year\n"); |
|
247 + strncpy(bufp, optp, 4); |
|
248 + bufp += 4; |
|
249 + optp = tmpp + 1; |
|
250 + |
|
251 + } else if (tmpp - optp == 6) { |
|
252 + /* YYYYMM- */ |
|
253 + long year; |
|
254 + if (isalldigits(optp, 6) != B_TRUE) |
|
255 + comerrno(EX_BAD, "Bad modification date: " |
|
256 + "year\n"); |
|
257 + |
|
258 + if (check_n_get_val(optp, 4, &year, 1, 1, 0, 0) |
|
259 + != B_TRUE) |
|
260 + comerrno(EX_BAD, "Bad modification date: year " |
|
261 + "length\n"); |
|
262 + |
|
263 + strncpy(bufp, optp, 4); |
|
264 + optp = optp + 4; |
|
265 + bufp += 4; |
|
266 + } else |
|
267 + comerrno(EX_BAD, "Bad modification date\n"); |
|
268 + |
|
269 + } else /* tmpp == NULL */ { |
|
270 + /* YYYY[MM[DD.... */ |
|
271 + long year; |
|
272 + |
|
273 + if (check_n_get_val(optp, 4, &year, 1, 1, 0, 0) != B_TRUE) |
|
274 + comerrno(EX_BAD, "Bad modification date year:length\n"); |
|
275 + |
|
276 + strncpy(bufp, optp, 4); |
|
277 + bufp += 4; |
|
278 + optp += 4; |
|
279 + } |
|
280 + |
|
281 + if (*optp) { |
|
282 + long month; |
|
283 + /* optp should point to MM */ |
|
284 + if (check_n_get_val(optp, 2, &month, 1, 1, 1, 12) != B_TRUE) |
|
285 + comerrno(EX_BAD, "Bad modification date:month\n"); |
|
286 + strncpy(bufp, optp, 2); |
|
287 + bufp += 2; |
|
288 + optp += 2; |
|
289 + } |
|
290 + if ((*optp) && (IS_SEPARATOR1(*optp))) |
|
291 + optp++; |
|
292 + |
|
293 + if (*optp) { |
|
294 + long day; |
|
295 + |
|
296 + if (check_n_get_val(optp, 2, &day, 1, 1, 1, 31) != B_TRUE) |
|
297 + comerrno(EX_BAD, "Bad modification date: day\n"); |
|
298 + /* DD */ |
|
299 + strncpy(bufp, optp, 2); |
|
300 + bufp += 2; |
|
301 + optp += 2; |
|
302 + } |
|
303 + |
|
304 + if (*optp == ' ') |
|
305 + optp++; |
|
306 + |
|
307 + if (*optp) { |
|
308 + long hour; |
|
309 + if (check_n_get_val(optp, 2, &hour, 0, 0, 1, 23) != B_TRUE) |
|
310 + comerrno(EX_BAD, "Bad modification date: hour\n"); |
|
311 + |
|
312 + strncpy(bufp, optp, 2); |
|
313 + bufp += 2; |
|
314 + optp += 2; |
|
315 + } |
|
316 + |
|
317 + if (*optp == ':') |
|
318 + optp++; |
|
319 + |
|
320 + if (*optp) { |
|
321 + long min; |
|
322 + if (check_n_get_val(optp, 2, &min, 0, 0, 1, 59) != B_TRUE) |
|
323 + comerrno(EX_BAD, "Bad modification date: minute\n"); |
|
324 + strncpy(bufp, optp, 2); |
|
325 + bufp += 2; |
|
326 + optp += 2; |
|
327 + } |
|
328 + |
|
329 + if (*optp == ':') |
|
330 + optp++; |
|
331 + |
|
332 + if (*optp) { |
|
333 + long sec; |
|
334 + if (check_n_get_val(optp, 2, &sec, 0, 0, 1, 59) != B_TRUE) |
|
335 + comerrno(EX_BAD, "Bad modification date: second\n"); |
|
336 + strncpy(bufp, optp, 2); |
|
337 + bufp += 2; |
|
338 + optp += 2; |
|
339 + } |
|
340 + |
|
341 + if (*optp == ' ') |
|
342 + /* optional space */ |
|
343 + optp++; |
|
344 + |
|
345 + if (*optp != 0) { |
|
346 + comerrno(EX_BAD, "Bad modification date: extra \n"); |
|
347 + } |
|
348 + |
|
349 + modification_date = modbuf; |
|
350 + return (1); |
|
351 + |
|
352 +} |
|
353 + |
|
354 + |
|
355 +LOCAL int |
|
356 +get_boot_platid(opt_arg) |
|
357 + char *opt_arg; |
|
358 +{ |
|
359 + long val; |
|
360 + char *ptr; |
|
361 + |
|
362 + use_eltorito++; |
|
363 + |
|
364 + if (strcmp(opt_arg, "x86") == 0) |
|
365 + val = 0; |
|
366 + else if (strcmp(opt_arg, "PPC") == 0) |
|
367 + val = 1; |
|
368 + else if (strcmp(opt_arg, "Mac") == 0) |
|
369 + val = 2; |
|
370 + else if (strcmp(opt_arg, "efi") == 0) |
|
371 + val = 0xEF; |
|
372 + else { |
|
373 + val = strtol(opt_arg, &ptr, 0); |
|
374 + if (*ptr || val < 0 || val >= 0x100) { |
|
375 + comerrno(EX_BAD, "Bad boot system ID.\n"); |
|
376 + } |
|
377 + } |
|
378 + |
|
379 + if (boot_image == NULL) { |
|
380 + /* called before -eltorito-boot option */ |
|
381 + def_platid = val; |
|
382 + return (1); |
|
383 + |
|
384 + } |
|
385 + |
|
386 + if (val != def_platid) { |
|
387 + new_boot_entry(); |
|
388 + get_boot_entry(); |
|
389 + } |
|
390 + |
|
391 + if (current_boot_entry == NULL) |
|
392 + comerrno(EX_BAD, "No current boot entry.\n"); |
|
393 + |
|
394 + current_boot_entry->type = ELTORITO_SECTION_HEADER; |
|
395 + current_boot_entry->boot_platid = val; |
|
396 + |
|
397 + return (1); |
|
398 +} |
|
399 + |
|
400 +LOCAL int |
|
401 get_boot_size(opt_arg) |
|
402 char *opt_arg; |
|
403 { |
|
404 @@ -840,7 +1210,8 @@ |
|
405 "Allow full 31 character filenames for ISO9660 names"}, |
|
406 {{"max-iso9660-filenames", &max_filenames }, |
|
407 "Allow 37 character filenames for ISO9660 names (violates ISO9660)"}, |
|
408 - |
|
409 + {{"modification-date&", NULL, (getpargfun)get_modification_date}, |
|
410 + "\1[string]\1Set the modification date in the primary volume descriptor"}, |
|
411 {{"allow-leading-dots", &allow_leading_dots }, |
|
412 "Allow ISO9660 filenames to start with '.' (violates ISO9660)"}, |
|
413 {{"ldots", &allow_leading_dots }, |
|
414 @@ -968,6 +1339,8 @@ |
|
415 "Boot image is 'no emulation' image"}, |
|
416 {{"no-boot~", NULL, (getpargfun)get_no_boot }, |
|
417 "Boot image is not bootable"}, |
|
418 + {{"eltorito-platform&", NULL, (getpargfun)get_boot_platid }, |
|
419 + "\1#\1Set eltorito platform id"}, |
|
420 {{"boot-load-seg&", NULL, (getpargfun)get_boot_addr }, |
|
421 "\1#\1Set load segment for boot image"}, |
|
422 {{"boot-load-size&", NULL, (getpargfun)get_boot_size }, |