1 /* #includes */ /*{{{C}}}*//*{{{*/
18 const char cmd[]="cpmchmod";
20 int main(int argc, char *argv[]) /*{{{*/
22 /* variables */ /*{{{*/
25 const char *format=FORMAT;
26 const char *devopts=NULL;
27 int c,i,usage=0,exitcode=0;
28 struct cpmSuperBlock drive;
35 /* parse options */ /*{{{*/
36 while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c)
38 case 'T': devopts=optarg; break;
39 case 'f': format=optarg; break;
41 case '?': usage=1; break;
44 if (optind>=(argc-2)) usage=1;
48 if (!sscanf(argv[optind++], "%o", &mode)) usage=1;
53 fprintf(stderr,"Usage: %s [-f format] image mode pattern ...\n",cmd);
57 /* open image */ /*{{{*/
58 if ((err=Device_open(&drive.dev, image, O_RDWR, devopts)))
60 fprintf(stderr,"%s: can not open %s (%s)\n",cmd,image,err);
63 cpmReadSuper(&drive,&root,format);
65 cpmglob(optind,argc,argv,&root,&gargc,&gargv);
66 for (i=0; i<gargc; ++i)
70 if (cpmNamei(&root,gargv[i], &ino)==-1)
72 fprintf(stderr,"%s: can not find %s: %s\n",cmd,gargv[i],boo);
75 else if (cpmChmod(&ino, mode) == -1)
77 fprintf(stderr,"%s: Failed to set attributes for %s: %s\n",cmd,gargv[i],boo);