Category : C Source Code
Archive   : JZCHKDSK.ZIP
Filename : JZCHKDSK.DMO

 
Output of file : JZCHKDSK.DMO contained in archive : JZCHKDSK.ZIP
/*
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ Title : jzchkdsk ³
³ This program does many low disk functions similar to chkdsk. ³
³ It demonstrates how to perform low level disk functions from "C". ³
³ Usage: JZCHKDSK ³
³ Compile Spec: msc /Ox /Ze /Zp /I c:\msc\jaz jzchkdsk.dmo; ³
³ link jzchkdsk,,,jzc jzscreen ³
³ ³
³ (C) JazSoft Software by Jack A. Zucker (301) 794-5950 ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*/

#include
#include

#define SIGINT 2 /* int 23h break code */

char startdir[65]; /* starting directory for search */
char gpath[65]; /* global path spec */
int gcount = 0; /* count of non-contiguous clusters */
char *gfat; /* global fat table */
int gbigfat; /* true if big fat table */
int gnumfiles = 0; /* number of files processed */
int gnumclust = 0; /* total clusters processed */
int gbytes,gsectors; /* bytes per sectors,sectors/cluster*/
int NONCONTIG = 0; /* non contiguous list only */
int CONTIG = 0; /* list only contiguous files */
int QUIET = 0; /* quit mode. Don't list anything */
int BADSECTORS= 0; /* look for bad sectors */
int ERROR = 0; /* error flag. Exit program */
int breakkey();
int gdrive; ; /* global drive */

main(argc,argv)
int argc;
char **argv;
{

unsigned int walloc,wsectsize,wclusters;
TFAT wfat;
int w;
unsigned int getbadsect(),wbadsect;
char wbuf[512],*s;
char *woption;
TDISKBLK *wdisk = (TDISKBLK *) wbuf;

getcwd(gpath,64); /* get current path */

strcpy(startdir,argv[2]); /* copy filespec to work variable */

if (strlen(startdir) > 1 && startdir[1] == ':') {
gdrive = toupper(startdir[0]) - 65;
memcpy(startdir,startdir+2,strlen(startdir)-1);
jzlogdrv(gdrive);
}
else
gdrive = jzgetdrv();

if (strcmp(startdir,"\\") == 0) startdir[0] = 0;

strupr(startdir); /* convert to upper case */

woption = argv[1]; /* get options */

if (*woption == '-' || *woption == '/')
for(s = woption+1 ; *s ; s ++)
switch(toupper(*s)) {
case 'N' : NONCONTIG = 1; /* list only non contiguous files */
break;
case 'C' : CONTIG = 1; /* list only contiguous files */
break;
case 'Q' : QUIET = 1; /* don't list anything */
NONCONTIG = 1;
CONTIG = 1;
break;
case 'B' : BADSECTORS = 1; /* look for bad sectors */
break;
case '/' :
case '-' : break;
case '?' : /* set error flag for help text */
default : printf("\nIllegal option %c",*s);
ERROR = 1; /* set error flag */
break;
}

printf("\nJZCHKDSK (C) JazSoft by Jack A. Zucker (301) 794-5950 | 75766,1336");

if (ERROR || ((NONCONTIG || CONTIG) && argc < 3)) {
printf("\nUsage: JZCHKDSK ");
printf("\nOptions: -c List contiguous files");
printf("\n -n List non - contiguous files only");
printf("\n -q Quiet mode. Don't list files at all");
printf("\n -b List Bad Sectors");
printf("\n");
exit(0);
}

signal(SIGINT,breakkey); /* handle control breaks elegantly */

if (! QUIET || ! BADSECTORS) {
printf("\n\n File Total Non Dir Actual");
printf("\n Name Clusters Contig Size Size\n");
}

diskinfo(gdrive,wdisk);

gbytes = wdisk->bytes;
gsectors = wdisk->sectors;

jzdskfre(&wfat,gdrive+1); /* get disk free space */
jzfat(gdrive+1,&walloc,&wsectsize,&wclusters);

gbigfat = wclusters > 4086;

jzgetfat(&gfat,gdrive); /* get the FAT for the spec drive */

if (NONCONTIG || CONTIG) searchdir(startdir); /* search the directory */

if (BADSECTORS) wbadsect = getbadsect(gdrive,wdisk->ttlsect);

if (NONCONTIG || CONTIG) {
printf("\n\nDrive %c",gdrive + 65);
printf("\nNon Contiguous Clusters %d",gcount);
printf("\nNumber of files Processed %d",gnumfiles);
printf("\nPercentage of Contigous files %3.2f",
(float) (gnumclust - gcount) / gnumclust * 100);
printf("\nPercentage of Non Contiguous files %3.2f",
(float) gcount / gnumclust * 100);
}

printf("\nTotal Disk Space %ld",
(long) walloc * wsectsize * wclusters);
printf("\nTotal Clusters %u",wclusters);
printf("\nFree Space (Bytes) %ld",wfat.free);
printf("\nBad Sectors ");
printf(BADSECTORS ? "%u" : "

  3 Responses to “Category : C Source Code
Archive   : JZCHKDSK.ZIP
Filename : JZCHKDSK.DMO

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/