home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------ */
- /* GDI.C */
- /* Diskinformation */
- /* (C) 1991 Michael Gruteser & TOOLBOX */
- /* ------------------------------------------------------ */
- #include <stdio.h>
- #include <ctype.h>
- #include <dir.h>
- #include <dos.h>
- #include <errno.h>
- #include "lwinfo.h"
-
- bootsec_info_t lwinfo;
- struct fatinfo fat;
- media_t mdinfo;
-
- main(int argc, char **argv) {
-
- int error;
- int count;
- int lw;
- int nimmdisk();
- void ausgabe();
-
- printf ("Disketten Information ");
- switch (argc) {
- case 1 : lw = getdisk();
- break;
- case 2 : lw = nimmdisk(argv[1]);
- break;
- default : printf("Falsche Anzahl von Argumenten.\n");
- exit(1);
- }
- count = 20;
- do {
- count--;
- error = get_bootsecinfo(lw, &lwinfo);
- }
- while ((error != 0) && (count > 0));
- if (error != EZERO) {
- switch (errno) {
- case EACCES : printf("Zugriff verweigert.\n");
- break;
- case EINVDRV : printf("Laufwerk nicht gültig.\n");
- break;
- default : printf("Allgemeiner Fehler.\n");
- }
- exit(1);
- }
- getfat (lw+1, &fat);
- ausgabe(lw);
- return 0;
- }
-
- int nimmdisk(char *str) {
-
- int error;
- int lw;
-
- error = 0;
- if (strlen(str) != 2)
- error = 1;
- if (str[1] != ':')
- error = 1;
- if (error == 1) {
- printf("Syntax-Error");
- exit(1);
- }
- lw = toupper(str[0]) - 0x41;
- return(lw);
- }
-
- void ausgabe(int lw) {
-
- printf("Informationen über das Laufwerk Nr.: %d ");
- printf("Bezeichnung : %c:\n", lw, lw+0x41);
- printf("Information ");
- printf("von DOS vom BIOS\n");
- printf("=========================================");
- printf("===================================\n");
- printf("System Identifikation ")
- printf(" %s\n", lwinfo.hersteller);
- printf("Media Descriptor ");
- printf(" %x\n");
- printf(lwinfo.mediadescriptor & 0xff));
- printf("Bytes pro Sektor %-6d");
- printf(" %-6d\n", fat.fi_bysec);
- printf("lwinfo.bytes_pro_sektor);
- printf("Sektoren pro Cluster %d");
- printf(" %d\n", fat.fi_sclus);
- printf("lwinfo.sektoren_pro_cluster);
- printf("Anzahl der FATs ");
- printf(" %d\n", lwinfo.fat_anzahl);
- printf("Anzahl der Einträge H.-Verzeichnis ");
- printf(" %-6d\n");
- printf(lwinfo.root_dir_eintraege);
- printf("Sektoren pro Fat ");
- printf(" %d\n",lwinfo.sektoren_pro_fat);
- printf("Anzahl der Cluster %-6u\n");
- printf(fat.fi_nclus);
- printf("Anzahl der Sektoren ");
- printf(" %-6u\n",lwinfo.sektorenanzahl);
- printf("Offset der Fat ");
- printf(" %d\n");
- printf(lwinfo.reservierte_sektoren);
- printf("Offset des H.-Verzeichnisses %-6d\n",
- lwinfo.reservierte_sektoren + lwinfo.fat_anzahl *
- lwinfo.sektoren_pro_fat);
- printf("Offset zu den Daten %-6d\n",
- 1+
- 32*lwinfo.root_dir_eintraege/lwinfo.bytes_pro_sektor+
- lwinfo.sektoren_pro_fat *
- lwinfo.fat_anzahl);
- printf("Sektoren pro Spur ");
- printf(" %-6d\n", lwinfo.sektoren_pro_spur);
- printf("Anzahl der Seiten ");
- printf(" %d\n", lwinfo.seiten);
- printf("Versteckte Sektoren ");
- printf(" %d\n", lwinfo.versteckte_sektoren);
- printf("Fatgröße in Bit ");
- printf(" %d\n");
- printf(((lwinfo.sektorenanzahl/8) < 4086) ? 12 : 16);
- printf("\n");
- }
-
- /* ------------------------------------------------------ */
- /* Ende von GDI.C */