#include <stdlib.h>
#include <errno.h>
-#include "getopt.h"
+#include "getopt_.h"
#include "cpmdir.h"
#include "cpmfs.h"
if (block>0)
{
++usedBlocks;
- if (block<min || block>max)
+ if (block<min || block>=max)
{
printf("Error: Bad block number (extent=%d, name=\"%s\", block=%d)\n",extent,prfile(sb,extent),block);
if (ask("Remove file"))
{
const char *err;
const char *image;
- const char *format=FORMAT;
+ const char *format;
const char *devopts=NULL;
int c,usage=0;
struct cpmSuperBlock sb;
struct cpmInode root;
enum Result ret;
+ if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT;
while ((c=getopt(argc,argv,"T:f:nh?"))!=EOF) switch(c)
{
case 'f': format=optarg; break;
}
if (optind!=(argc-1)) usage=1;
- else image=argv[optind];
+ else image=argv[optind++];
if (usage)
{
{
if ((err=Device_open(&sb.dev, image,O_RDONLY, devopts)))
{
- fprintf(stderr,"%s: can not open %s: %s\n",cmd,image,err);
+ fprintf(stderr,"%s: cannot open %s: %s\n",cmd,image,err);
exit(1);
}
else
{
- fprintf(stderr,"%s: can not open %s for writing, no repair possible\n",cmd,image);
+ fprintf(stderr,"%s: cannot open %s for writing, no repair possible\n",cmd,image);
}
}
- cpmReadSuper(&sb,&root,format);
+ if (cpmReadSuper(&sb,&root,format)==-1)
+ {
+ fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo);
+ exit(1);
+ }
ret=fsck(&root,image);
if (ret&MODIFIED)
{