Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 63621 Details for
Bug 88981
Ideas for enhance mkisofs image merge
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Implementation of 2,3 and 3+
mkisofs.patch (text/plain), 23.24 KB, created by
Honza
on 2005-07-17 09:00:51 UTC
(
hide
)
Description:
Implementation of 2,3 and 3+
Filename:
MIME Type:
Creator:
Honza
Created:
2005-07-17 09:00:51 UTC
Size:
23.24 KB
patch
obsolete
>--- orig/mkisofs.c >+++ mod/mkisofs.c >@@ -141,6 +141,9 @@ > char *boot_catalog = BOOT_CATALOG_DEFAULT; > char *boot_image = BOOT_IMAGE_DEFAULT; > char *genboot_image = BOOT_IMAGE_DEFAULT; >+char *graft_old_image = NULL; >+char *graft_prev_image = NULL; >+char *graft_old_root = NULL; > int ucs_level = 3; /* We now have Unicode tables so use level 3 */ > int volume_set_size = 1; > int volume_sequence_number = 1; >@@ -149,7 +152,11 @@ > struct eltorito_boot_entry_info *last_boot_entry = NULL; > struct eltorito_boot_entry_info *current_boot_entry = NULL; > >+struct image_info image_info_prev={NULL,NULL,PREV_SESS_DEV};/* This is for previous session. */ >+struct image_info * image_info_h=&image_info_prev; >+ > int use_graft_ptrs; /* Use graft points */ >+int graft_images = 0; /* Use graft images */ > int jhide_trans_tbl; /* Hide TRANS.TBL from Joliet tree */ > int hide_rr_moved; /* Name RR_MOVED .rr_moved in Rock Ridge tree */ > int omit_period = 0; /* Violates iso9660, but these are a pain */ >@@ -432,6 +439,11 @@ > > #endif /* APPLE_HYB */ > >+#define OPTION_GRAFT_OLD_ROOT 2100 >+#define OPTION_GRAFT_OLD_IMAGE 2101 >+#define OPTION_GRAFT_PREV_IMAGE 2102 >+#define OPTION_GRAFT_IMAGES 2103 >+ > LOCAL int save_pname = 0; > > LOCAL const struct ld_option ld_options[] = >@@ -491,6 +503,14 @@ > ONE_DASH}, > {{"graft-points", no_argument, NULL, OPTION_USE_GRAFT}, > '\0', NULL, "Allow to use graft points for filenames", ONE_DASH}, >+ {{"graft-images", no_argument, NULL, OPTION_GRAFT_IMAGES}, >+ '\0', NULL, "Allow to use graft points for images", ONE_DASH}, >+ {{"graft-old-root", required_argument, NULL, OPTION_GRAFT_OLD_ROOT}, >+ '\0', NULL, "Graft old root to different directory", ONE_DASH}, >+ {{"graft-old-image", required_argument, NULL, OPTION_GRAFT_OLD_IMAGE}, >+ '\0', NULL, "Turn old image to file and graft it", ONE_DASH}, >+ {{"graft-prev-image", required_argument, NULL, OPTION_GRAFT_PREV_IMAGE}, >+ '\0', NULL, "Turn just previous session image to file and graft it", ONE_DASH}, > {{"root", required_argument, NULL, OPTION_RELOC_ROOT}, > '\0', "DIR", "Set root directory for all new files and directories", ONE_DASH}, > {{"old-root", required_argument, NULL, OPTION_RELOC_OLD_ROOT}, >@@ -776,6 +796,180 @@ > LOCAL char * escstrcpy __PR((char *to, char *from)); > EXPORT void * e_malloc __PR((size_t size)); > >+/* From main: prepare path for grafting. */ >+ >+LOCAL struct directory * >+prepare_path(root,graft_point,remain) >+ struct directory * root; >+ char * graft_point; >+ char ** remain; >+{ >+ struct directory *graft_dir; >+ char *pnt; >+ char *xpnt; >+ size_t len; >+ >+ len = 0; >+ >+ /* >+ * Remove unwanted "./" & "/" sequences from start... >+ */ >+ do { >+ xpnt = graft_point; >+ while (xpnt[0] == '.' && xpnt[1] == '/') >+ xpnt += 2; >+ while (*xpnt == PATH_SEPARATOR) { >+ xpnt++; >+ } >+ strcpy(graft_point, xpnt); >+ } while (xpnt > graft_point); >+ >+ graft_dir = root; >+ xpnt = graft_point; >+ >+ /* >+ * Loop down deeper and deeper until we find the >+ * correct insertion spot. >+ * Canonicalize the filename while parsing it. >+ */ >+ while (1 == 1) { >+ do { >+ while (xpnt[0] == '.' && xpnt[1] == '/') >+ xpnt += 2; >+ while (xpnt[0] == '/') >+ xpnt += 1; >+ if (xpnt[0] == '.' && xpnt[1] == '.' && xpnt[2] == '/') { >+ if (graft_dir && graft_dir != root) { >+ graft_dir = graft_dir->parent; >+ xpnt += 2; >+ } >+ } >+ } while ((xpnt[0] == '/') || (xpnt[0] == '.' && xpnt[1] == '/')); >+ pnt = strchr(xpnt, PATH_SEPARATOR); >+ if (pnt == NULL) { >+ if(remain) {*remain=xpnt;break;} >+ if(!xpnt[0]) break; >+ /* else: assume last path component is also directory. */ >+ } else *pnt = '\0'; >+ if (debug) { >+ error("GRAFT Point:'%s' in '%s : %s' (%s)\n", >+ xpnt, >+ graft_dir->whole_name, >+ graft_dir->de_name, >+ graft_point); >+ } >+ graft_dir = find_or_create_directory(graft_dir, >+ graft_point, >+ NULL, TRUE); >+ if(!pnt) break; >+ *pnt = PATH_SEPARATOR; >+ xpnt = pnt + 1; >+ } >+ return(graft_dir); >+} >+ >+struct directory_entry * create_image_file(start,size,path) >+ int start; >+ int size; >+ char * path; >+{ >+ char * name; >+ struct directory_entry * pnt; >+ struct directory * tempd; >+ >+ tempd = prepare_path(root, path, &name); >+ if((name[0])||((name[0]=='.')&&((!name[1])||((name[1]=='.')&&(!name[2]))))) { >+ char whole_path[PATH_MAX]; >+ int timeNow=time(NULL); >+ >+/* Note: we skipping hidding. Why should anyone use this option and then hide it ? */ >+ pnt = (struct directory_entry *)e_malloc(sizeof(struct directory_entry)); >+ memset (pnt,0,sizeof(struct directory_entry)); >+ pnt->name=strdup(name); >+ pnt->starting_block=start; >+ pnt->size=size*SECTOR_SIZE; >+ pnt->iinfo=&image_info_prev; >+#if 0 /* We used memset, so this is only usefull as comment */ >+ pnt->priority=0; >+ pnt->got_rr_name=0; >+ pnt->table=NULL; >+ pnt->whole_name=NULL; >+ pnt->filedir=NULL; >+ pnt->parent_rec=NULL; >+ pnt->inode=0; >+ pnt->rr_attributes=NULL; >+ pnt->rr_attr_size=0; >+ pnt->total_rr_attr_size=0; >+ pnt->de_flags=0; >+#ifdef APPLE_HYB >+ pnt->assoc=NULL; >+ pnt->hfs_ent=NULL; >+#endif >+#endif >+ pnt->dev=PREV_SESS_DEV; >+/* Setting idr & adding rr to pnt ... */ >+ set_733(pnt->isorec.extent,start); >+ pnt->isorec.flags[0]=ISO_FILE; >+ pnt->isorec.ext_attr_length[0]=0; >+ iso9660_date(pnt->isorec.date, timeNow); >+ pnt->isorec.file_unit_size[0]=0; >+ pnt->isorec.interleave[0]=0; >+#ifdef APPLE_HYB >+ if(apple_both) { >+#ifdef USE_LIBSCHILY >+ comerrno(EX_BAD, "Warning: hiding old image from apple.\n"); >+#else >+ fprintf(stderr, "Warning: hiding old image from apple.\n"); >+#endif >+ } >+ set_723(pnt->isorec.volume_sequence_number,volume_sequence_number); >+ iso9660_file_length(name,pnt,0); >+ set_733((char *)pnt->isorec.size,SECTOR_SIZE*size); >+ if(generate_tables) { >+ pnt->table=e_malloc(strlen(name)+5); >+ sprintf(pnt->table,"F\t%s\n",name); >+ } >+ if(use_XA||use_RockRidge) { >+ struct stat statf; >+ >+ statf.st_mode=(S_IFREG|new_dir_mode)&(~0111); >+ statf.st_nlink=1; >+ if(rationalize_uid) >+ statf.st_uid=uid_to_use; >+ else >+ statf.st_uid=getuid(); >+ if(rationalize_gid) >+ statf.st_gid=gid_to_use; >+ else >+ statf.st_gid=getgid(); >+ statf.st_mtime=statf.st_atime=statf.st_ctime=timeNow; >+ generate_xa_rr_attributes(whole_path,name,pnt,&statf,&statf,0); >+ } >+#endif >+ >+/* Putting into directory. */ >+ pnt->next=tempd->contents; >+ tempd->contents=pnt; >+ pnt->filedir=tempd; >+ >+ strcpy(whole_path,tempd->whole_name); >+ strcat(whole_path,SPATH_SEPARATOR); >+ strcat(whole_path,name); >+ pnt->whole_name=strdup(whole_path); >+#ifdef SORTING >+ pnt->sort=tempd->sort; >+ if(do_sort) pnt->sort=sort_matches(whole_path,pnt->sort); >+#endif >+ } else { >+#ifdef USE_LIBSCHILY >+ comerr("Bad graft point for image %s.\n",path); >+#else >+ fprintf(stderr, "Bad graft point for image %s.\n",path); >+#endif >+ } >+} >+ >+ > LOCAL void > read_rcfile(appname) > char *appname; >@@ -1198,6 +1392,7 @@ > int warn_violate = 0; > int have_cmd_line_pathspec = 0; > int rationalize_all = 0; >+ int old_image_size = 0; > > #ifdef APPLE_HYB > char *afpfile = ""; /* mapping file for TYPE/CREATOR */ >@@ -1276,9 +1471,21 @@ > have_cmd_line_pathspec = 1; > goto parse_input_files; > >+ case OPTION_GRAFT_OLD_IMAGE: >+ graft_old_image = optarg; >+ break; >+ case OPTION_GRAFT_PREV_IMAGE: >+ graft_prev_image = optarg; >+ break; >+ case OPTION_GRAFT_OLD_ROOT: >+ graft_old_root = optarg; >+ break; > case OPTION_USE_GRAFT: > use_graft_ptrs = 1; > break; >+ case OPTION_GRAFT_IMAGES: >+ graft_images = 1; >+ break; > case 'C': > /* > * This is a temporary hack until cdrecord gets the >@@ -2715,10 +2922,10 @@ > /* Find name of root directory. */ > if (arg != NULL) > node = findgequal(arg); >- if (!use_graft_ptrs) >+ if ((!use_graft_ptrs)&&(!graft_images)) > node = NULL; > if (node == NULL) { >- if (use_graft_ptrs && arg != NULL) >+ if ((use_graft_ptrs||graft_images) && arg != NULL) > node = escstrcpy(nodename, arg); > else > node = arg; >@@ -2729,6 +2936,15 @@ > */ > node = escstrcpy(nodename, ++node); > } >+ /* This is as good place as any other ... */ >+ if ((use_graft_ptrs)&&(graft_images)) { >+#ifdef USE_LIBSCHILY >+ 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"); >+#else >+ 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");); >+#endif >+ /* In fact, I'm not really sure if graft_images&&!use_graft_ptrs have usable meaning ... */ >+ } > > /* > * See if boot catalog file exists in root directory, if not we will >@@ -2763,9 +2979,11 @@ > } > if (merge_image != NULL) { > char sector[SECTOR_SIZE]; >+ int file_addr; > > errno = 0; >- mrootp = merge_isofs(merge_image); >+ get_session_start(&file_addr); >+ mrootp = merge_isofs(merge_image,&old_image_size,file_addr); > if (mrootp == NULL) { > /* Complain and die. */ > #ifdef USE_LIBSCHILY >@@ -2836,6 +3054,8 @@ > char *short_name; > int status; > char graft_point[PATH_MAX + 1]; >+ FILE * prev_image_f=NULL; >+ struct iso_directory_record * image_root=NULL; > > /* > * We would like a syntax like: >@@ -2860,7 +3080,7 @@ > * the image tree. > */ > node = findgequal(arg); >- if (!use_graft_ptrs) >+ if ((!use_graft_ptrs)&&(!graft_images)) > node = NULL; > /* > * Remove '\\' escape chars which are located >@@ -2920,7 +3140,18 @@ > status = stat_filter(node, &st); > else > status = lstat_filter(node, &st); >- if (status == 0 && S_ISDIR(st.st_mode)) { >+ /* Same is true for graft_images ... */ >+ if (status == 0 && (!S_ISDIR(st.st_mode)) && graft_images && (node!=arg)) { >+ FILE * temp_f; >+ prev_image_f=fopen(node, "rb"); >+ if(prev_image_f) { >+ temp_f=in_image; >+ in_image=prev_image_f; >+ image_root=merge_isofs(node,NULL,0); >+ in_image=temp_f; >+ } >+ } >+ if (status == 0 && (S_ISDIR(st.st_mode))||(image_root)) { > len = strlen(graft_point); > > if ((len <= (sizeof (graft_point) -1)) && >@@ -2972,7 +3203,7 @@ > } > } else { > graft_dir = root; >- if (use_graft_ptrs) >+ if ((use_graft_ptrs)||(graft_images)) > node = escstrcpy(nodename, arg); > else > node = arg; >@@ -2999,6 +3230,7 @@ > #endif > } else { > if (S_ISDIR(st.st_mode)) { >+ if (!use_graft_ptrs) graft_dir=root; /* Because graft_images will ignore directories. */ > if (debug) { > error("graft_dir: '%s : %s', node: '%s', (scan)\n", > graft_dir->whole_name, >@@ -3022,12 +3254,63 @@ > short_name++; > } > } >+ if ((graft_images)&&(image_root)) { >+ struct directory_entry * s_entry; >+ struct image_info * iinfo; >+ FILE * temp_f; >+ >+ if (debug) { >+ error("graft_image: '%s : %s', node: '%s', short_name: '%s'\n", >+ graft_dir->whole_name, >+ graft_dir->de_name, node, >+ short_name); >+ } >+ temp_f=in_image; >+ in_image=prev_image_f; >+ iinfo=(struct image_info *)e_malloc(sizeof(struct image_info)); >+ /* We can of course expect user will add image file >+ as other argument (except debuging or user error). >+ Problem is we don't know correct name and location ... >+ Well, maybee this will work ... >+ */ >+#ifdef APPLE_HYB >+ if(!insert_file_entry(graft_dir,node,"",0)) { >+#else >+ if(!insert_file_entry(graft_dir,node,"")) { >+#endif >+#ifdef USE_LIBSCHILY >+ comerrno(EX_BAD, "Cannot merge session from %s (insert_file)\n",node); >+#else >+ fprintf(stderr, "Cannot merge session from %s (insert_file)\n",node); >+#endif >+ free(iinfo); >+ } else { >+ iinfo->de=s_entry=graft_dir->contents; >+ /* I think we should expect it won't be so many ... */ >+ iinfo->dev=image_info_h->dev-1; >+ s_entry->de_flags|=INHIBIT_ISO9660_ENTRY|INHIBIT_JOLIET_ENTRY; >+ if(merge_previous_session(graft_dir, image_root, reloc_root, NULL, iinfo)<0) { >+#ifdef USE_LIBSCHILY >+ comerrno(EX_BAD, "Cannot merge session from %s\n",node); >+#else >+ fprintf(stderr, "Cannot merge session from %s\n",node); >+#endif >+ free(iinfo); >+ } else { >+ iinfo->prev=image_info_h; >+ image_info_h=iinfo; >+ } >+ } >+ in_image=temp_f; >+ goto graft_file_done; >+ } else if (!use_graft_ptrs) graft_dir=root; > if (debug) { > error("graft_dir: '%s : %s', node: '%s', short_name: '%s'\n", > graft_dir->whole_name, > graft_dir->de_name, node, > short_name); > } >+ > #ifdef APPLE_HYB > if (!insert_file_entry(graft_dir, node, > short_name, 0)) >@@ -3042,8 +3325,9 @@ > /* exit(1);*/ > } > } >+graft_file_done: >+ if(prev_image_f) fclose(prev_image_f); > } >- > optind++; > no_path_names = 0; > } >@@ -3067,8 +3351,22 @@ > * side, since we may need to create some additional directories. > */ > if (merge_image != NULL) { >- if (merge_previous_session(root, mrootp, >- reloc_root, reloc_old_root) < 0) { >+ struct directory * old_root, * tempd; >+ int prev; >+ >+ get_session_start(&prev); >+ >+ if (graft_old_image) { >+ create_image_file(0,prev+old_image_size,graft_old_image); >+ } >+ if(graft_prev_image) { >+ create_image_file(prev,old_image_size,graft_prev_image); >+ } >+ if (graft_old_root) { >+ old_root = prepare_path(root,graft_old_root, NULL); >+ } else old_root=root; >+ if (merge_previous_session(old_root, mrootp, >+ reloc_root, reloc_old_root, &image_info_prev) < 0) { > #ifdef USE_LIBSCHILY > comerrno(EX_BAD, "Cannot merge previous session.\n"); > #else >--- orig/mkisofs.h >+++ mod/mkisofs.h >@@ -89,6 +89,12 @@ > > #endif /* APPLE_HYB */ > >+struct image_info { >+ struct image_info * prev; >+ struct directory_entry * de; >+ dev_t dev; >+}; >+ > struct directory_entry { > struct directory_entry *next; > struct directory_entry *jnext; >@@ -121,6 +127,7 @@ > #ifdef UDF > int udf_file_entry_sector; /* also used as UDF unique ID */ > #endif >+ struct image_info * iinfo; > }; > > struct file_hash { >@@ -339,6 +346,7 @@ > extern int print_size; > extern int split_output; > extern int use_graft_ptrs; >+extern int graft_images; > extern int jhide_trans_tbl; > extern int hide_rr_moved; > extern int omit_period; >@@ -493,12 +501,13 @@ > extern int open_merge_image __PR((char *path)); > extern int close_merge_image __PR((void)); > extern struct iso_directory_record * >- merge_isofs __PR((char *path)); >+ merge_isofs __PR((char *path, int * size, int)); > extern unsigned char *parse_xa __PR((unsigned char *pnt, int *lenp, > struct directory_entry * dpnt)); > extern int rr_flags __PR((struct iso_directory_record *idr)); > extern int merge_previous_session __PR((struct directory *, >- struct iso_directory_record *, char *, char *)); >+ struct iso_directory_record *, char *, char *, >+ struct image_info *)); > extern int get_session_start __PR((int *)); > > /* joliet.c */ >--- orig/multi.c >+++ mod/multi.c >@@ -76,14 +76,14 @@ > struct stat *statbuf, > struct stat *lstatbuf)); > LOCAL struct directory_entry ** >- read_merging_directory __PR((struct iso_directory_record *, int *)); >+ read_merging_directory __PR((struct iso_directory_record *, int *, struct image_info *)); > LOCAL int free_mdinfo __PR((struct directory_entry **, int len)); > LOCAL void free_directory_entry __PR((struct directory_entry * dirp)); > LOCAL void merge_remaining_entries __PR((struct directory *, >- struct directory_entry **, int)); >+ struct directory_entry **, int, struct image_info *)); > > LOCAL int merge_old_directory_into_tree __PR((struct directory_entry *, >- struct directory *)); >+ struct directory *, struct image_info *)); > LOCAL void check_rr_relocation __PR((struct directory_entry * de)); > > #ifdef PROTOTYPES >@@ -619,9 +619,10 @@ > } > > LOCAL struct directory_entry ** >-read_merging_directory(mrootp, nentp) >+read_merging_directory(mrootp, nentp, relative) > struct iso_directory_record *mrootp; > int *nentp; >+ struct image_info * relative; > { > unsigned char *cpnt; > unsigned char *cpnt1; >@@ -708,6 +709,13 @@ > (*pnt)->starting_block = > isonum_733((unsigned char *) idr->extent); > (*pnt)->size = isonum_733((unsigned char *) idr->size); >+ if((relative->de)|| >+ /* HACK: There is only one way this could happen >+ (I mean version without relative->s_entry) >+ ... graft_old_image. */ >+ (!(*pnt)->starting_block)&&((*pnt)->size)) { >+ (*pnt)->iinfo=relative; >+ } > (*pnt)->priority = 0; > (*pnt)->name = NULL; > (*pnt)->got_rr_name = 0; >@@ -720,7 +728,7 @@ > * session bits of information. > */ > (*pnt)->inode = (*pnt)->starting_block; >- (*pnt)->dev = PREV_SESS_DEV; >+ (*pnt)->dev = relative->dev; /* Will be PREV_SESS_DEV in previous session merging. */ > (*pnt)->rr_attributes = NULL; > (*pnt)->rr_attr_size = 0; > (*pnt)->total_rr_attr_size = 0; >@@ -1170,11 +1178,12 @@ > * to the root directory for this image. > */ > struct iso_directory_record * >-merge_isofs(path) >+merge_isofs(path,size,file_addr) > char *path; >+ int *size; >+ int file_addr; > { > char buffer[SECTOR_SIZE]; >- int file_addr; > int i; > struct iso_primary_descriptor *pri = NULL; > struct iso_directory_record *rootp; >@@ -1185,7 +1194,7 @@ > * search for volume headers in multiple places because we might be > * starting with a multisession image. FIXME(eric). > */ >- get_session_start(&file_addr); >+ /* get_session_start(&file_addr); */ /* Moved to caller for graft_images */ > > for (i = 0; i < 100; i++) { > if (readsecs(file_addr, buffer, >@@ -1230,14 +1239,16 @@ > > memcpy(rootp, pri->root_directory_record, sizeof (*rootp)); > >+ if(size) *size=isonum_733(pri->volume_space_size); > return (rootp); > } > > LOCAL void >-merge_remaining_entries(this_dir, pnt, n_orig) >+merge_remaining_entries(this_dir, pnt, n_orig, relative) > struct directory *this_dir; > struct directory_entry **pnt; > int n_orig; >+ struct image_info * relative; > { > int i; > struct directory_entry *s_entry; >@@ -1286,7 +1297,7 @@ > pnt[i] = NULL; > continue; > } else { >- merge_old_directory_into_tree(pnt[i], this_dir); >+ merge_old_directory_into_tree(pnt[i], this_dir, relative); > } > } > pnt[i]->next = this_dir->contents; >@@ -1363,9 +1374,10 @@ > * location. FIXME(eric). > */ > LOCAL int >-merge_old_directory_into_tree(dpnt, parent) >+merge_old_directory_into_tree(dpnt, parent, relative) > struct directory_entry *dpnt; > struct directory *parent; >+ struct image_info * relative; > { > struct directory_entry **contents = NULL; > int i; >@@ -1403,7 +1415,7 @@ > /* > * Now fill this directory using information from the previous session. > */ >- contents = read_merging_directory(&dpnt->isorec, &n_orig); >+ contents = read_merging_directory(&dpnt->isorec, &n_orig, relative); > /* > * Start by simply copying the '.', '..' and non-directory entries to > * this directory. Technically we could let merge_remaining_entries >@@ -1422,6 +1434,7 @@ > /* If we have a directory, don't reuse the extent number. */ > if ((contents[i]->isorec.flags[0] & ISO_DIRECTORY) != 0) { > memset(contents[i]->isorec.extent, 0, 8); >+ contents[i]->iinfo=0; > > if (strcmp(contents[i]->name, ".") == 0) > this_dir->dir_flags |= DIR_HAS_DOT; >@@ -1458,14 +1471,18 @@ > > /* > * Zero the extent number for ourselves. >+ * This is point where we in fact specify we are not going to reuse >+ * extent of this directory. > */ > memset(dpnt->isorec.extent, 0, 8); >+ dpnt->iinfo=0; >+ /* Note: starting_block not updated - why ? BUG ? */ > > /* > * Anything that is left are other subdirectories that need to be > * merged. > */ >- merge_remaining_entries(this_dir, contents, n_orig); >+ merge_remaining_entries(this_dir, contents, n_orig, relative); > free_mdinfo(contents, n_orig); > #if 0 > /* >@@ -1553,11 +1570,12 @@ > * directory entries, so that we can determine how large each directory is. > */ > int >-merge_previous_session(this_dir, mrootp, reloc_root, reloc_old_root) >+merge_previous_session(this_dir, mrootp, reloc_root, reloc_old_root, relative) > struct directory *this_dir; > struct iso_directory_record *mrootp; > char *reloc_root; > char *reloc_old_root; >+ struct image_info * relative; > { > struct directory_entry **orig_contents = NULL; > struct directory_entry *odpnt = NULL; >@@ -1581,7 +1599,7 @@ > * Parse the same directory in the image that we are merging for > * multisession stuff. > */ >- orig_contents = read_merging_directory(mrootp, &n_orig); >+ orig_contents = read_merging_directory(mrootp, &n_orig, relative); > if (orig_contents == NULL) { > if (reloc_old_root) { > #ifdef USE_LIBSCHILY >@@ -1634,7 +1652,7 @@ > if (new_orig_contents != orig_contents) { > free_mdinfo(new_orig_contents, new_n_orig); > } >- new_orig_contents = read_merging_directory(&subroot, &new_n_orig); >+ new_orig_contents = read_merging_directory(&subroot, &new_n_orig, relative); > > if (!new_orig_contents) { > #ifdef USE_LIBSCHILY >@@ -1689,7 +1707,7 @@ > if (retcode == -1) > return (-1); > } >- merge_remaining_entries(this_dir, orig_contents, n_orig); >+ merge_remaining_entries(this_dir, orig_contents, n_orig, relative); > > /* use new directory */ > free_mdinfo(orig_contents, n_orig); >@@ -1767,7 +1785,7 @@ > s_entry, 1); > dflag = merge_previous_session(child, > &odpnt->isorec, >- NULL, reloc_old_root); >+ NULL, reloc_old_root, relative); > if (dflag == -1) { > return (-1); > } >@@ -1782,7 +1800,7 @@ > * Whatever is left over, are things which are no longer in the tree on > * disk. We need to also merge these into the tree. > */ >- merge_remaining_entries(this_dir, orig_contents, n_orig); >+ merge_remaining_entries(this_dir, orig_contents, n_orig, relative); > } > free_mdinfo(orig_contents, n_orig); > return (1); >--- orig/write.c >+++ mod/write.c >@@ -1059,6 +1059,22 @@ > s_entry->isorec.extent) != 0) { > continue; > } >+ if(s_entry->iinfo) { >+ /* In fact hack. We don't really need relative extent in image of >+ previous session ... but we must work around fact it can have >+ extent=0 ... >+ On the other hand, you can't unpack images from previous session >+ ... at least for now (FIXME). >+ Alternative (clean) way is add yet another item in struct directory_entry. >+ Note: also solving images of previous sessions in unpacked images ! >+ Note: most files with s_entry->iinfo WILL have extent!=0. >+ */ >+ extern char * graft_old_image; >+ if(!graft_old_image) { >+ fprintf(stderr, "Unexpected file %s with extent 0\n",s_entry->whole_name); >+ } >+ continue; >+ } > /* > * This saves some space if there are symlinks present > */ >@@ -1357,6 +1373,37 @@ > } > } > >+LOCAL void >+assign_relative_extents(dpnt) >+ struct directory *dpnt; >+{ >+ struct directory_entry * s_entry; >+ int jump; >+ >+ while(dpnt) { >+ for(s_entry=dpnt->contents;s_entry;s_entry=s_entry->next) { >+ if(!s_entry->iinfo) continue; >+ if(!s_entry->iinfo->de) continue; >+ >+ jump=s_entry->iinfo->de->starting_block; >+ if((!jump)&&(jump=isonum_733((unsigned char *)s_entry->iinfo->de->isorec.extent))) { >+ /* Can someone tell me WHY this happen ? It's around hard links ... >+ Or it is BUG, just not visible before ? >+ */ >+#ifdef DEBUG >+ fprintf("starting_block not set while extent is for %s\n",s_entry->iinfo->de->whole_name); >+#endif >+ } >+ s_entry->starting_block+=jump; >+ set_733((unsigned char *)s_entry->isorec.extent, >+ isonum_733((unsigned char *)s_entry->isorec.extent)+jump); >+ } >+ if(dpnt->subdir) >+ assign_relative_extents(dpnt->subdir); >+ dpnt = dpnt->next; >+ } >+} >+ > EXPORT void > generate_one_directory(dpnt, outfile) > struct directory *dpnt; >@@ -2274,6 +2321,10 @@ > } > #endif /* SORTING */ > >+ if (graft_images) { >+ assign_relative_extents(root); >+ } >+ > #ifdef APPLE_HYB > /* > * put this here for the time being - may when I've worked out how to
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 88981
: 63621