-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlchk.cpp
More file actions
298 lines (285 loc) · 9.45 KB
/
Copy pathlchk.cpp
File metadata and controls
298 lines (285 loc) · 9.45 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// lren
#include "lfn.cpp"
void GetCDFSInfo(struct DPB *d) {
struct iso_primary_descriptor desc;
int cy,usc2,joliet,sector;
joliet=0;
sector=VTOC_START;
#ifdef LANG_EN
printf("Physical File Systems:\n");
printf("#\tID\tEnc\tRoot\n");
#endif
#ifdef LANG_DE
printf("Physikalische Datei Systeme:\n");
printf("#\tID\tEnc\tRoot\n");
#endif
cy=readCDSectorsP(d,sector+d->CD_vol_start,1,&desc);
if (cy!=0) return;
while ((desc.type_of_descriptor!=0xff)) {
usc2= ((desc.esc_seq[0]=='%') && (desc.esc_seq[1]=='/'))
&& ((desc.esc_seq[2]=='@') || (desc.esc_seq[2]=='C') || (desc.esc_seq[2]=='E'));
printf("%.2X\t%.5s\t%.3s\t%.u", desc.type_of_descriptor, desc.ID, ((desc.vol_flags & 1)==0) ? usc2 ? "Uni" : desc.esc_seq : "ASC", desc.root_start);
if (desc.type_of_descriptor == 0) printf("\t(boot)");
printf("\n");
sector++;
cy=readCDSectorsP(d,sector+d->CD_vol_start,1,&desc);
if (cy!=0) return;
}
}
void GetTrackInfo(char drive)
{
AudioDiskInfo adi;
AudioTrackInfo ati;
byte track, dataTrack;
#ifdef LANG_EN
printf("Information on CD-ROM sessions:\n");
#endif
#ifdef LANG_DE
printf("CD-ROM Session Informationen:\n");
#endif
if (GetAudioDiskInfo(drive,0,&adi)!=0)
{
printf("Tracks: %u - %u\n",adi.firstTrack,adi.lastTrack);
if (adi.lastTrack>=adi.firstTrack)
{
#ifdef LANG_EN
printf("List of tracks:\n");
printf("Track #\tStart Type\n");
#endif
#ifdef LANG_DE
printf("Liste der Tracks:\n");
printf("Track #\tStart Typ\n");
#endif
dataTrack=0;
for (track=adi.firstTrack;track<=adi.lastTrack;track++) //Mixed-Mode
{
GetAudioTrackInfo(drive,0,track,&ati);
if ((ati.trackInfo & DATA_TRACK)!=0) dataTrack=track;
printf("%.2u\t%.2u:%.2u.%.2u ",track,ati.start.minute,ati.start.second,ati.start.frame);
if ((ati.trackInfo & DATA_TRACK) !=0) printf("DATA\n");
else printf("AUDIO\n");
}
if (dataTrack==0)
{
#ifdef LANG_EN
printf("No data track found!\n");
#endif
#ifdef LANG_DE
printf("Kein Datentrack gefunden!\n");
#endif
return;
}
}
else //CD-Extra
{
#ifdef LANG_EN
printf("This is probably a CD-Extra (1 Audio Session, 1 Data Session)\n");
#endif
#ifdef LANG_DE
printf("Dies ist vermutlich eine CD-Extra (1 Audio Session, 1 Daten Session)\n");
#endif
return;
}
}
}
void PrintDPB(struct DPB &b)
{
struct dosver ver;
getDOSver(&ver);
#ifdef LANG_EN
printf("Version ");printf(LFN_VER);printf("\n");
printf("Copyright (C) 1999 Ortwin Glueck\nThis is free software under GPL. See the readme file for details.\n\n");
printf("DOS Version: %X-%u.%u\tCode page: %u\n",ver.oem,ver.main,ver.sub, getDOSActiveCP());
printf("Drive: %u\nBytes per Sector: %u\n",b.drive,b.bytes_per_sector);
#endif
#ifdef LANG_DE
printf("Version ");printf(LFN_VER);printf("\n");
printf("Copyright (C) 1999 Ortwin Glck\nDies ist freie Software unter der GPL. Siehe readme Datei fr Details.\n\n");
printf("DOS Version: %X-%u.%u\tCode page: %u\n",ver.oem,ver.main,ver.sub, getDOSActiveCP());
printf("Laufwerk: %u\nBytes pro Sektor: %u\n",b.drive,b.bytes_per_sector);
#endif
if (b.fat_type==CD)
{
GetCDFSInfo(&b);
GetTrackInfo(b.drive);
#ifdef LANG_EN
printf("First Root Sector: %u\n",b.first_root_sector);
printf("Session Size: %lu\n",b.no_sectors);
printf("Session Start: %lu\n",b.CD_vol_start);
#endif
#ifdef LANG_DE
printf("Erster Root Sektor: %u\n",b.first_root_sector);
printf("Session Gr”sse: %lu\n",b.no_sectors);
printf("Session Start: %lu\n",b.CD_vol_start);
#endif
}
else
{
#ifdef LANG_EN
printf("Sectors per Cluster: %u\n",b.sectors_per_cluster);
printf("Number of Clusters: %lu\n",b.no_clusters);
printf("Number of FATs: %u Number of Root entries: %u\n",b.no_fats,b.no_root_entries);
printf("Media Descriptor: %x\nSectors per FAT: %lu\n",b.media_descriptor,b.sectors_per_fat);
printf("Sectors / reserved: %lu / %u\n",b.no_sectors,b.reserved_sectors);
printf("First Data Sector: %lu\n",b.first_data_sector);
printf("First Root Sector/Cluster: %lu/%lu\n",b.first_root_sector,b.first_root_cluster);
printf("Root Sectors: %u\nFat entries per Sector: %u\n",b.no_root_sectors,b.fat_entries_per_sector);
#endif
#ifdef LANG_DE
printf("Sektoren pro Cluster: %u\n",b.sectors_per_cluster,b.reserved_sectors);
printf("Anzahl Clusters: %lu\n",b.no_clusters);
printf("Anzahl FATs: %u Anzahl Root Eintr„ge: %u\n",b.no_fats,b.no_root_entries);
printf("Media Descriptor: %x\nSektoren pro FAT: %lu\n",b.media_descriptor,b.sectors_per_fat);
printf("Sektoren / reserviert: %lu / %u\n",b.no_sectors,b.reserved_sectors);
printf("Erster Datensektor: %lu\n",b.first_data_sector);
printf("Erster Root Sektor/Cluster: %lu/%lu\n",b.first_root_sector,b.first_root_cluster);
printf("Root Sektoren: %u\nFAT-Eintr„ge pro Sektor: %u\n",b.no_root_sectors,b.fat_entries_per_sector);
#endif
}
#ifdef LANG_EN
printf("Label: %.32s\n",b.label);
printf("File System: ");
#endif
#ifdef LANG_DE
printf("Bezeichnung: %.32s\n",b.label);
printf("Dateisystem: ");
#endif
switch (b.fat_type)
{
case FAT12: printf("FAT12\n");break;
case FAT16: printf("FAT16\n");break;
case FAT32: printf("FAT32\n");break;
case CD: printf("CD-ROM: ");
switch (b.cdfs)
{
case CD_NO:
#ifdef LANG_EN
printf("Unknown\n");
#endif
#ifdef LANG_DE
printf("Unbekannt\n");
#endif
break;
case CD_ISO: printf("ISO-9660\n");break;
case CD_JOLIET: printf("Microsoft Joliet\n");break;
}
break;
default:
#ifdef LANG_EN
printf("Unknown\n");
#endif
#ifdef LANG_DE
printf("Unbekannt\n");
#endif
break;
}
#ifdef LANG_EN
printf("FAT32 compatible disk access ");
#endif
#ifdef LANG_DE
printf("FAT32 kompatibler Zugriffsmodus ");
#endif
#ifdef LANG_EN
if (win98==1) printf("enabled\n");
else printf("disabled\n");
#endif
#ifdef LANG_DE
if (win98==1) printf("wird bentzt\n");
else printf("wird nicht bentzt\n");
#endif
#ifdef LANG_EN
printf("Volume locking ");
if (noLocking==1) printf("disabled\n");
else printf("enabled\n");
#endif
#ifdef LANG_DE
printf("Laufwerkssperrung ");
if (noLocking==1) printf("wird nicht bentzt\n");
else printf("wird bentzt\n");
#endif
#ifdef LANG_EN
printf("Cache: ");
if (bypassCache) printf("disabled\n");
else {
if (useVMCache!=0) {
#ifdef VMEMORY
printf("virtual, areas: %u, pages per area: %u, mem used:%lu bytes\n",no_cache_areas,no_pages_per_area,((long)no_cache_areas*no_pages_per_area*sizeof(cachepage)));
#endif
}
else printf("standard\n");
}
#endif
#ifdef LAND_DE
printf("Cache: ");
if (bypassCache) printf("abgeschaltet\n");
else {
if (useVMCache!=0) {
#ifdef VMEMORY
printf("virtuell, Bereiche: %u, pages per area: %u, RAM belegt:%lu Bytes\n",no_cache_areas,no_pages_per_area,((long)no_cache_areas*no_pages_per_area*sizeof(cachepage)));
#endif
}
else printf("normal\n");
}
#endif
}
int FSInfo(const struct DPB *b)
//FAT32 only
//allocated_clusters: relative number of newly allocated clusters, negative values are freed clusters
{
struct BIGFATBOOTFSINFO *fsi;
if (b->fat_type!=FAT32) return 1;
fsi=(struct BIGFATBOOTFSINFO*)malloc(b->bytes_per_sector);
if (fsi==NULL)
{
printf(msg[27]);
return 1;
}
readSector(b->drive,b->fs_info_sector,1,fsi);
if ((fsi->start_signature==0x41615252) && (fsi->signature==0x61417272) && (fsi->end_signature==0xAA550000)) {
if (fsi->no_free_clusters!=-1)
{
#ifdef LANG_EN
printf("Free clusters: %lu",fsi->no_free_clusters);
#endif
#ifdef LANG_DE
printf("Freie Cluster: %lu",fsi->no_free_clusters);
#endif
}
else {
#ifdef LANG_EN
printf("Free clusters: unknown");
#endif
#ifdef LANG_DE
printf("Freie Cluster: unbekannt");
#endif
}
#ifdef LANG_EN
printf(" Next free cluster: %lu\n",fsi->next_free_cluster);
#endif
#ifdef LANG_DE
printf(" N„chster freier Cluster: %lu\n",fsi->next_free_cluster);
#endif
}
else {
#ifdef LANG_EN
printf("Extended filesystem information record signatures invalid!\n");
#endif
#ifdef LANG_DE
printf("Erweiterte Dateisystem Info-Signaturen ungltig!\n");
#endif
}
free(fsi);
return 0;
}
void main(int argc,char *argv[],char* envp[])
{
struct DPB Disk;
byte drv;
initLFNLib();
if (argc==0) drv=drive_of_path(NULL);
else drv=drive_of_path(argv[1]);
makeDPB(drv,Disk); //we dont care for errors. lchk is diagnostic software!
PrintDPB(Disk);
FSInfo(&Disk);
killCache();
}