Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 88981
Collapse All | Expand All

(-)file_not_specified_in_diff (-34 / +410 lines)
Line  Link Here
0
-- orig/mkisofs.c
0
++ mod/mkisofs.c
Lines 141-146 Link Here
141
char	*boot_catalog = BOOT_CATALOG_DEFAULT;
141
char	*boot_catalog = BOOT_CATALOG_DEFAULT;
142
char	*boot_image = BOOT_IMAGE_DEFAULT;
142
char	*boot_image = BOOT_IMAGE_DEFAULT;
143
char	*genboot_image = BOOT_IMAGE_DEFAULT;
143
char	*genboot_image = BOOT_IMAGE_DEFAULT;
144
char	*graft_old_image = NULL;
145
char	*graft_prev_image = NULL;
146
char	*graft_old_root = NULL;
144
int	ucs_level = 3;		/* We now have Unicode tables so use level 3 */
147
int	ucs_level = 3;		/* We now have Unicode tables so use level 3 */
145
int	volume_set_size = 1;
148
int	volume_set_size = 1;
146
int	volume_sequence_number = 1;
149
int	volume_sequence_number = 1;
Lines 149-155 Link Here
149
struct eltorito_boot_entry_info *last_boot_entry = NULL;
152
struct eltorito_boot_entry_info *last_boot_entry = NULL;
150
struct eltorito_boot_entry_info *current_boot_entry = NULL;
153
struct eltorito_boot_entry_info *current_boot_entry = NULL;
151
154
155
struct image_info image_info_prev={NULL,NULL,PREV_SESS_DEV};/* This is for previous session. */
156
struct image_info * image_info_h=&image_info_prev;
157
152
int	use_graft_ptrs;		/* Use graft points */
158
int	use_graft_ptrs;		/* Use graft points */
159
int	graft_images = 0;	/* Use graft images */
153
int	jhide_trans_tbl;	/* Hide TRANS.TBL from Joliet tree */
160
int	jhide_trans_tbl;	/* Hide TRANS.TBL from Joliet tree */
154
int	hide_rr_moved;		/* Name RR_MOVED .rr_moved in Rock Ridge tree */
161
int	hide_rr_moved;		/* Name RR_MOVED .rr_moved in Rock Ridge tree */
155
int	omit_period = 0;	/* Violates iso9660, but these are a pain */
162
int	omit_period = 0;	/* Violates iso9660, but these are a pain */
Lines 432-437 Link Here
432
439
433
#endif	/* APPLE_HYB */
440
#endif	/* APPLE_HYB */
434
441
442
#define OPTION_GRAFT_OLD_ROOT		2100
443
#define OPTION_GRAFT_OLD_IMAGE		2101
444
#define OPTION_GRAFT_PREV_IMAGE		2102
445
#define OPTION_GRAFT_IMAGES		2103
446
435
LOCAL int	save_pname = 0;
447
LOCAL int	save_pname = 0;
436
448
437
LOCAL const struct ld_option ld_options[] =
449
LOCAL const struct ld_option ld_options[] =
Lines 491-496 Link Here
491
	ONE_DASH},
503
	ONE_DASH},
492
	{{"graft-points", no_argument, NULL, OPTION_USE_GRAFT},
504
	{{"graft-points", no_argument, NULL, OPTION_USE_GRAFT},
493
	'\0', NULL, "Allow to use graft points for filenames", ONE_DASH},
505
	'\0', NULL, "Allow to use graft points for filenames", ONE_DASH},
506
	{{"graft-images", no_argument, NULL, OPTION_GRAFT_IMAGES},
507
	'\0', NULL, "Allow to use graft points for images", ONE_DASH},
508
	{{"graft-old-root", required_argument, NULL, OPTION_GRAFT_OLD_ROOT},
509
	'\0', NULL, "Graft old root to different directory", ONE_DASH},
510
	{{"graft-old-image", required_argument, NULL, OPTION_GRAFT_OLD_IMAGE},
511
	'\0', NULL, "Turn old image to file and graft it", ONE_DASH},
512
	{{"graft-prev-image", required_argument, NULL, OPTION_GRAFT_PREV_IMAGE},
513
	'\0', NULL, "Turn just previous session image to file and graft it", ONE_DASH},
494
	{{"root", required_argument, NULL, OPTION_RELOC_ROOT},
514
	{{"root", required_argument, NULL, OPTION_RELOC_ROOT},
495
	'\0', "DIR", "Set root directory for all new files and directories", ONE_DASH},
515
	'\0', "DIR", "Set root directory for all new files and directories", ONE_DASH},
