-
Notifications
You must be signed in to change notification settings - Fork 1
/
srdisk.c
executable file
·127 lines (101 loc) · 3.04 KB
/
srdisk.c
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
117
118
119
120
121
122
123
124
125
126
/*
* ReSizeable RAMDisk formatter
*
* Copyright (C) 1992-1996, 2005 Marko Kohtala
* Released under GNU GPL, read the file 'COPYING' for more information
*
* Compilable with Borland C++ 3.0.
*
*/
#include "srdisk.h"
#include <stdio.h>
#include <time.h>
word forced_format; /* What values user explicitly defined for newf */
word defined_format; /* What values user defined for newf */
word changed_format; /* Differences between f and newf */
word root_files = 1; /* Number of entries in root directory */
word max_bps = 512; /* Largest possible sector size on system */
char drive=0;
int force_f=0; /* -1 if not to, 0 to ask, 1 to destroy data */
struct config_s far *mainconf; /* First drive configuration structure */
struct config_s far *conf; /* Current drive configuration structure */
struct format_s f, newf;
int return_val = 0; /* ERRORLEVEL value to return */
char *return_msg; /* Pointer to message to display on exit */
char *exename; /* Name of the executable */
/* To get enough stack */
unsigned _stklen = 0x1000;
void force_banner(void)
{
static int wrote_banner = 0;
if (!wrote_banner) {
printf("ReSizeable RAMDisk Formatter version "VERSION". "
"Copyright (c) 2005 Marko Kohtala.\n\n");
wrote_banner = 1;
}
}
void print_banner(void)
{
if (verbose == -1 || verbose > 0)
force_banner();
}
/*
** MAIN FUNCTION
*/
int main(int argc, char *argv[])
{
extern int mem_allocated;
exename = *argv[0] ? argv[0] : "SRDISK.EXE";
if (argc > 1) parse_cmdline(argc, argv);
print_banner();
if (argc == 1)
printf("For help type 'SRDISK /?'.\n\n");
{ /* This is to solve a strange problem I am having with DR-DOS 5
DR-DOS 5 seems to get into infinite loop reading FAT if sector
size is larger than 128 bytes!
*/
max_bps = 512;
#if 0 /* !!!! This is just to test if the bug has been solved */
asm {
mov ax,0x4452
stc
int 0x21
jc notDRDOS
cmp ax,dx
jne notDRDOS
cmp ax,0x1065
jne notDRDOS /* Actually "not DR-DOS 5" */
}
/* It is DR-DOS 5, so limit the sector size */
max_bps = 128;
if (newf.bps > max_bps) {
warning("Sector size is limited to 128 bytes under DR-DOS 5");
newf.bps = max_bps;
}
notDRDOS:
#endif
}
if (verbose == -1) verbose = 2;
init_drive(); /* Find drive and collect old configuration */
if (defined_format || bootsectorfile) { /* If new format defined */
format_disk();
if (error_count) {
warning("The disk is possibly damaged because of the errors\n");
}
if (mem_allocated && isWinEnh() && verbose > 1) {
warning("Memory allocated for disk under MS-Windows will be released when you\n"
"end this DOS session\n");
}
}
else {
if (f_set_env != YES && 1 < verbose && verbose < 4) {
if (f.size) print_format(&f);
else printf("Drive %c: disabled\n", drive);
}
}
if (f_set_env == YES)
set_env();
if (return_msg)
puts(return_msg);
return return_val;
}