@@ -236,7 +236,8 @@ static bool_t raw_type_open(struct image *im, const struct raw_type *type)
236
236
}
237
237
238
238
static void tag_add_layout (
239
- struct image * im , const struct simple_layout * layout , unsigned int trk_idx )
239
+ struct image * im , const struct simple_layout * layout ,
240
+ const uint8_t * no , unsigned int trk_idx )
240
241
{
241
242
struct raw_sec * sec ;
242
243
struct raw_trk * trk ;
@@ -261,7 +262,7 @@ static void tag_add_layout(
261
262
sec = & im -> img .sec_info_base [trk -> sec_off ];
262
263
for (i = 0 ; i < layout -> nr_sectors ; i ++ ) {
263
264
sec -> r = i + layout -> base [0 ];
264
- sec -> n = layout -> no ;
265
+ sec -> n = no [ i ] ;
265
266
sec ++ ;
266
267
}
267
268
}
@@ -319,14 +320,17 @@ static bool_t tag_open(struct image *im, char *tag)
319
320
FIL file ;
320
321
struct slot slot ;
321
322
char buf [512 ];
322
- } * heap = (void * )im -> bufs .read_data .p ;
323
+ uint8_t no [256 ];
324
+ } * heap = (void * )im -> bufs .write_bc .p ;
323
325
struct opts opts = {
324
326
.file = & heap -> file ,
325
327
.opts = img_cfg_opts ,
326
328
.arg = heap -> buf ,
327
329
.argmax = sizeof (heap -> buf )- 1
328
330
};
329
331
332
+ ASSERT (sizeof (* heap ) <= im -> bufs .write_bc .len );
333
+
330
334
if (!get_img_cfg (& heap -> slot ))
331
335
return FALSE;
332
336
@@ -340,7 +344,7 @@ static bool_t tag_open(struct image *im, char *tag)
340
344
char * p , * q ;
341
345
/* New section: Finalise any currently-active section. */
342
346
if (active ) {
343
- tag_add_layout (im , & t_layout , nr_t );
347
+ tag_add_layout (im , & t_layout , heap -> no , nr_t );
344
348
finalise_track_map (im );
345
349
active = 0 ;
346
350
}
@@ -372,6 +376,7 @@ static bool_t tag_open(struct image *im, char *tag)
372
376
match = active ;
373
377
reset_all_params (im );
374
378
d_layout = t_layout = dfl_simple_layout ;
379
+ memset (heap -> no , ~0 , sizeof (heap -> no ));
375
380
nr_t = 0 ;
376
381
} else {
377
382
/* Mark ourselves inactive for this section. */
@@ -387,7 +392,7 @@ static bool_t tag_open(struct image *im, char *tag)
387
392
case IMGCFG_tracks : {
388
393
char * p = opts .arg ;
389
394
int c_s , c_e , h_s , h_e , c , h ;
390
- tag_add_layout (im , & t_layout , nr_t );
395
+ tag_add_layout (im , & t_layout , heap -> no , nr_t );
391
396
if (nr_t ++ == 0 )
392
397
d_layout = t_layout ;
393
398
t_layout = d_layout ;
@@ -423,14 +428,24 @@ static bool_t tag_open(struct image *im, char *tag)
423
428
case IMGCFG_step :
424
429
im -> step = strtol (opts .arg , NULL , 10 );
425
430
break ;
426
- case IMGCFG_bps : {
427
- int no , sz = strtol (opts .arg , NULL , 10 );
428
- for (no = 0 ; no < 8 ; no ++ )
429
- if ((128u <<no ) == sz )
430
- break ;
431
- t_layout .no = no ;
431
+ case IMGCFG_bps : {
432
+ char * p , * q ;
433
+ int no = ~0 , i = 0 ;
434
+ for (p = opts .arg ; * p != '\0' ; p = q ) {
435
+ int sz ;
436
+ for (q = p ; * q && * q != ',' ; q ++ )
437
+ continue ;
438
+ if (* q == ',' )
439
+ * q ++ = '\0' ;
440
+ sz = strtol (p , NULL , 10 );
441
+ for (no = 0 ; no < 8 ; no ++ )
442
+ if ((128u <<no ) == sz )
443
+ break ;
444
+ heap -> no [i ++ ] = no ;
445
+ }
446
+ memset (& heap -> no [i ], no , sizeof (heap -> no )- i );
432
447
break ;
433
- }
448
+ }
434
449
case IMGCFG_id :
435
450
t_layout .base [0 ] = strtol (opts .arg , NULL , 0 );
436
451
break ;
@@ -494,7 +509,7 @@ static bool_t tag_open(struct image *im, char *tag)
494
509
}
495
510
496
511
if (active ) {
497
- tag_add_layout (im , & t_layout , nr_t );
512
+ tag_add_layout (im , & t_layout , heap -> no , nr_t );
498
513
finalise_track_map (im );
499
514
}
500
515
0 commit comments