496
	{{"old-root", required_argument, NULL, OPTION_RELOC_OLD_ROOT},
516
	{{"old-root", required_argument, NULL, OPTION_RELOC_OLD_ROOT},
Lines 776-781 Link Here
776
LOCAL	char *	escstrcpy	__PR((char *to, char *from));
796
LOCAL	char *	escstrcpy	__PR((char *to, char *from));
777
EXPORT	void *	e_malloc	__PR((size_t size));
797
EXPORT	void *	e_malloc	__PR((size_t size));
778
798
799
/* From main: prepare path for grafting. */
800
801
LOCAL struct directory *
802
prepare_path(root,graft_point,remain)
803
	    struct directory * root;
804
	    char * graft_point;
805
	    char ** remain;
806
{
807
	struct directory *graft_dir;
808
	char		*pnt;
809
	char		*xpnt;
810
	size_t		len;
811
812
	len = 0;
813
814
	/*
815
	 * Remove unwanted "./" & "/" sequences from start...
816
	 */
817
	do {
818
		xpnt = graft_point;
819
		while (xpnt[0] == '.' && xpnt[1] == '/')
820
			xpnt += 2;
821
		while (*xpnt == PATH_SEPARATOR) {
822
			xpnt++;
823
		}
824
		strcpy(graft_point, xpnt);
825
	} while (xpnt > graft_point);
826
827
	graft_dir = root;
828
	xpnt = graft_point;
829
830
	/*
831
	 * Loop down deeper and deeper until we find the
832
	 * correct insertion spot.
833
	 * Canonicalize the filename while parsing it.
834
	 */
835
	while (1 == 1) {
836
		do {
837
			while (xpnt[0] == '.' && xpnt[1] == '/')
838
				xpnt += 2;
839
			while (xpnt[0] == '/')
840
				xpnt += 1;
841
			if (xpnt[0] == '.' && xpnt[1] == '.' && xpnt[2] == '/') {
842
				if (graft_dir && graft_dir != root) {
843
					graft_dir = graft_dir->parent;
844
					xpnt += 2;
845
				}
846
			}
847
		} while ((xpnt[0] == '/') || (xpnt[0] == '.' && xpnt[1] == '/'));
848
		pnt = strchr(xpnt, PATH_SEPARATOR);
849
		if (pnt == NULL) {
850
			if(remain) {*remain=xpnt;break;}
851
			if(!xpnt[0]) break;
852
			/* else: assume last path component is also directory. */
853
		} else *pnt = '\0';
854
		if (debug) {
855
			error("GRAFT Point:'%s' in '%s : %s' (%s)\n",
856
				xpnt,
857
				graft_dir->whole_name,
858
				graft_dir->de_name,
859
				graft_point);
860
		}
861
		graft_dir = find_or_create_directory(graft_dir,
862
			graft_point,
863
			NULL, TRUE);
864
		if(!pnt) break;
865
		*pnt = PATH_SEPARATOR;
866
		xpnt = pnt + 1;
867
	}
868
	return(graft_dir);
869
}
870
871
struct directory_entry * create_image_file(start,size,path)
872
    int start;
873
    int size;
874
    char * path;
875
{
876
    char * name;
877
    struct directory_entry * pnt;
878
    struct directory * tempd;
879
880
    tempd = prepare_path(root, path, &name);
881
    if((name[0])||((name[0]=='.')&&((!name[1])||((name[1]=='.')&&(!name[2]))))) {
882
	char whole_path[PATH_MAX];
883
	int timeNow=time(NULL);
884
885
/* Note: we skipping hidding. Why should anyone use this option and then hide it ? */
886
	pnt = (struct directory_entry *)e_malloc(sizeof(struct directory_entry));
887
	memset (pnt,0,sizeof(struct directory_entry));
888
	pnt->name=strdup(name);
889
	pnt->starting_block=start;
890
	pnt->size=size*SECTOR_SIZE;
891
	pnt->iinfo=&image_info_prev;
892
#if 0 /* We used memset, so this is only usefull as comment */
893
	pnt->priority=0;
894
	pnt->got_rr_name=0;
895
	pnt->table=NULL;
896
	pnt->whole_name=NULL;
897
	pnt->filedir=NULL;
898
	pnt->parent_rec=NULL;
899
	pnt->inode=0;
900
	pnt->rr_attributes=NULL;
901
	pnt->rr_attr_size=0;
902
	pnt->total_rr_attr_size=0;
903
	pnt->de_flags=0;
904
#ifdef APPLE_HYB
905
	pnt->assoc=NULL;
906
	pnt->hfs_ent=NULL;
907
#endif
908
#endif
909
	pnt->dev=PREV_SESS_DEV;
910
/* Setting idr & adding rr to pnt ... */
911
	set_733(pnt->isorec.extent,start);
912
	pnt->isorec.flags[0]=ISO_FILE;
913
	pnt->isorec.ext_attr_length[0]=0;
914
	iso9660_date(pnt->isorec.date, timeNow);
915
	pnt->isorec.file_unit_size[0]=0;
916
	pnt->isorec.interleave[0]=0;
917
#ifdef APPLE_HYB
918
	if(apple_both) {
919
#ifdef	USE_LIBSCHILY
920
		comerrno(EX_BAD, "Warning: hiding old image from apple.\n");
921
#else
922
		fprintf(stderr, "Warning: hiding old image from apple.\n");
923
#endif
924
	}
925
	set_723(pnt->isorec.volume_sequence_number,volume_sequence_number);
926
	iso9660_file_length(name,pnt,0);
927
	set_733((char *)pnt->isorec.size,SECTOR_SIZE*size);
928
	if(generate_tables) {
929
		pnt->table=e_malloc(strlen(name)+5);
930
		sprintf(pnt->table,"F\t%s\n",name);
931
	}
932
	if(use_XA||use_RockRidge) {
933
		struct stat statf;
934
		
935
		statf.st_mode=(S_IFREG|new_dir_mode)&(~0111);
936
		statf.st_nlink=1;
937
		if(rationalize_uid)
938
			statf.st_uid=uid_to_use;
939
		else
940
			statf.st_uid=getuid();
941
		if(rationalize_gid)
942
			statf.st_gid=gid_to_use;
943
		else
944
			statf.st_gid=getgid();
945
		statf.st_mtime=statf.st_atime=statf.st_ctime=timeNow;
946
		generate_xa_rr_attributes(whole_path,name,pnt,&statf,&statf,0);
947
	}
948
#endif
949
			
950
/* Putting into directory. */
951
	pnt->next=tempd->contents;
952
	tempd->contents=pnt;
953
	pnt->filedir=tempd;
954
	
955
	strcpy(whole_path,tempd->whole_name);
956
	strcat(whole_path,SPATH_SEPARATOR);
957
	strcat(whole_path,name);
958
	pnt->whole_name=strdup(whole_path);
959
#ifdef SORTING
960
	pnt->sort=tempd->sort;
961
	if(do_sort) pnt->sort=sort_matches(whole_path,pnt->sort);
962
#endif
963
    } else {
964
#ifdef	USE_LIBSCHILY
965
	comerr("Bad graft point for image %s.\n",path);
966
#else
967
	fprintf(stderr, "Bad graft point for image %s.\n",path);
968
#endif
969
    }
970
}
971
972
779
LOCAL void
973
LOCAL void
780
read_rcfile(appname)
974
read_rcfile(appname)
781
	char		*appname;
975
	char		*appname;
Lines 1198-1203 Link Here
1198
	int		warn_violate = 0;
1392
	int		warn_violate = 0;
1199
	int		have_cmd_line_pathspec = 0;
1393
	int		have_cmd_line_pathspec = 0;
1200
	int		rationalize_all = 0;
1394
	int		rationalize_all = 0;
1395
	int		old_image_size = 0;
1201
1396
1202
#ifdef APPLE_HYB
1397
#ifdef APPLE_HYB
1203
	char		*afpfile = "";	/* mapping file for TYPE/CREATOR */
1398
	char		*afpfile = "";	/* mapping file for TYPE/CREATOR */
Lines 1276-1284 Link Here
1276
			have_cmd_line_pathspec = 1;
1471
			have_cmd_line_pathspec = 1;
1277
			goto parse_input_files;
1472
			goto parse_input_files;
1278
1473
1474
		case OPTION_GRAFT_OLD_IMAGE:
1475
			graft_old_image = optarg;
1476
			break;
1477
		case OPTION_GRAFT_PREV_IMAGE:
1478
			graft_prev_image = optarg;
1479
			break;
1480
		case OPTION_GRAFT_OLD_ROOT:
1481
			graft_old_root = optarg;
1482
			break;
1279
		case OPTION_USE_GRAFT:
1483
		case OPTION_USE_GRAFT:
1280
			use_graft_ptrs = 1;
1484
			use_graft_ptrs = 1;
1281
			break;
1485
			break;
1486
		case OPTION_GRAFT_IMAGES:
1487
			graft_images = 1;
1488
			break;
1282
		case 'C':
1489
		case 'C':
1283
			/*
1490
			/*
1284
			 * This is a temporary hack until cdrecord gets the
1491
			 * This is a temporary hack until cdrecord gets the
Lines 2715-2724 Link Here
2715
	/* Find name of root directory. */
2922
	/* Find name of root directory. */
2716
	if (arg != NULL)
2923
	if (arg != NULL)
2717
		node = findgequal(arg);
2924
		node = findgequal(arg);
2718
	if (!use_graft_ptrs)
2925
	if ((!use_graft_ptrs)&&(!graft_images))
2719
		node = NULL;
2926
		node = NULL;
2720
	if (node == NULL) {
2927
	if (node == NULL) {
2721
		if (use_graft_ptrs && arg != NULL)
2928
		if ((use_graft_ptrs||graft_images) && arg != NULL)
2722
			node = escstrcpy(nodename, arg);
2929
			node = escstrcpy(nodename, arg);
2723
		else
2930
		else
2724
			node = arg;
2931
			node = arg;
Lines 2729-2734 Link Here
2729
		 */
2936
		 */
2730
		node = escstrcpy(nodename, ++node);
2937
		node = escstrcpy(nodename, ++node);
2731
	}
2938
	}
2939
	/* This is as good place as any other ... */
2940
	if ((use_graft_ptrs)&&(graft_images)) {
2941
#ifdef	USE_LIBSCHILY
2942
		comerrno(EX_BAD, "Note: both graft_points and graft_images is on.\nThis mean any iso9660 image will be unpacked,\nwhile directories and other files will be grafted normally.\n");
2943
#else
2944
		fprintf(stderr, "Note: both graft_points and graft_images is on.\nThis mean any iso9660 image will be unpacked,\nwhile directories and other files will be grafted normally.\n"););
2945
#endif
2946
	    /* In fact, I'm not really sure if graft_images&&!use_graft_ptrs have usable meaning ... */
2947
	}
2732
2948
2733
	/*
2949
	/*
2734
	 * See if boot catalog file exists in root directory, if not we will
2950
	 * See if boot catalog file exists in root directory, if not we will
Lines 2763-2771 Link Here
2763
	}
2979
	}
2764
	if (merge_image != NULL) {
2980
	if (merge_image != NULL) {
2765
		char	sector[SECTOR_SIZE];
2981
		char	sector[SECTOR_SIZE];
2982
		int file_addr;
2766
2983
2767
		errno = 0;
2984
		errno = 0;
2768
		mrootp = merge_isofs(merge_image);
2985
		get_session_start(&file_addr);
2986
		mrootp = merge_isofs(merge_image,&old_image_size,file_addr);
2769
		if (mrootp == NULL) {
2987
		if (mrootp == NULL) {
2770
			/* Complain and die. */
2988
			/* Complain and die. */
2771
#ifdef	USE_LIBSCHILY
2989
#ifdef	USE_LIBSCHILY
Lines 2836-2841 Link Here
2836
		char		*short_name;
3054
		char		*short_name;
2837
		int		status;
3055
		int		status;
2838
		char		graft_point[PATH_MAX + 1];
3056
		char		graft_point[PATH_MAX + 1];
3057
		FILE * prev_image_f=NULL;
3058
		struct iso_directory_record * image_root=NULL;
2839
3059
2840
		/*
3060
		/*
2841
		 * We would like a syntax like:
3061
		 * We would like a syntax like:
Lines 2860-2866 Link Here
2860
		 * the image tree.
3080
		 * the image tree.
2861
		 */
3081
		 */
2862
		node = findgequal(arg);
3082
		node = findgequal(arg);
2863
		if (!use_graft_ptrs)
3083
		if ((!use_graft_ptrs)&&(!graft_images))
2864
			node = NULL;
3084
			node = NULL;
2865
		/*
3085
		/*
2866
		 * Remove '\\' escape chars which are located
3086
		 * Remove '\\' escape chars which are located
Lines 2920-2926 Link Here
2920
				status = stat_filter(node, &st);
3140
				status = stat_filter(node, &st);
2921
			else
3141
			else
2922
				status = lstat_filter(node, &st);
3142
				status = lstat_filter(node, &st);
2923
			if (status == 0 && S_ISDIR(st.st_mode)) {
3143
			/* Same is true for graft_images ... */
3144
			if (status == 0 && (!S_ISDIR(st.st_mode)) && graft_images && (node!=arg)) {
3145
				FILE * temp_f;
3146
				prev_image_f=fopen(node, "rb");
3147
				if(prev_image_f) {
3148
					temp_f=in_image;
3149
					in_image=prev_image_f;
3150
					image_root=merge_isofs(node,NULL,0);
3151
					in_image=temp_f;
3152
				}
3153
			}
3154
			if (status == 0 && (S_ISDIR(st.st_mode))||(image_root)) {
2924
				len = strlen(graft_point);
3155
				len = strlen(graft_point);
2925
3156
2926
				if ((len <= (sizeof (graft_point) -1)) &&
3157
				if ((len <= (sizeof (graft_point) -1)) &&
Lines 2972-2978 Link Here
2972
			}
3203
			}
2973
		} else {
3204
		} else {
2974
			graft_dir = root;
3205
			graft_dir = root;
2975
			if (use_graft_ptrs)
3206
			if ((use_graft_ptrs)||(graft_images))
2976
				node = escstrcpy(nodename, arg);
3207
				node = escstrcpy(nodename, arg);
2977
			else
3208
			else
2978
				node = arg;
3209
				node = arg;
Lines 2999-3004 Link Here
2999
#endif
3230
#endif
3000
		} else {
3231
		} else {
3001
			if (S_ISDIR(st.st_mode)) {
3232
			if (S_ISDIR(st.st_mode)) {
3233
				if (!use_graft_ptrs) graft_dir=root; /* Because graft_images will ignore directories. */
3002
				if (debug) {
3234
				if (debug) {
3003
					error("graft_dir: '%s : %s', node: '%s', (scan)\n",
3235
					error("graft_dir: '%s : %s', node: '%s', (scan)\n",
3004
						graft_dir->whole_name,
3236
						graft_dir->whole_name,
Lines 3022-3033 Link Here
3022
						short_name++;
3254
						short_name++;
3023
					}
3255
					}
3024
				}
3256
				}
3257
				if ((graft_images)&&(image_root)) {
3258
					struct directory_entry * s_entry;
3259
					struct image_info * iinfo;
3260
					FILE * temp_f;
3261
3262
					if (debug) {
3263
						error("graft_image: '%s : %s', node: '%s', short_name: '%s'\n",
3264
							graft_dir->whole_name,
3265
							graft_dir->de_name, node,
3266
							short_name);
3267
					}
3268
					temp_f=in_image;
3269
					in_image=prev_image_f;
3270
					iinfo=(struct image_info *)e_malloc(sizeof(struct image_info));
3271
					/* We can of course expect user will add image file
3272
					   as other argument (except debuging or user error).
3273
					   Problem is we don't know correct name and location ...
3274
					   Well, maybee this will work ...
3275
					 */
3276
#ifdef APPLE_HYB
3277
					if(!insert_file_entry(graft_dir,node,"",0)) {
3278
#else
3279
					if(!insert_file_entry(graft_dir,node,"")) {
3280
#endif
3281
#ifdef USE_LIBSCHILY
3282
						comerrno(EX_BAD, "Cannot merge session from %s (insert_file)\n",node);
3283
#else
3284
						fprintf(stderr, "Cannot merge session from %s (insert_file)\n",node);
3285
#endif
3286
						free(iinfo);
3287
					} else {
3288
						iinfo->de=s_entry=graft_dir->contents;
3289
					/* I think we should expect it won't be so many ... */
3290
						iinfo->dev=image_info_h->dev-1;
3291
						s_entry->de_flags|=INHIBIT_ISO9660_ENTRY|INHIBIT_JOLIET_ENTRY;
3292
						if(merge_previous_session(graft_dir, image_root, reloc_root, NULL, iinfo)<0) {
3293
#ifdef USE_LIBSCHILY
3294
							comerrno(EX_BAD, "Cannot merge session from %s\n",node);
3295
#else
3296
							fprintf(stderr, "Cannot merge session from %s\n",node);
3297
#endif
3298
							free(iinfo);
3299
						} else {
3300
							iinfo->prev=image_info_h;
3301
							image_info_h=iinfo;
3302
						}
3303
					}
3304
					in_image=temp_f;
3305
					goto graft_file_done;
3306
				} else if (!use_graft_ptrs) graft_dir=root;
3025
				if (debug) {
3307
				if (debug) {
3026
					error("graft_dir: '%s : %s', node: '%s', short_name: '%s'\n",
3308
					error("graft_dir: '%s : %s', node: '%s', short_name: '%s'\n",
3027
						graft_dir->whole_name,
3309
						graft_dir->whole_name,
3028
						graft_dir->de_name, node,
3310
						graft_dir->de_name, node,
3029
						short_name);
3311
						short_name);
3030
				}
3312
				}
3313
				
3031
#ifdef APPLE_HYB
3314
#ifdef APPLE_HYB
3032
				if (!insert_file_entry(graft_dir, node,
3315
				if (!insert_file_entry(graft_dir, node,
3033
								short_name, 0))
3316
								short_name, 0))
Lines 3042-3049 Link Here
3042
/*					exit(1);*/
3325
/*					exit(1);*/
3043
				}
3326
				}
3044
			}
3327
			}
3328
graft_file_done:
3329
			if(prev_image_f) fclose(prev_image_f);
3045
		}
