-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmkformat.c
More file actions
116 lines (98 loc) · 2.78 KB
/
dmkformat.c
File metadata and controls
116 lines (98 loc) · 2.78 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* rfloppy - read floppy disks
*
* $Id: dmkformat.c,v 1.3 2002/10/19 23:36:34 eric Exp $
*
* Copyright 2002 Eric Smith.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. Note that permission is
* not granted to redistribute this program under the terms of any
* other version of the General Public License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "libdmk.h"
#define CYLINDER_COUNT 77
int main (int argc, char *argv[])
{
dmk_handle h;
int cylinder;
int i;
sector_info_t sector_info [26];
if (argc != 2)
exit (1);
h = dmk_create_image (argv [1],
0, /* double-sided */
CYLINDER_COUNT,
0, /* not double density */
360, /* RPM */
250); /* rate */
if (! h)
{
fprintf (stderr, "error opening output file\n");
exit (2);
}
for (cylinder = 0; cylinder < CYLINDER_COUNT; cylinder++)
{
if (! dmk_seek (h, cylinder, 0))
{
fprintf (stderr, "error seeking to cylinder %d\n", cylinder);
exit (2);
}
for (i = 0; i < 26; i++)
{
sector_info [i].cylinder = cylinder;
sector_info [i].head = 0;
sector_info [i].sector = i + 1;
sector_info [i].size_code = 0;
sector_info [i].mode = DMK_FM;
sector_info [i].write_data = 1;
sector_info [i].data_value = 0xe5; /* not used */
}
if (! dmk_format_track (h, DMK_FM, 26, sector_info))
{
fprintf (stderr, "error formatting cylinder %d\n", cylinder);
exit (2);
}
}
#ifdef ADDRESS_MARK_DEBUG
for (cylinder = 0; cylinder < CYLINDER_COUNT; cylinder++)
{
if (! dmk_seek (h, cylinder, 0))
{
fprintf (stderr, "error seeking to cylinder %d\n", cylinder);
exit (2);
}
for (i = 1; i <= 26; i++)
{
sector_info [0].cylinder = cylinder;
sector_info [0].head = 0;
sector_info [0].sector = i;
sector_info [0].size_code = 0;
sector_info [0].mode = DMK_FM;
sector_info [0].write_data = 1;
sector_info [0].data_value = 0xe5; /* not used */
if (! dmk_check_address_mark (h, & sector_info [0]))
{
fprintf (stderr, "address mark error on %d/%d\n",
cylinder, i);
exit (2);
}
}
}
#endif /* ADDRESS_MARK_DEBUG */
dmk_close_image (h);
exit (0);
}