X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=cpmchmod.c;h=76b70a96011257fda2a518be45d0b0da7ad8d719;hb=edf600144998d1a1e09898548938cc11b95c10bc;hp=00c979fece0c65e3a0c529595957cbd2f93881da;hpb=224b4e6d27a3af235500d9d8028ddbd3a60af7ed;p=debian%2Fcpmtools diff --git a/cpmchmod.c b/cpmchmod.c index 00c979f..76b70a9 100644 --- a/cpmchmod.c +++ b/cpmchmod.c @@ -7,7 +7,7 @@ #include #include -#include "getopt.h" +#include "getopt_.h" #include "cpmfs.h" #ifdef USE_DMALLOC @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) /*{{{*/ /* variables */ /*{{{*/ const char *err; const char *image; - const char *format=FORMAT; + const char *format; const char *devopts=NULL; int c,i,usage=0,exitcode=0; struct cpmSuperBlock drive; @@ -33,6 +33,7 @@ int main(int argc, char *argv[]) /*{{{*/ /*}}}*/ /* parse options */ /*{{{*/ + if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) { case 'T': devopts=optarg; break; @@ -44,8 +45,8 @@ int main(int argc, char *argv[]) /*{{{*/ if (optind>=(argc-2)) usage=1; else { - image=argv[optind]; - if (!sscanf(argv[optind+1], "%o", &mode)) usage=1; + image=argv[optind++]; + if (!sscanf(argv[optind++], "%o", &mode)) usage=1; } if (usage) @@ -78,6 +79,7 @@ int main(int argc, char *argv[]) /*{{{*/ exitcode=1; } } + cpmUmount(&drive); exit(exitcode); } /*}}}*/