1 /* #includes */ /*{{{C}}}*//*{{{*/
13 const char cmd[]="cpmchmod";
15 int main(int argc, char *argv[]) /*{{{*/
17 /* variables */ /*{{{*/
20 const char *format=FORMAT;
21 const char *devopts=NULL;
22 int c,i,usage=0,exitcode=0;
23 struct cpmSuperBlock drive;
30 /* parse options */ /*{{{*/
31 while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c)
33 case 'T': devopts=optarg; break;
34 case 'f': format=optarg; break;
36 case '?': usage=1; break;
39 if (optind>=(argc-2)) usage=1;
43 if (!sscanf(argv[optind+1], "%o", &mode)) usage=1;
48 fprintf(stderr,"Usage: %s [-f format] image mode pattern ...\n",cmd);
52 /* open image */ /*{{{*/
53 if ((err=Device_open(&drive.dev, image, O_RDWR, devopts)))
55 fprintf(stderr,"%s: can not open %s (%s)\n",cmd,image,err);
58 cpmReadSuper(&drive,&root,format);
60 cpmglob(optind,argc,argv,&root,&gargc,&gargv);
61 for (i=0; i<gargc; ++i)
65 if (cpmNamei(&root,gargv[i], &ino)==-1)
67 fprintf(stderr,"%s: can not find %s: %s\n",cmd,gargv[i],boo);
70 else if (cpmChmod(&ino, mode) == -1)
72 fprintf(stderr,"%s: Failed to set attributes for %s: %s\n",cmd,gargv[i],boo);