1 /* #includes */ /*{{{C}}}*//*{{{*/
18 const char cmd[]="cpmchmod";
20 int main(int argc, char *argv[]) /*{{{*/
22 /* variables */ /*{{{*/
26 const char *devopts=NULL;
27 int c,i,usage=0,exitcode=0;
28 struct cpmSuperBlock drive;
35 /* parse options */ /*{{{*/
36 if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT;
37 while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c)
39 case 'T': devopts=optarg; break;
40 case 'f': format=optarg; break;
42 case '?': usage=1; break;
45 if (optind>=(argc-2)) usage=1;
49 if (!sscanf(argv[optind++], "%o", &mode)) usage=1;
54 fprintf(stderr,"Usage: %s [-f format] image mode pattern ...\n",cmd);
58 /* open image */ /*{{{*/
59 if ((err=Device_open(&drive.dev, image, O_RDWR, devopts)))
61 fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err);
64 if (cpmReadSuper(&drive,&root,format)==-1)
66 fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo);
70 cpmglob(optind,argc,argv,&root,&gargc,&gargv);
71 for (i=0; i<gargc; ++i)
75 if (cpmNamei(&root,gargv[i], &ino)==-1)
77 fprintf(stderr,"%s: can not find %s: %s\n",cmd,gargv[i],boo);
80 else if (cpmChmod(&ino, mode) == -1)
82 fprintf(stderr,"%s: Failed to set attributes for %s: %s\n",cmd,gargv[i],boo);