3330
		}
3046
3047
		optind++;
3331
		optind++;
3048
		no_path_names = 0;
3332
		no_path_names = 0;
3049
	}
3333
	}
Lines 3067-3074 Link Here
3067
	 * side, since we may need to create some additional directories.
3351
	 * side, since we may need to create some additional directories.
3068
	 */
3352
	 */
3069
	if (merge_image != NULL) {
3353
	if (merge_image != NULL) {
3070
		if (merge_previous_session(root, mrootp,
3354
		struct directory * old_root, * tempd;
3071
					reloc_root, reloc_old_root) < 0) {
3355
		int prev;
3356
		
3357
		get_session_start(&prev);
3358
		
3359
		if (graft_old_image) {
3360
		    create_image_file(0,prev+old_image_size,graft_old_image);
3361
		}
3362
		if(graft_prev_image) {
3363
		    create_image_file(prev,old_image_size,graft_prev_image);
3364
		}
3365
		if (graft_old_root) {
3366
			old_root = prepare_path(root,graft_old_root, NULL);
3367
		} else old_root=root;
3368
		if (merge_previous_session(old_root, mrootp,
3369
					reloc_root, reloc_old_root, &image_info_prev) < 0) {
3072
#ifdef	USE_LIBSCHILY
3370
#ifdef	USE_LIBSCHILY
3073
			comerrno(EX_BAD, "Cannot merge previous session.\n");
3371
			comerrno(EX_BAD, "Cannot merge previous session.\n");
3074
#else
3372
#else
3075
-- orig/mkisofs.h
3373
++ mod/mkisofs.h
Lines 89-94 Link Here
89
89
90
#endif	/* APPLE_HYB */
90
#endif	/* APPLE_HYB */
91
91
92
struct image_info {
93
	struct image_info * prev;
94
	struct directory_entry * de;
95
	dev_t dev;
96
};
97
92
struct directory_entry {
98
struct directory_entry {
93
	struct directory_entry *next;
99
	struct directory_entry *next;
94
	struct directory_entry *jnext;
100
	struct directory_entry *jnext;
Lines 121-126 Link Here
121
#ifdef UDF
127
#ifdef UDF
122
	int		udf_file_entry_sector;	/* also used as UDF unique ID */
128
	int		udf_file_entry_sector;	/* also used as UDF unique ID */
123
#endif
129
#endif
130
	struct image_info * iinfo;
124
};
131
};
125
132
126
struct file_hash {
133
struct file_hash {
Lines 339-344 Link Here
339
extern int	print_size;
346
extern int	print_size;
340
extern int	split_output;
347
extern int	split_output;
341
extern int	use_graft_ptrs;
348
extern int	use_graft_ptrs;
349
extern int	graft_images;
342
extern int	jhide_trans_tbl;
350
extern int	jhide_trans_tbl;
343
extern int	hide_rr_moved;
351
extern int	hide_rr_moved;
344
extern int	omit_period;
352
extern int	omit_period;
Lines 493-504 Link Here
493
extern int open_merge_image __PR((char *path));
501
extern int open_merge_image __PR((char *path));
494
extern int close_merge_image __PR((void));
502
extern int close_merge_image __PR((void));
495
extern struct iso_directory_record *
503
extern struct iso_directory_record *
496
			merge_isofs __PR((char *path));
504
			merge_isofs __PR((char *path, int * size, int));
497
extern unsigned char	*parse_xa __PR((unsigned char *pnt, int *lenp,
505
extern unsigned char	*parse_xa __PR((unsigned char *pnt, int *lenp,
498
				struct directory_entry * dpnt));
506
				struct directory_entry * dpnt));
499
extern int	rr_flags	__PR((struct iso_directory_record *idr));
507
extern int	rr_flags	__PR((struct iso_directory_record *idr));
500
extern int merge_previous_session __PR((struct directory *,
508
extern int merge_previous_session __PR((struct directory *,
501
				struct iso_directory_record *, char *, char *));
509
				struct iso_directory_record *, char *, char *,
510
				struct image_info *));
502
extern int get_session_start __PR((int *));
511
extern int get_session_start __PR((int *));
503
512
504
/* joliet.c */
513
/* joliet.c */
505
-- orig/multi.c
514
++ mod/multi.c
Lines 76-89 Link Here
76
					struct stat *statbuf,
76
					struct stat *statbuf,
77
					struct stat *lstatbuf));
77
					struct stat *lstatbuf));
78
LOCAL	struct directory_entry **
78
LOCAL	struct directory_entry **
79
		read_merging_directory __PR((struct iso_directory_record *, int *));
79
		read_merging_directory __PR((struct iso_directory_record *, int *, struct image_info *));
80
LOCAL	int	free_mdinfo	__PR((struct directory_entry **, int len));
80
LOCAL	int	free_mdinfo	__PR((struct directory_entry **, int len));
81
LOCAL	void	free_directory_entry __PR((struct directory_entry * dirp));
81
LOCAL	void	free_directory_entry __PR((struct directory_entry * dirp));
82
LOCAL	void	merge_remaining_entries __PR((struct directory *,
82
LOCAL	void	merge_remaining_entries __PR((struct directory *,
83
					struct directory_entry **, int));
83
					struct directory_entry **, int, struct image_info *));
84
84
85
LOCAL	int	merge_old_directory_into_tree __PR((struct directory_entry *,
85
LOCAL	int	merge_old_directory_into_tree __PR((struct directory_entry *,
86
							struct directory *));
86
							struct directory *, struct image_info *));
87
LOCAL	void	check_rr_relocation __PR((struct directory_entry * de));
87
LOCAL	void	check_rr_relocation __PR((struct directory_entry * de));
88
88
89
#ifdef	PROTOTYPES
89
#ifdef	PROTOTYPES
Lines 619-627 Link Here
619
}
619
}
620
620
621
LOCAL struct directory_entry **
621
LOCAL struct directory_entry **
622
read_merging_directory(mrootp, nentp)
622
read_merging_directory(mrootp, nentp, relative)
623
	struct iso_directory_record *mrootp;
