Esempio n. 1
0
void main(void) {
  unsigned long numSectors;

  /* init interrupts */
  initInterrupts();
  /* check disk ready */
  if (!checkDiskReady()) {
    error("disk not ready");
  }
  /* determine disk size */
  numSectors = getDiskSize();
  printf("Disk has %lu (0x%lX) sectors.\n",
         numSectors, numSectors);
  if (numSectors < 32) {
    error("disk is too small");
  }
  /* copy boot block to write buffer */
  copyBootBlock();
  /* write boot block to disk */
  printf("Writing boot block to disk...\n");
  if (!writeDisk(0, 32, wrBuf)) {
    error("cannot write boot block to disk");
  }
  /* done */
  printf("Halting...\n");
}
Esempio n. 2
0
/*************** MAIN PROGRAM ******************************/
int main(int arg_count, char **args)
{
  char startpath[_MAX_PATH], *apu;
  char *defaultdir = ".";
  unsigned long disk_size,disk_free, summa;
  double slack;

  printf("\nDU/" VERSION_BITS "bit v" VERSION_NO
	 "     Copyright (c) Timo Kokkonen, OH6LXV               "
	 RELEASE_DATE "\n\n");

  strcpy(startpath,".");
  if (arg_count>1) {
    if (!strcmp(args[1],"/?")) {
      print_syntax();
      exit(0);
    }
    if (args[arg_count-1][0]=='/')
     if (sscanf(&args[arg_count-1][1],"%d",&sublevels)!=1) {
       printf("\nInvalid parameter '%s'.\n",args[arg_count-1]);
       print_syntax();
       exit(1);
     }
  }
  if ((arg_count>=2)&&(args[1][0]!='/'))  apu=args[1];
    else apu=defaultdir;

  if (!_fullpath(startpath,apu,_MAX_PATH)) {
    printf("Cannot convert '%s' to absolute path.\n",apu);
    exit(1);
  }
  if (startpath[strlen(startpath)-1]!='\\') strcat(startpath,"\\");
  strcpy(startpath,SplitDir(startpath));

  if (!getDiskSize(startpath[0]-64,&disk_size,&disk_free,&cluster_size)) {
    printf("Cannot read drive %c: \n",startpath[0]);
    exit(1);
  }
  summa=calc_dir(startpath);
  if (true_sum!=0) slack=(1-(double)summa/true_sum)*100.0;
    else slack=0;

  // printf(" %lu  %lu  %lu \n",disk_size-disk_free,summa,true_sum);
  printf("\n %lu bytes in %lu file(s), %1.1lf%% slack (%lu bytes).\n",
							true_sum,
							file_counter,
							slack,
							true_sum-summa);
  return 0;
}
Esempio n. 3
0
int main(void)
{
  int maxdrives,curdrive, x;
  unsigned long disksize,diskfree,clustersize,sizesum=0,freesum=0;
  unsigned long capacity;
  char label[41],file_system[256];

  #ifdef __OS2__
   DosError(FERR_DISABLEHARDERR|FERR_ENABLEEXCEPTION);
  #endif

  printf("\nDF/" VERSION_BITS "bit v" VERSION_NO
	 "     Copyright (c) Timo Kokkonen, OH6LXV  "
	 "             " RELEASE_DATE "\n\n");

  curdrive=getdisk();
  maxdrives=setdisk(curdrive);
  if (maxdrives-2<=0) return 1;

  printf("disk               free       used      total capacity  cluster   file system\n");
  for(x=3;x<=maxdrives;x++) {
    label[0]=0;
    file_system[0]=0;
    #ifdef __MSDOS__
    if (!DriveExists(x)) continue;
    #endif
    if (getDiskSize(x,&disksize,&diskfree,&clustersize)) {
      getDiskLabel(x,label);
      strcpy(file_system,getIFSname(x));
    }
    sizesum+=disksize; freesum+=diskfree;
    if (disksize==0) capacity=0;
      else capacity=((disksize-diskfree)/(disksize/100));

    printf("%c:%-12s %8luk  %8luk  %8luk  %3lu%%  %5lu bytes   %-8s \n",
       x+64,label,diskfree/1024,(disksize-diskfree)/1024,disksize/1024,
       capacity,clustersize,file_system);
  }

  printf("\nTotal:        %9luk %9luk %9luk  %3lu%% \n",
     freesum/1024,(sizesum-freesum)/1024,sizesum/1024,
     (sizesum-freesum)/(sizesum/100));

  return 0;
}