]>
Commit | Line | Data |
---|---|---|
016fe5d8 | 1 | --- cdrtools-1.10/mkisofs/Makefile |
2 | +++ cdrtools-1.10/mkisofs/Makefile | |
3 | @@ -35,7 +35,7 @@ | |
4 | getopt.c getopt1.c \ | |
5 | scsi.c \ | |
6 | scsi_cdr.c cd_misc.c \ | |
7 | - modes.c \ | |
8 | + modes.c silo.c \ | |
9 | apple.c volume.c desktop.c mac_label.c | |
10 | HFILES= apple.h bootinfo.h config.h defaults.h diskmbr.h exclude.h \ | |
11 | fnmatch.h getopt.h iso9660.h mac_label.h mactypes.h match.h \ | |
12 | --- cdrtools-1.10/mkisofs/defaults.h | |
13 | +++ cdrtools-1.10/mkisofs/defaults.h | |
14 | @@ -22,6 +22,10 @@ | |
15 | #define VOLUME_ID_DEFAULT "CDROM" | |
16 | #define BOOT_CATALOG_DEFAULT "boot.catalog" | |
17 | #define BOOT_IMAGE_DEFAULT NULL | |
18 | +#define SILO_BOOT_IMAGE_DEFAULT "boot/second.b" | |
19 | +#define SILO_BOOTBLOCK_DEFAULT "boot/cd.b" | |
20 | +#define SILO_CONF_FILE_DEFAULT "/etc/silo.conf" | |
21 | + | |
22 | #ifdef APPLE_HYB | |
23 | #define APPLE_TYPE_DEFAULT "TEXT" | |
24 | #define APPLE_CREATOR_DEFAULT "unix" | |
25 | --- cdrtools-1.10/mkisofs/mkisofs.8 | |
26 | +++ cdrtools-1.10/mkisofs/mkisofs.8 | |
27 | @@ -85,6 +85,14 @@ | |
28 | .I boot_catalog | |
29 | ] | |
30 | [ | |
31 | +.B \-s | |
32 | +.I silo_conf_file | |
33 | +] | |
34 | +[ | |
35 | +.B \-S | |
36 | +.I silo_bootblock | |
37 | +] | |
38 | +[ | |
39 | .B \-check-oldnames | |
40 | ] | |
41 | [ | |
42 | @@ -1272,6 +1280,25 @@ | |
43 | .B \&.m\&kisofsrc | |
44 | with SYSI=system_id. | |
45 | If specified in both places, the command line version is used. | |
46 | +.TP | |
47 | +.BI \-s " silo_conf_file | |
48 | +Specifies the path and filename of the SILO configuration file to be | |
49 | +used when making a "SILO" bootable CD. The pathname must be relative to the | |
50 | +source path specified to | |
51 | +.B mkisofs | |
52 | +and start with a slash. | |
53 | +The default is | |
54 | +.I /etc/silo.conf | |
55 | +See SILO documentation for the syntax of this file. | |
56 | +.TP | |
57 | +.BI \-S " silo_bootblock | |
58 | +Specifies the path and filename of the SILO first stage boot image to be | |
59 | +used when making a "SILO" bootable CD. The pathname must be relative to the | |
60 | +source path specified to | |
61 | +.B mkisofs. | |
62 | +The default is | |
63 | +.I boot/cd.b | |
64 | +The boot image must come from SILO 0.8.7 and higher. | |
65 | .TP | |
66 | .B \-T | |
67 | Generate a file TRANS.TBL in each directory on the CDROM, which can be used | |
68 | --- cdrtools-1.10/mkisofs/mkisofs.c | |
69 | +++ cdrtools-1.10/mkisofs/mkisofs.c | |
70 | @@ -94,6 +94,7 @@ | |
71 | int use_genboot = 0; | |
72 | int use_RockRidge = 0; | |
73 | int use_Joliet = 0; | |
74 | +int use_silo = 0; | |
75 | int verbose = 1; | |
76 | int gui = 0; | |
77 | int all_files = 1; /* New default is to include all files */ | |
78 | @@ -131,6 +132,10 @@ | |
79 | char *boot_catalog = BOOT_CATALOG_DEFAULT; | |
80 | char *boot_image = BOOT_IMAGE_DEFAULT; | |
81 | char *genboot_image = BOOT_IMAGE_DEFAULT; | |
82 | +char *silo_boot_image = SILO_BOOT_IMAGE_DEFAULT; | |
83 | +char *silo_bootblock = SILO_BOOTBLOCK_DEFAULT; | |
84 | +char *silo_conf_file = SILO_CONF_FILE_DEFAULT; | |
85 | + | |
86 | int ucs_level = 3; /* We now have Unicode tables so use level 3 */ | |
87 | int volume_set_size = 1; | |
88 | int volume_sequence_number = 1; | |
89 | @@ -377,6 +382,8 @@ | |
90 | ||
91 | #endif /* APPLE_HYB */ | |
92 | ||
93 | +#define OPTION_SILO_BOOT 2200 | |
94 | + | |
95 | static int save_pname = 0; | |
96 | ||
97 | static const struct ld_option ld_options[] = | |
98 | @@ -407,6 +414,8 @@ | |
99 | '\0', NULL, "Start specifying alternative El Torito boot parameters", ONE_DASH}, | |
100 | {{"sparc-boot", required_argument, NULL, 'B'}, | |
101 | 'B', "FILES", "Set sparc boot image names", ONE_DASH}, | |
102 | + {{"silo-boot", required_argument, NULL, OPTION_SILO_BOOT}, | |
103 | + '\0', "FILE", "Set SILO second stage boot image name" , ONE_DASH }, | |
104 | {{"generic-boot", required_argument, NULL, 'G'}, | |
105 | 'G', "FILE", "Set generic boot image name", ONE_DASH}, | |
106 | {{"sparc-label", required_argument, NULL, OPTION_SPARCLABEL}, | |
107 | @@ -513,7 +522,10 @@ | |
108 | { {"sort", required_argument, NULL, OPTION_SORT}, | |
109 | '\0', "FILE", "Sort file content locations according to rules in FILE" , ONE_DASH }, | |
110 | #endif /* SORTING */ | |
111 | - | |
112 | + { {"silo-conf-file", required_argument, NULL, 's'}, | |
113 | + 's', "FILE", "Set name of SILO configuration file on the CD", ONE_DASH }, | |
114 | + { {"silo-bootblock", required_argument, NULL, 'S'}, | |
115 | + 'S', "FILE", "Set SILO first stage bootblock image name", ONE_DASH }, | |
116 | {{"split-output", no_argument, NULL, OPTION_SPLIT_OUTPUT}, | |
117 | '\0', NULL, "Split output into files of approx. 1GB size", ONE_DASH}, | |
118 | {{"sysid", required_argument, NULL, OPTION_SYSID}, | |
119 | @@ -1288,6 +1300,34 @@ | |
120 | #endif | |
121 | } | |
122 | break; | |
123 | + case OPTION_SILO_BOOT: | |
124 | + use_silo++; | |
125 | + silo_boot_image = optarg; /* pathname of the boot image on cd */ | |
126 | + if (silo_boot_image == NULL) { | |
127 | + fprintf(stderr,"Required boot image pathname missing\n"); | |
128 | + exit(1); | |
129 | + } | |
130 | + break; | |
131 | + case 'S': | |
132 | + use_silo++; | |
133 | + silo_bootblock = optarg; /* pathname of the boot image on cd */ | |
134 | + if (silo_bootblock == NULL) { | |
135 | + fprintf(stderr,"Required bootblock pathname missing\n"); | |
136 | + exit(1); | |
137 | + } | |
138 | + break; | |
139 | + case 's': | |
140 | + use_silo++; | |
141 | + silo_conf_file = optarg; /* pathname of the boot image on cd */ | |
142 | + if (silo_conf_file == NULL) { | |
143 | + fprintf(stderr,"Required SILO config file pathname missing\n"); | |
144 | + exit(1); | |
145 | + } | |
146 | + if (*silo_conf_file != '/') { | |
147 | + fprintf(stderr,"SILO config file pathname must start with /\n"); | |
148 | + exit(1); | |
149 | + } | |
150 | + break; | |
151 | case OPTION_ABSTRACT: | |
152 | abstract = optarg; | |
153 | if (strlen(abstract) > 37) { | |
154 | @@ -2742,7 +2782,10 @@ | |
155 | outputlist_insert(&sunlabel_desc); | |
156 | if (use_genboot) | |
157 | outputlist_insert(&genboot_desc); | |
158 | - outputlist_insert(&padblock_desc); | |
159 | + if (use_silo) | |
160 | + outputlist_insert(&silo_desc); | |
161 | + else | |
162 | + outputlist_insert(&padblock_desc); | |
163 | ||
164 | /* PVD for disc. */ | |
165 | outputlist_insert(&voldesc_desc); | |
166 | --- cdrtools-1.10/mkisofs/mkisofs.h | |
167 | +++ cdrtools-1.10/mkisofs/mkisofs.h | |
168 | @@ -160,6 +160,7 @@ | |
169 | extern struct output_fragment *out_tail; | |
170 | ||
171 | extern struct output_fragment padblock_desc; | |
172 | +extern struct output_fragment silo_desc; | |
173 | extern struct output_fragment voldesc_desc; | |
174 | extern struct output_fragment joliet_desc; | |
175 | extern struct output_fragment torito_desc; | |
176 | @@ -228,8 +229,15 @@ | |
177 | struct directory_entry *s_entry; | |
178 | unsigned int pad; | |
179 | off_t off; | |
180 | +#ifdef __STDC__ | |
181 | + int (*filter)(char *, int, int); | |
182 | +#else | |
183 | + int (*filter)(); | |
184 | +#endif | |
185 | }; | |
186 | ||
187 | +extern struct deferred_write * dw_head, * dw_tail; | |
188 | + | |
189 | struct eltorito_boot_entry_info { | |
190 | struct eltorito_boot_entry_info *next; | |
191 | char *boot_image; | |
192 | @@ -565,6 +573,9 @@ | |
193 | extern char *boot_catalog; | |
194 | extern char *boot_image; | |
195 | extern char *genboot_image; | |
196 | +extern char *silo_boot_image; | |
197 | +extern char *silo_bootblock; | |
198 | +extern char *silo_conf_file; | |
199 | extern int ucs_level; | |
200 | extern int volume_set_size; | |
201 | extern int volume_sequence_number; | |
202 | --- cdrtools-1.10/mkisofs/silo.c | |
203 | +++ cdrtools-1.10/mkisofs/silo.c | |
204 | @@ -0,0 +1,255 @@ | |
205 | +/* | |
206 | + * Program silo.c - Handle SILO bootable iso9660 CD-ROMs. | |
207 | + * | |
208 | + | |
209 | + Copyright (C) 1999 Jakub Jelinek <jakub@redhat.com>. | |
210 | + | |
211 | + This program is free software; you can redistribute it and/or modify | |
212 | + it under the terms of the GNU General Public License as published by | |
213 | + the Free Software Foundation; either version 2, or (at your option) | |
214 | + any later version. | |
215 | + | |
216 | + This program is distributed in the hope that it will be useful, | |
217 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
218 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
219 | + GNU General Public License for more details. | |
220 | + | |
221 | + You should have received a copy of the GNU General Public License | |
222 | + along with this program; if not, write to the Free Software | |
223 | + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
224 | + | |
225 | + | |
226 | +static char rcsid[] ="$Id$"; | |
227 | + | |
228 | +#include <mconfig.h> | |
229 | +#include <stdio.h> | |
230 | +#include <sys/types.h> | |
231 | +#include <sys/stat.h> | |
232 | +#include <unistd.h> | |
233 | +#include <fcntl.h> | |
234 | +#include <stdlib.h> | |
235 | + | |
236 | +#include "mkisofs.h" | |
237 | +#include "iso9660.h" | |
238 | +#include <schily.h> | |
239 | + | |
240 | +/* used by Win32 for opening binary file - not used by Unix */ | |
241 | +#ifndef O_BINARY | |
242 | +#define O_BINARY 0 | |
243 | +#endif /* O_BINARY */ | |
244 | + | |
245 | +struct sun_disklabel { | |
246 | + char info[128]; /* Informative text string */ | |
247 | + char spare0[14]; | |
248 | + struct sun_info { | |
249 | + char spare1; | |
250 | + char id; | |
251 | + char spare2; | |
252 | + char flags; | |
253 | + } infos[8]; | |
254 | + char spare1[246]; /* Boot information etc. */ | |
255 | + char rspeed[2]; /* 722 - Disk rotational speed */ | |
256 | + char pcylcount[2]; /* 722 - Physical cylinder count */ | |
257 | + char sparecyl[2]; /* 722 - extra sects per cylinder */ | |
258 | + char spare2[4]; /* More magic... */ | |
259 | + char ilfact[2]; /* 722 - Interleave factor */ | |
260 | + char ncyl[2]; /* 722 - Data cylinder count */ | |
261 | + char nacyl[2]; /* 722 - Alt. cylinder count */ | |
262 | + char ntrks[2]; /* 722 - Tracks per cylinder */ | |
263 | + char nsect[2]; /* 722 - Sectors per track */ | |
264 | + char spare3[4]; /* Even more magic... */ | |
265 | + struct sun_partition { | |
266 | + char start_cylinder[4]; /* 732 */ | |
267 | + char num_sectors[4]; /* 732 */ | |
268 | + } partitions[8]; | |
269 | + char magic[2]; /* 722 - Magic number */ | |
270 | + char csum[2]; /* 722 - Label xor'd checksum */ | |
271 | + struct bootblock_header { | |
272 | + char magic[4]; /* 732 */ | |
273 | + char aout[20]; | |
274 | + char siloid[8]; | |
275 | + char insn[16]; | |
276 | + char extent[4]; /* 732 */ | |
277 | + char size[4]; /* 732 */ | |
278 | + char text[2048-512-56]; | |
279 | + } bootblock; | |
280 | +}; | |
281 | + | |
282 | +static struct { | |
283 | + char id; | |
284 | + char conf_part; | |
285 | + char part; | |
286 | + char pad; | |
287 | + char conf_file[256]; | |
288 | +} silo_info; | |
289 | + | |
290 | +static int silo_size(int starting_extent) | |
291 | +{ | |
292 | + last_extent += 16; | |
293 | + return 0; | |
294 | +} | |
295 | + | |
296 | +static int silo_filter(char * buffer, int size, int offset) | |
297 | +{ | |
298 | + if (offset < 0x808 + sizeof(silo_info) | |
299 | + && offset + size > 0x808) | |
300 | + { | |
301 | + int i; | |
302 | + if (offset < 0x808) | |
303 | + { | |
304 | + offset = 0x808 - offset; | |
305 | + size -= offset; | |
306 | + buffer += offset; | |
307 | + offset = 0; | |
308 | + } | |
309 | + else | |
310 | + offset -= 0x808; | |
311 | + i = sizeof(silo_info) - offset; | |
312 | + if (i > size) i = size; | |
313 | + memcpy (buffer, ((char *)&silo_info) + offset, i); | |
314 | + } | |
315 | + return 0; | |
316 | +} | |
317 | + | |
318 | +static int silo_write(FILE * outfile) | |
319 | +{ | |
320 | + struct directory_entry * de; | |
321 | + struct directory_entry * de2; | |
322 | + struct deferred_write * dwpnt; | |
323 | + int bootblock, i, should_write; | |
324 | + struct sun_disklabel silo_bb; | |
325 | + | |
326 | + memset (&silo_bb, 0, sizeof (silo_bb)); | |
327 | + | |
328 | + if (*silo_bootblock == '/') silo_bootblock++; | |
329 | + if (*silo_boot_image == '/') silo_boot_image++; | |
330 | + | |
331 | + /* | |
332 | + * search from root of iso fs to find boot catalog | |
333 | + */ | |
334 | + de2 = search_tree_file(root, silo_bootblock); | |
335 | + if (!de2) | |
336 | + { | |
337 | + fprintf(stderr,"Uh oh, I cant find the SILO bootblock!\n"); | |
338 | + exit(1); | |
339 | + } | |
340 | + | |
341 | + /* | |
342 | + * now read it from disk | |
343 | + */ | |
344 | + bootblock = open(de2->whole_name, O_RDWR | O_BINARY); | |
345 | + if (bootblock == -1) | |
346 | + { | |
347 | + fprintf(stderr,"Error opening SILO bootblock for reading.\n"); | |
348 | + perror(""); | |
349 | + exit(1); | |
350 | + } | |
351 | + | |
352 | + if (read (bootblock, (char *)&silo_bb.bootblock, 1024) != 1024) | |
353 | + { | |
354 | + fprintf(stderr,"Error reading SILO bootblock.\n"); | |
355 | + perror(""); | |
356 | + exit(1); | |
357 | + } | |
358 | + | |
359 | + close (bootblock); | |
360 | + | |
361 | + if (get_732 (silo_bb.bootblock.magic) != 0x01030107 | |
362 | + || strncmp (silo_bb.bootblock.siloid, "SILO", 4) | |
363 | + || silo_bb.bootblock.siloid[5] != '.' | |
364 | + || silo_bb.bootblock.siloid[4] < '0' | |
365 | + || silo_bb.bootblock.siloid[4] > '9' | |
366 | + || silo_bb.bootblock.siloid[6] < '0' | |
367 | + || silo_bb.bootblock.siloid[6] > '9' | |
368 | + || silo_bb.bootblock.siloid[7] < '0' | |
369 | + || silo_bb.bootblock.siloid[7] > '9') | |
370 | + { | |
371 | + fprintf(stderr,"Error: the file %s is not a valid SILO bootblock.\n", silo_bootblock); | |
372 | + perror(""); | |
373 | + exit(1); | |
374 | + } | |
375 | + | |
376 | + /* Check version number. Only SILO 0.87 and up is valid. */ | |
377 | + if (silo_bb.bootblock.siloid[4] == '0' | |
378 | + && (silo_bb.bootblock.siloid[6] < '8' | |
379 | + || (silo_bb.bootblock.siloid[6] == '8' | |
380 | + && silo_bb.bootblock.siloid[7] <= '6'))) | |
381 | + { | |
382 | + fprintf(stderr,"Error: SILO bootblock is too old. Must be at least 0.8.7.\n"); | |
383 | + perror(""); | |
384 | + exit(1); | |
385 | + } | |
386 | + | |
387 | + /* | |
388 | + * search from root of iso fs to find boot catalog | |
389 | + */ | |
390 | + de = search_tree_file(root, silo_boot_image); | |
391 | + if (!de) | |
392 | + { | |
393 | + fprintf(stderr,"Uh oh, I cant find the SILO boot image!\n"); | |
394 | + exit(1); | |
395 | + } | |
396 | + | |
397 | + /* | |
398 | + * need to filter second.b, so that we can seed | |
399 | + * silo.conf location and other stuff. | |
400 | + * We could write it into the de->whole_name file, | |
401 | + * but I prefer filtering it like this because | |
402 | + * then the tree can be e.g. read only NFS mounted. | |
403 | + */ | |
404 | + for (dwpnt = dw_head; dwpnt; dwpnt = dwpnt->next) | |
405 | + { | |
406 | + if (!dwpnt->name) continue; | |
407 | + if (!strcmp (dwpnt->name, de->whole_name)) | |
408 | + dwpnt->filter = silo_filter; | |
409 | + } | |
410 | + | |
411 | + set_732 (silo_bb.bootblock.extent, de->starting_block); | |
412 | + set_732 (silo_bb.bootblock.size, de->size); | |
413 | + | |
414 | + strcpy (silo_bb.info, "SPARC bootable CD-ROM: "); | |
415 | + strcat (silo_bb.info, volume_id); | |
416 | + | |
417 | + should_write = (last_extent - session_start) << 2; | |
418 | + | |
419 | + /* Now some magic */ | |
420 | + silo_bb.spare0[3] = 1; | |
421 | + silo_bb.spare0[13] = 8; | |
422 | + for (i = 0; i < 8; i++) { | |
423 | + silo_bb.infos[i].id = 0x83; | |
424 | + silo_bb.infos[i].flags = 0x18; | |
425 | + } | |
426 | + set_732 (silo_bb.spare1 + 14, 0x600ddeee); | |
427 | + set_722 (silo_bb.rspeed, 0x15e); | |
428 | + set_722 (silo_bb.pcylcount, (should_write + 639) / 640); | |
429 | + set_722 (silo_bb.ilfact, 1); | |
430 | + set_722 (silo_bb.ncyl, (should_write + 639) / 640); | |
431 | + set_722 (silo_bb.ntrks, 1); | |
432 | + set_722 (silo_bb.nsect, 640); | |
433 | + set_732 (silo_bb.partitions[0].num_sectors, should_write); | |
434 | + set_722 (silo_bb.magic, 0xdabe); | |
435 | + for (i = 0; i < 510; i+=2) { | |
436 | + silo_bb.csum[0] ^= silo_bb.info[i]; | |
437 | + silo_bb.csum[1] ^= silo_bb.info[i+1]; | |
438 | + } | |
439 | + | |
440 | + xfwrite(&silo_bb, 1, sizeof(silo_bb), outfile); | |
441 | + memset (&silo_bb, 0, sizeof(silo_bb)); | |
442 | + | |
443 | + for(i=1; i<16; i++) | |
444 | + { | |
445 | + xfwrite(&silo_bb, 1, sizeof(silo_bb), outfile); | |
446 | + } | |
447 | + | |
448 | + memset (&silo_info, 0, sizeof(silo_info)); | |
449 | + silo_info.id = 'L'; | |
450 | + silo_info.conf_part = 1; | |
451 | + strncpy (silo_info.conf_file, silo_conf_file, 256); | |
452 | + silo_info.conf_file[259] = '\0'; | |
453 | + | |
454 | + last_extent_written += 16; | |
455 | + | |
456 | + return 0; | |
457 | +} | |
458 | + | |
459 | +struct output_fragment silo_desc = {NULL, silo_size, NULL, silo_write}; | |
460 | --- cdrtools-1.10/mkisofs/vms.c | |
461 | +++ cdrtools-1.10/mkisofs/vms.c | |
462 | @@ -288,7 +288,7 @@ | |
463 | extern unsigned int last_extent_written; | |
464 | ||
465 | int | |
466 | -vms_write_one_file(char *filename, int size, FILE * outfile) | |
467 | +vms_write_one_file(struct deferred_write * dwpnt, FILE * outfile) | |
468 | { | |
469 | int status, | |
470 | i; | |
471 | @@ -296,10 +296,12 @@ | |
472 | int count; | |
473 | int use; | |
474 | int remain; | |
475 | + int offset = 0; | |
476 | ||
477 | - open_file(filename); | |
478 | ||
479 | - remain = size; | |
480 | + open_file(dwpnt->name); | |
481 | + | |
482 | + remain = dwpnt->size; | |
483 | ||
484 | while (remain > 0) { | |
485 | use = (remain > SECTOR_SIZE * NSECT - 1 ? NSECT * SECTOR_SIZE : remain); | |
486 | @@ -308,11 +310,14 @@ | |
487 | rab->rab$l_ubf = buffer; | |
488 | rab->rab$w_usz = sizeof(buffer); | |
489 | status = sys$read(rab); | |
490 | + if (dwpnt->filter) | |
491 | + (* dwpnt->filter)(buffer, use, offset); | |
492 | fwrite(buffer, 1, use, outfile); | |
493 | last_extent_written += use / SECTOR_SIZE; | |
494 | if ((last_extent_written % 1000) < use / SECTOR_SIZE) | |
495 | fprintf(stderr, "%d..", last_extent_written); | |
496 | remain -= use; | |
497 | + offset += use; | |
498 | }; | |
499 | ||
500 | close_file(rab); | |
501 | --- cdrtools-1.10/mkisofs/write.c | |
502 | +++ cdrtools-1.10/mkisofs/write.c | |
503 | @@ -78,10 +78,10 @@ | |
504 | FILE *file)); | |
505 | static int assign_directory_addresses __PR((struct directory *node)); | |
506 | #ifdef APPLE_HYB | |
507 | -static void write_one_file __PR((char *filename, unsigned int size, | |
508 | +static void write_one_file __PR((struct deferred_write *dwpnt, | |
509 | FILE *outfile, off_t off)); | |
510 | #else | |
511 | -static void write_one_file __PR((char *filename, unsigned int size, | |
512 | +static void write_one_file __PR((struct deferred_write *dwpnt, | |
513 | FILE *outfile)); | |
514 | #endif | |
515 | static void write_files __PR((FILE *outfile)); | |
516 | @@ -292,7 +292,7 @@ | |
517 | static struct deferred_write mac_boot; | |
518 | ||
519 | #endif /* APPLE_HYB */ | |
520 | -static struct deferred_write *dw_head = NULL, | |
521 | +struct deferred_write *dw_head = NULL, | |
522 | *dw_tail = NULL; | |
523 | ||
524 | unsigned int last_extent_written = 0; | |
525 | @@ -350,16 +350,14 @@ | |
526 | ||
527 | #ifdef APPLE_HYB | |
528 | static void | |
529 | -write_one_file(filename, size, outfile, off) | |
530 | - char *filename; | |
531 | - unsigned int size; | |
532 | +write_one_file(dwpnt, outfile, off) | |
533 | + struct deferred_write *dwpnt; | |
534 | FILE *outfile; | |
535 | off_t off; | |
536 | #else | |
537 | static void | |
538 | -write_one_file(filename, size, outfile) | |
539 | - char *filename; | |
540 | - unsigned int size; | |
541 | +write_one_file(dwpnt, outfile) | |
542 | + struct deferred_write *dwpnt; | |
543 | FILE *outfile; | |
544 | #endif /* APPLE_HYB */ | |
545 | { | |
546 | @@ -375,18 +373,19 @@ | |
547 | FILE *infile; | |
548 | int remain; | |
549 | int use; | |
550 | + int offset; | |
551 | ||
552 | ||
553 | - if ((infile = fopen(filename, "rb")) == NULL) { | |
554 | + if ((infile = fopen(dwpnt->name, "rb")) == NULL) { | |
555 | #ifdef USE_LIBSCHILY | |
556 | - comerr("cannot open '%s'\n", filename); | |
557 | + comerr("cannot open '%s'\n", dwpnt->name); | |
558 | #else | |
559 | #if defined(sun) || defined(_AUX_SOURCE) | |
560 | fprintf(stderr, "cannot open %s: (%d)\n", | |
561 | - filename, errno); | |
562 | + dwpnt->name, errno); | |
563 | #else | |
564 | fprintf(stderr, "cannot open %s: %s\n", | |
565 | - filename, strerror(errno)); | |
566 | + dwpnt->name, strerror(errno)); | |
567 | #endif | |
568 | exit(1); | |
569 | #endif | |
570 | @@ -394,8 +393,8 @@ | |
571 | #ifdef APPLE_HYB | |
572 | fseek(infile, off, SEEK_SET); | |
573 | #endif /* APPLE_HYB */ | |
574 | - remain = size; | |
575 | - | |
576 | + remain = dwpnt->size; | |
577 | + offset = 0; | |
578 | while (remain > 0) { | |
579 | use = (remain > SECTOR_SIZE * NSECT - 1 ? | |
580 | NSECT * SECTOR_SIZE : remain); | |
581 | @@ -404,13 +403,16 @@ | |
582 | memset(buffer, 0, use); | |
583 | if (fread(buffer, 1, use, infile) == 0) { | |
584 | #ifdef USE_LIBSCHILY | |
585 | - comerr("cannot read from %s\n", filename); | |
586 | + comerr("cannot read from %s\n", dwpnt->name); | |
587 | #else | |
588 | - fprintf(stderr, "cannot read from %s\n", filename); | |
589 | + fprintf(stderr, "cannot read from %s\n", dwpnt->name); | |
590 | exit(1); | |
591 | #endif | |
592 | } | |
593 | + if (dwpnt->filter) | |
594 | + (* dwpnt->filter)(buffer, use, offset); | |
595 | xfwrite(buffer, 1, use, outfile); | |
596 | + offset += use; | |
597 | last_extent_written += use / SECTOR_SIZE; | |
598 | #if 0 | |
599 | if ((last_extent_written % 1000) < use / SECTOR_SIZE) { | |
600 | @@ -465,13 +467,12 @@ | |
601 | } else { | |
602 | ||
603 | #ifdef VMS | |
604 | - vms_write_one_file(dwpnt->name, dwpnt->size, outfile); | |
605 | + vms_write_one_file(dwpnt, outfile); | |
606 | #else | |
607 | #ifdef APPLE_HYB | |
608 | - write_one_file(dwpnt->name, dwpnt->size, outfile, | |
609 | - dwpnt->off); | |
610 | + write_one_file(dwpnt, outfile,dwpnt->off); | |
611 | #else | |
612 | - write_one_file(dwpnt->name, dwpnt->size, outfile); | |
613 | + write_one_file(dwpnt, outfile); | |
614 | #endif /* APPLE_HYB */ | |
615 | #endif | |
616 | free(dwpnt->name); | |
617 | @@ -1054,6 +1055,7 @@ | |
618 | dwpnt->next = NULL; | |
619 | dwpnt->size = s_entry->size; | |
620 | dwpnt->extent = last_extent; | |
621 | + dwpnt->filter = NULL; | |
622 | set_733((char *) s_entry->isorec.extent, | |
623 | last_extent); | |
624 | s_entry->starting_block = last_extent; | |
625 | @@ -1613,8 +1615,7 @@ | |
626 | ||
627 | /* write out HFS boot block */ | |
628 | if (mac_boot.name) | |
629 | - write_one_file(mac_boot.name, mac_boot.size, outfile, | |
630 | - mac_boot.off); | |
631 | + write_one_file(&mac_boot, outfile, mac_boot.off); | |
632 | } | |
633 | #endif /* APPLE_HYB */ | |
634 |