623
	struct iso_directory_record *mrootp;
624
	int		*nentp;
624
	int		*nentp;
625
	struct image_info * relative;
625
{
626
{
626
	unsigned char	*cpnt;
627
	unsigned char	*cpnt;
627
	unsigned char	*cpnt1;
628
	unsigned char	*cpnt1;
Lines 708-713 Link Here
708
		(*pnt)->starting_block =
709
		(*pnt)->starting_block =
709
				isonum_733((unsigned char *) idr->extent);
710
				isonum_733((unsigned char *) idr->extent);
710
		(*pnt)->size = isonum_733((unsigned char *) idr->size);
711
		(*pnt)->size = isonum_733((unsigned char *) idr->size);
712
		if((relative->de)||
713
		    /* HACK: There is only one way this could happen
714
		     (I mean version without relative->s_entry)
715
		       ... graft_old_image. */
716
		    (!(*pnt)->starting_block)&&((*pnt)->size)) {
717
			(*pnt)->iinfo=relative;
718
		}
711
		(*pnt)->priority = 0;
719
		(*pnt)->priority = 0;
712
		(*pnt)->name = NULL;
720
		(*pnt)->name = NULL;
713
		(*pnt)->got_rr_name = 0;
721
		(*pnt)->got_rr_name = 0;
Lines 720-726 Link Here
720
		 * session bits of information.
728
		 * session bits of information.
721
		 */
729
		 */
722
		(*pnt)->inode = (*pnt)->starting_block;
730
		(*pnt)->inode = (*pnt)->starting_block;
723
		(*pnt)->dev = PREV_SESS_DEV;
731
		(*pnt)->dev = relative->dev; /* Will be PREV_SESS_DEV in previous session merging. */
724
		(*pnt)->rr_attributes = NULL;
732
		(*pnt)->rr_attributes = NULL;
725
		(*pnt)->rr_attr_size = 0;
733
		(*pnt)->rr_attr_size = 0;
726
		(*pnt)->total_rr_attr_size = 0;
734
		(*pnt)->total_rr_attr_size = 0;
Lines 1170-1180 Link Here
1170
 * to the root directory for this image.
1178
 * to the root directory for this image.
1171
 */
1179
 */
1172
struct iso_directory_record *
1180
struct iso_directory_record *
1173
merge_isofs(path)
1181
merge_isofs(path,size,file_addr)
1174
	char	*path;
1182
	char	*path;
1183
	int	*size;
1184
	int	file_addr;
1175
{
1185
{
1176
	char		buffer[SECTOR_SIZE];
1186
	char		buffer[SECTOR_SIZE];
1177
	int		file_addr;
1178
	int		i;
1187
	int		i;
1179
	struct iso_primary_descriptor *pri = NULL;
1188
	struct iso_primary_descriptor *pri = NULL;
1180
	struct iso_directory_record *rootp;
1189
	struct iso_directory_record *rootp;
Lines 1185-1191 Link Here
1185
	 * search for volume headers in multiple places because we might be
1194
	 * search for volume headers in multiple places because we might be
1186
	 * starting with a multisession image. FIXME(eric).
1195
	 * starting with a multisession image. FIXME(eric).
1187
	 */
1196
	 */
1188
	get_session_start(&file_addr);
1197
	/* get_session_start(&file_addr); */ /* Moved to caller for graft_images */
1189
1198
1190
	for (i = 0; i < 100; i++) {
1199
	for (i = 0; i < 100; i++) {
1191
		if (readsecs(file_addr, buffer,
1200
		if (readsecs(file_addr, buffer,
Lines 1230-1243 Link Here
1230
1239
1231
	memcpy(rootp, pri->root_directory_record, sizeof (*rootp));
1240
	memcpy(rootp, pri->root_directory_record, sizeof (*rootp));
1232
1241
1242
	if(size) *size=isonum_733(pri->volume_space_size);
1233
	return (rootp);
1243
	return (rootp);
1234
}
1244
}
1235
1245
1236
LOCAL void
1246
LOCAL void
1237
merge_remaining_entries(this_dir, pnt, n_orig)
1247
merge_remaining_entries(this_dir, pnt, n_orig, relative)
1238
	struct directory *this_dir;
1248
	struct directory *this_dir;
1239
	struct directory_entry **pnt;
1249
	struct directory_entry **pnt;
1240
	int		n_orig;
1250
	int		n_orig;
1251
	struct image_info * relative;
1241
{
1252
{
1242
	int		i;
1253
	int		i;
1243
	struct directory_entry *s_entry;
1254
	struct directory_entry *s_entry;
Lines 1286-1292 Link Here
1286
				pnt[i] = NULL;
1297
				pnt[i] = NULL;
1287
				continue;
1298
				continue;
1288
			} else {
1299
			} else {
1289
				merge_old_directory_into_tree(pnt[i], this_dir);
1300
				merge_old_directory_into_tree(pnt[i], this_dir, relative);
1290
			}
1301
			}
1291
		}
1302
		}
1292
		pnt[i]->next = this_dir->contents;
1303
		pnt[i]->next = this_dir->contents;
Lines 1363-1371 Link Here
1363
 * location.  FIXME(eric).
1374
 * location.  FIXME(eric).
1364
 */
1375
 */
1365
LOCAL int
1376
LOCAL int
1366
merge_old_directory_into_tree(dpnt, parent)
1377
merge_old_directory_into_tree(dpnt, parent, relative)
1367
	struct directory_entry	*dpnt;
1378
	struct directory_entry	*dpnt;
1368
	struct directory *parent;
1379
	struct directory *parent;
1380
	struct image_info * relative;
1369
{
1381
{
1370
	struct directory_entry **contents = NULL;
1382
	struct directory_entry **contents = NULL;
1371
	int		i;
1383
	int		i;
Lines 1403-1409 Link Here
1403
	/*
1415
	/*
1404
	 * Now fill this directory using information from the previous session.
1416
	 * Now fill this directory using information from the previous session.
1405
	 */
1417
	 */
1406
	contents = read_merging_directory(&dpnt->isorec, &n_orig);
1418
	contents = read_merging_directory(&dpnt->isorec, &n_orig, relative);
1407
	/*
1419
	/*
1408
	 * Start by simply copying the '.', '..' and non-directory entries to
1420
	 * Start by simply copying the '.', '..' and non-directory entries to
1409
	 * this directory.  Technically we could let merge_remaining_entries
1421
	 * this directory.  Technically we could let merge_remaining_entries
Lines 1422-1427 Link Here
1422
		/* If we have a directory, don't reuse the extent number. */
1434
		/* If we have a directory, don't reuse the extent number. */
1423
		if ((contents[i]->isorec.flags[0] & ISO_DIRECTORY) != 0) {
1435
		if ((contents[i]->isorec.flags[0] & ISO_DIRECTORY) != 0) {
1424
			memset(contents[i]->isorec.extent, 0, 8);
1436
			memset(contents[i]->isorec.extent, 0, 8);
1437
			contents[i]->iinfo=0;
1425
1438
1426
			if (strcmp(contents[i]->name, ".") == 0)
1439
			if (strcmp(contents[i]->name, ".") == 0)
1427
				this_dir->dir_flags |= DIR_HAS_DOT;
1440
				this_dir->dir_flags |= DIR_HAS_DOT;
Lines 1458-1471 Link Here
1458
1471
1459
	/*
1472
	/*
1460
	 * Zero the extent number for ourselves.
1473
	 * Zero the extent number for ourselves.
1474
	 * This is point where we in fact specify we are not going to reuse
1475
	 * extent of this directory.
1461
	 */
1476
	 */
1462
	memset(dpnt->isorec.extent, 0, 8);
1477
	memset(dpnt->isorec.extent, 0, 8);
1478
	dpnt->iinfo=0;
1479
	/* Note: starting_block not updated - why ? BUG ? */
1463
1480
1464
	/*
1481
	/*
1465
	 * Anything that is left are other subdirectories that need to be
1482
	 * Anything that is left are other subdirectories that need to be
1466
	 * merged.
1483
	 * merged.
1467
	 */
1484
	 */
1468
	merge_remaining_entries(this_dir, contents, n_orig);
1485
	merge_remaining_entries(this_dir, contents, n_orig, relative);
1469
	free_mdinfo(contents, n_orig);
1486
	free_mdinfo(contents, n_orig);
1470
#if 0
1487
#if 0
1471
	/*
1488
	/*
Lines 1553-1563 Link Here
1553
 * directory entries, so that we can determine how large each directory is.
1570
 * directory entries, so that we can determine how large each directory is.
1554
 */
1571
 */
1555
int
1572
int
1556
merge_previous_session(this_dir, mrootp, reloc_root, reloc_old_root)
1573
merge_previous_session(this_dir, mrootp, reloc_root, reloc_old_root, relative)
1557
	struct directory *this_dir;
1574
	struct directory *this_dir;
1558
	struct iso_directory_record *mrootp;
1575
	struct iso_directory_record *mrootp;
1559
	char *reloc_root;
1576
	char *reloc_root;
1560
	char *reloc_old_root;
1577
	char *reloc_old_root;
1578
	struct image_info * relative;
1561
{
1579
{
1562
	struct directory_entry **orig_contents = NULL;
1580
	struct directory_entry **orig_contents = NULL;
1563
	struct directory_entry *odpnt = NULL;
1581
	struct directory_entry *odpnt = NULL;
Lines 1581-1587 Link Here
1581
	 * Parse the same directory in the image that we are merging for
1599
	 * Parse the same directory in the image that we are merging for
1582
	 * multisession stuff.
1600
	 * multisession stuff.
1583
	 */
1601
	 */
1584
	orig_contents = read_merging_directory(mrootp, &n_orig);
1602
	orig_contents = read_merging_directory(mrootp, &n_orig, relative);
1585
	if (orig_contents == NULL) {
1603
	if (orig_contents == NULL) {
1586
		if (reloc_old_root) {
1604
		if (reloc_old_root) {
1587
#ifdef	USE_LIBSCHILY
1605
#ifdef	USE_LIBSCHILY
Lines 1634-1640 Link Here
1634
				if (new_orig_contents != orig_contents) {
1652
				if (new_orig_contents != orig_contents) {
1635
					free_mdinfo(new_orig_contents, new_n_orig);
1653
					free_mdinfo(new_orig_contents, new_n_orig);
1636
				}
1654
				}
1637
				new_orig_contents = read_merging_directory(&subroot, &new_n_orig);
1655
				new_orig_contents = read_merging_directory(&subroot, &new_n_orig, relative);
1638
1656
1639
				if (!new_orig_contents) {
1657
				if (!new_orig_contents) {
1640
#ifdef	USE_LIBSCHILY
1658
#ifdef	USE_LIBSCHILY
Lines 1689-1695 Link Here
1689
			if (retcode == -1)
1707
			if (retcode == -1)
1690
				return (-1);
1708
				return (-1);
1691
		}
1709
		}
1692
		merge_remaining_entries(this_dir, orig_contents, n_orig);
1710
		merge_remaining_entries(this_dir, orig_contents, n_orig, relative);
1693
1711
1694
		/* use new directory */
1712
		/* use new directory */
1695
		free_mdinfo(orig_contents, n_orig);
1713
		free_mdinfo(orig_contents, n_orig);
Lines 1767-1773 Link Here
1767
					s_entry, 1);
1785
					s_entry, 1);
1768
				dflag = merge_previous_session(child,
1786
				dflag = merge_previous_session(child,
1769
					&odpnt->isorec,
1787
					&odpnt->isorec,
1770
					NULL, reloc_old_root);
1788
					NULL, reloc_old_root, relative);
1771
				if (dflag == -1) {
1789
				if (dflag == -1) {
1772
					return (-1);
1790
					return (-1);
1773
				}
1791
				}
Lines 1782-1788 Link Here
1782
		 * Whatever is left over, are things which are no longer in the tree on
1800
		 * Whatever is left over, are things which are no longer in the tree on
1783
		 * disk. We need to also merge these into the tree.
1801
		 * disk. We need to also merge these into the tree.
1784
		 */
1802
		 */
1785
		merge_remaining_entries(this_dir, orig_contents, n_orig);
1803
		merge_remaining_entries(this_dir, orig_contents, n_orig, relative);
1786
	}
1804
	}
1787
	free_mdinfo(orig_contents, n_orig);
1805
	free_mdinfo(orig_contents, n_orig);
1788
	return (1);
1806
	return (1);
1789
-- orig/write.c
1807
++ mod/write.c
Lines 1059-1064 Link Here
1059
						s_entry->isorec.extent) != 0) {
1059
						s_entry->isorec.extent) != 0) {
1060
				continue;
1060
				continue;
1061
			}
1061
			}
1062
			if(s_entry->iinfo) {
1063
		/* In fact hack. We don't really need relative extent in image of
1064
		    previous session ... but we must work around fact it can have
1065
		    extent=0 ...
1066
		   On the other hand, you can't unpack images from previous session
1067
		    ... at least for now (FIXME).
1068
		   Alternative (clean) way is add yet another item in struct directory_entry.
1069
		   Note: also solving images of previous sessions in unpacked images !
1070
		   Note: most files with s_entry->iinfo WILL have extent!=0.
1071
		 */
1072
				extern char * graft_old_image;
1073
				if(!graft_old_image) {
1074
					fprintf(stderr, "Unexpected file %s with extent 0\n",s_entry->whole_name);
1075
				}
1076
				continue;
1077
			}
1062
			/*
1078
			/*
1063
			 * This saves some space if there are symlinks present
1079
			 * This saves some space if there are symlinks present
1064
			 */
1080
			 */
Lines 1357-1362 Link Here
1357
	}
1373
	}
1358
}
1374
}
1359
1375
1376
LOCAL void
1377
assign_relative_extents(dpnt)
1378
	struct directory	*dpnt;
1379
{
1380
	struct directory_entry * s_entry;
1381
	int jump;
1382
1383
	while(dpnt) {
1384
		for(s_entry=dpnt->contents;s_entry;s_entry=s_entry->next) {
1385
			if(!s_entry->iinfo) continue;
1386
			if(!s_entry->iinfo->de) continue;
1387
1388
			jump=s_entry->iinfo->de->starting_block;
1389
			if((!jump)&&(jump=isonum_733((unsigned char *)s_entry->iinfo->de->isorec.extent))) {
1390
		/* Can someone tell me WHY this happen ? It's around hard links ... 
1391
		    Or it is BUG, just not visible before ?
1392
		 */
1393
#ifdef DEBUG
1394
				fprintf("starting_block not set while extent is for %s\n",s_entry->iinfo->de->whole_name);
1395
#endif
1396
			}
1397
			s_entry->starting_block+=jump;
1398
			set_733((unsigned char *)s_entry->isorec.extent,
1399
				isonum_733((unsigned char *)s_entry->isorec.extent)+jump);
1400
		}
1401
		if(dpnt->subdir)
1402
			assign_relative_extents(dpnt->subdir);
1403
		dpnt = dpnt->next;
1404
	}
1405
}
1406
1360
EXPORT void
1407
EXPORT void
1361
generate_one_directory(dpnt, outfile)
1408
generate_one_directory(dpnt, outfile)
1362
	struct directory	*dpnt;
1409
	struct directory	*dpnt;
Lines 2274-2279 Link Here
2274
	}
2321
	}
2275
#endif /* SORTING */
2322
#endif /* SORTING */
2276
2323
2324
	if (graft_images) {
2325
		assign_relative_extents(root);
2326
	}
2327
2277
#ifdef APPLE_HYB
2328
#ifdef APPLE_HYB
2278
	/*
2329
	/*
2279
	 * put this here for the time being - may when I've worked out how to
2330
	 * put this here for the time being - may when I've worked out how to

Return to bug 88981