@@ -235,9 +235,13 @@ static bool_t raw_type_open(struct image *im, const struct raw_type *type)
235
235
return raw_open (im );
236
236
}
237
237
238
+ struct tag_layout {
239
+ struct simple_layout s ;
240
+ uint8_t no [256 ];
241
+ };
242
+
238
243
static void tag_add_layout (
239
- struct image * im , const struct simple_layout * layout ,
240
- const uint8_t * no , unsigned int trk_idx )
244
+ struct image * im , const struct tag_layout * layout , unsigned int trk_idx )
241
245
{
242
246
struct raw_sec * sec ;
243
247
struct raw_trk * trk ;
@@ -246,23 +250,23 @@ static void tag_add_layout(
246
250
if (trk_idx == 0 )
247
251
init_track_map (im );
248
252
249
- trk = add_track_layout (im , layout -> nr_sectors , trk_idx );
250
- trk -> is_fm = layout -> is_fm ;
251
- trk -> rpm = layout -> rpm ;
252
- trk -> has_iam = layout -> has_iam ;
253
- trk -> gap_2 = layout -> gap2 ;
254
- trk -> gap_3 = layout -> gap3 ;
255
- trk -> gap_4a = layout -> gap4a ;
256
- trk -> data_rate = layout -> data_rate ;
257
- trk -> interleave = layout -> interleave ;
258
- trk -> cskew = layout -> cskew ;
259
- trk -> hskew = layout -> hskew ;
260
- trk -> head = layout -> head ;
253
+ trk = add_track_layout (im , layout -> s . nr_sectors , trk_idx );
254
+ trk -> is_fm = layout -> s . is_fm ;
255
+ trk -> rpm = layout -> s . rpm ;
256
+ trk -> has_iam = layout -> s . has_iam ;
257
+ trk -> gap_2 = layout -> s . gap2 ;
258
+ trk -> gap_3 = layout -> s . gap3 ;
259
+ trk -> gap_4a = layout -> s . gap4a ;
260
+ trk -> data_rate = layout -> s . data_rate ;
261
+ trk -> interleave = layout -> s . interleave ;
262
+ trk -> cskew = layout -> s . cskew ;
263
+ trk -> hskew = layout -> s . hskew ;
264
+ trk -> head = layout -> s . head ;
261
265
262
266
sec = & im -> img .sec_info_base [trk -> sec_off ];
263
- for (i = 0 ; i < layout -> nr_sectors ; i ++ ) {
264
- sec -> r = i + layout -> base [0 ];
265
- sec -> n = no [i ];
267
+ for (i = 0 ; i < layout -> s . nr_sectors ; i ++ ) {
268
+ sec -> r = i + layout -> s . base [0 ];
269
+ sec -> n = layout -> no [i ];
266
270
sec ++ ;
267
271
}
268
272
}
@@ -315,12 +319,12 @@ static bool_t tag_open(struct image *im, char *tag)
315
319
};
316
320
317
321
int match , active , option , nr_t = 0 ;
318
- struct simple_layout t_layout , d_layout ;
319
322
struct {
320
323
FIL file ;
321
324
struct slot slot ;
322
325
char buf [512 ];
323
- uint8_t no [256 ];
326
+ struct tag_layout t_layout ;
327
+ struct tag_layout d_layout ;
324
328
} * heap = (void * )im -> bufs .write_bc .p ;
325
329
struct opts opts = {
326
330
.file = & heap -> file ,
@@ -344,7 +348,7 @@ static bool_t tag_open(struct image *im, char *tag)
344
348
char * p , * q ;
345
349
/* New section: Finalise any currently-active section. */
346
350
if (active ) {
347
- tag_add_layout (im , & t_layout , heap -> no , nr_t );
351
+ tag_add_layout (im , & heap -> t_layout , nr_t );
348
352
finalise_track_map (im );
349
353
active = 0 ;
350
354
}
@@ -375,8 +379,9 @@ static bool_t tag_open(struct image *im, char *tag)
375
379
/* Best score so far: Process the section. */
376
380
match = active ;
377
381
reset_all_params (im );
378
- d_layout = t_layout = dfl_simple_layout ;
379
- memset (heap -> no , ~0 , sizeof (heap -> no ));
382
+ heap -> d_layout .s = dfl_simple_layout ;
383
+ memset (heap -> d_layout .no , ~0 , sizeof (heap -> d_layout .no ));
384
+ heap -> t_layout = heap -> d_layout ;
380
385
nr_t = 0 ;
381
386
} else {
382
387
/* Mark ourselves inactive for this section. */
@@ -392,10 +397,10 @@ static bool_t tag_open(struct image *im, char *tag)
392
397
case IMGCFG_tracks : {
393
398
char * p = opts .arg ;
394
399
int c_s , c_e , h_s , h_e , c , h ;
395
- tag_add_layout (im , & t_layout , heap -> no , nr_t );
400
+ tag_add_layout (im , & heap -> t_layout , nr_t );
396
401
if (nr_t ++ == 0 )
397
- d_layout = t_layout ;
398
- t_layout = d_layout ;
402
+ heap -> d_layout = heap -> t_layout ;
403
+ heap -> t_layout = heap -> d_layout ;
399
404
do {
400
405
/* <cylinder>[-<cylinder>] */
401
406
c_s = strtol (p , & p , 10 );
@@ -423,7 +428,7 @@ static bool_t tag_open(struct image *im, char *tag)
423
428
im -> nr_sides = strtol (opts .arg , NULL , 10 );
424
429
break ;
425
430
case IMGCFG_secs :
426
- t_layout .nr_sectors = strtol (opts .arg , NULL , 10 );
431
+ heap -> t_layout . s .nr_sectors = strtol (opts .arg , NULL , 10 );
427
432
break ;
428
433
case IMGCFG_step :
429
434
im -> step = strtol (opts .arg , NULL , 10 );
@@ -441,50 +446,50 @@ static bool_t tag_open(struct image *im, char *tag)
441
446
for (no = 0 ; no < 8 ; no ++ )
442
447
if ((128u <<no ) == sz )
443
448
break ;
444
- heap -> no [i ++ ] = no ;
449
+ heap -> t_layout . no [i ++ ] = no ;
445
450
}
446
- memset (& heap -> no [i ], no , sizeof (heap -> no )- i );
451
+ memset (& heap -> t_layout . no [i ], no , sizeof (heap -> t_layout . no )- i );
447
452
break ;
448
453
}
449
454
case IMGCFG_id :
450
- t_layout .base [0 ] = strtol (opts .arg , NULL , 0 );
455
+ heap -> t_layout . s .base [0 ] = strtol (opts .arg , NULL , 0 );
451
456
break ;
452
457
case IMGCFG_h :
453
- t_layout .head = (* opts .arg == 'a' ) ? 0
458
+ heap -> t_layout . s .head = (* opts .arg == 'a' ) ? 0
454
459
: (strtol (opts .arg , NULL , 10 ) & 1 ) + 1 ;
455
460
break ;
456
461
case IMGCFG_mode :
457
- t_layout .is_fm = !strcmp (opts .arg , "fm" );
462
+ heap -> t_layout . s .is_fm = !strcmp (opts .arg , "fm" );
458
463
break ;
459
464
case IMGCFG_interleave :
460
- t_layout .interleave = strtol (opts .arg , NULL , 10 );
465
+ heap -> t_layout . s .interleave = strtol (opts .arg , NULL , 10 );
461
466
break ;
462
467
case IMGCFG_cskew :
463
- t_layout .cskew = strtol (opts .arg , NULL , 10 );
468
+ heap -> t_layout . s .cskew = strtol (opts .arg , NULL , 10 );
464
469
break ;
465
470
case IMGCFG_hskew :
466
- t_layout .hskew = strtol (opts .arg , NULL , 10 );
471
+ heap -> t_layout . s .hskew = strtol (opts .arg , NULL , 10 );
467
472
break ;
468
473
case IMGCFG_rpm :
469
- t_layout .rpm = strtol (opts .arg , NULL , 10 );
474
+ heap -> t_layout . s .rpm = strtol (opts .arg , NULL , 10 );
470
475
break ;
471
476
case IMGCFG_gap2 :
472
- t_layout .gap2 = (* opts .arg == 'a' ) ? -1
477
+ heap -> t_layout . s .gap2 = (* opts .arg == 'a' ) ? -1
473
478
: (uint8_t )strtol (opts .arg , NULL , 10 );
474
479
break ;
475
480
case IMGCFG_gap3 :
476
- t_layout .gap3 = (* opts .arg == 'a' ) ? -1
481
+ heap -> t_layout . s .gap3 = (* opts .arg == 'a' ) ? -1
477
482
: (uint8_t )strtol (opts .arg , NULL , 10 );
478
483
break ;
479
484
case IMGCFG_gap4a :
480
- t_layout .gap4a = (* opts .arg == 'a' ) ? -1
485
+ heap -> t_layout . s .gap4a = (* opts .arg == 'a' ) ? -1
481
486
: (uint8_t )strtol (opts .arg , NULL , 10 );
482
487
break ;
483
488
case IMGCFG_iam :
484
- t_layout .has_iam = !strcmp (opts .arg , "yes" );
489
+ heap -> t_layout . s .has_iam = !strcmp (opts .arg , "yes" );
485
490
break ;
486
491
case IMGCFG_rate :
487
- t_layout .data_rate = strtol (opts .arg , NULL , 10 );
492
+ heap -> t_layout . s .data_rate = strtol (opts .arg , NULL , 10 );
488
493
break ;
489
494
case IMGCFG_file_layout : {
490
495
char * p , * q ;
@@ -509,7 +514,7 @@ static bool_t tag_open(struct image *im, char *tag)
509
514
}
510
515
511
516
if (active ) {
512
- tag_add_layout (im , & t_layout , heap -> no , nr_t );
517
+ tag_add_layout (im , & heap -> t_layout , nr_t );
513
518
finalise_track_map (im );
514
519
}
515
520
0 commit comments