X-Git-Url: https://git.gag.com/?p=debian%2Fcpmtools;a=blobdiff_plain;f=cpmcp.c;h=561c451f51a439d4134e4a42b37d42a027965c9a;hp=590e702aa887177c06e7d39599a2b05dd7335162;hb=b1e873c5b2f6376bb39ff0fda1464cbbacbae5f7;hpb=edf600144998d1a1e09898548938cc11b95c10bc diff --git a/cpmcp.c b/cpmcp.c index 590e702..561c451 100644 --- a/cpmcp.c +++ b/cpmcp.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -64,7 +63,7 @@ static int cpmToUnix(const struct cpmInode *root, const char *src, const char *d int res; char buf[4096]; - while ((res=cpmRead(&file,buf,sizeof(buf)))!=0) + while ((res=cpmRead(&file,buf,sizeof(buf)))>0) { int j; @@ -93,6 +92,7 @@ static int cpmToUnix(const struct cpmInode *root, const char *src, const char *d } } endwhile: + if (res==-1 && !ohno) { fprintf(stderr,"%s: can not read %s (%s)\n",cmd,src,boo); exitcode=1; ohno=1; } if (fclose(ufp)==EOF && !ohno) { fprintf(stderr,"%s: can not close %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; } if (preserve && !ohno && (ino.atime || ino.mtime)) { @@ -178,10 +178,14 @@ int main(int argc, char *argv[]) /* open image file */ /*{{{*/ if ((err=Device_open(&super.dev,image,readcpm ? O_RDONLY : O_RDWR, 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); + } + if (cpmReadSuper(&super,&root,format)==-1) + { + fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); exit(1); } - cpmReadSuper(&super,&root,format); /*}}}*/ if (readcpm) /* copy from CP/M to UNIX */ /*{{{*/ { @@ -255,7 +259,7 @@ int main(int argc, char *argv[]) cpmOpen(&ino,&file,O_WRONLY); do { - int j; + unsigned int j; for (j=0; j<(sizeof(buf)/2) && (c=getc(ufp))!=EOF; ++j) { @@ -263,7 +267,7 @@ int main(int argc, char *argv[]) buf[j]=c; } if (text && c==EOF) buf[j++]='\032'; - if (cpmWrite(&file,buf,j)!=j) + if (cpmWrite(&file,buf,j)!=(ssize_t)j) { fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,boo); ohno=1;