summaryrefslogtreecommitdiffstats
path: root/formats.c
blob: f7ff37665ae8424cfa65411a9f1203afe5a1440e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "util.h"

#define F(c,h,s) (c),(h),(s),((c)*(h)*(s))

static const struct diskfmt formats[] =
  {
    { "fd2",	    F( 40,1, 8), 0,  6, { 8, 16 },  8 },
    { "dd80",	    F( 40,1, 8), 0,  6, { 8, 16 },  8 },
    { "fd2d",	    F( 40,1,16), 0,  6, { 8, 16 },  8 },
    { "dd82",	    F( 40,1,16), 0,  6, { 8, 16 },  8 },
    { "abc830",     F( 40,1,16), 0,  6, { 8, 16 },  8 },
    { "abc830-ufd", F( 40,1,16), 0,  6, { 16, 0 }, 16 },
    { "fd4d",       F( 40,2,16), 0,  6, { 8, 16 },  8 },
    { "dd84",       F( 40,2,16), 0,  6, { 8, 16 },  8 },
    { "abc832",     F( 80,2,16), 2, 14, { 16, 0 }, 16 },
    { "abc832",     F( 80,2,16), 2, 14, { 16, 0 }, 16 },
    { "abc834",     F( 80,2,16), 2, 14, { 16, 0 }, 16 },
    /* XXX: right?  I have seen a claim one track "disappears"... */
    { "abc838",     F( 77,2,26), 2, 14, { 16, 0 }, 16 },
    { "hd",         F(238,8,32), 5, 14, { 16, 0 }, 16 },
  };

static const int nformats = (sizeof(formats)/sizeof(formats[0]));

const struct diskfmt *get_format(const char *name)
{
  const struct diskfmt *fmt;
  int i;

  for (i = 0, fmt = formats; i < nformats; i++, fmt++) {
    if (!strcmp(fmt->name, name))
      return fmt;
  }

  return NULL;
}

void show_formats(FILE *f)
{
  const struct diskfmt *fmt;
  int i;

  fprintf(f, "Format        Tracks  Sides  Sec/trk  Cluster  Sectors  Total  System\n");

  for (i = 0, fmt = formats; i < nformats; i++, fmt++) {
    fprintf(f, "%-13s %4d %6d %7d %9d %9d %6dK %3d/%2d\n",
	    fmt->name, fmt->c, fmt->h, fmt->s,
	    1 << fmt->cluster_shift,
	    fmt->sectors, fmt->sectors >> 2, fmt->syssec, fmt->dirsec[0]);
  }
}