1 /* #includes */ /*{{{C}}}*//*{{{*/
14 const char cmd[]="cpmchmod";
16 int main(int argc, char *argv[]) /*{{{*/
18 /* variables */ /*{{{*/
22 const char *devopts=NULL;
24 int c,i,usage=0,exitcode=0;
25 struct cpmSuperBlock drive;
32 /* parse options */ /*{{{*/
33 if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT;
34 while ((c=getopt(argc,argv,"T:f:uh?"))!=EOF) switch(c)
36 case 'T': devopts=optarg; break;
37 case 'f': format=optarg; break;
38 case 'u': uppercase=1; break;
40 case '?': usage=1; break;
43 if (optind>=(argc-2)) usage=1;
47 if (!sscanf(argv[optind++], "%o", &mode)) usage=1;
52 fprintf(stderr,"Usage: %s [-f format] [-u] image mode pattern ...\n",cmd);
56 /* open image */ /*{{{*/
57 if ((err=Device_open(&drive.dev, image, O_RDWR, devopts)))
59 fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err);
62 if (cpmReadSuper(&drive,&root,format,uppercase)==-1)
64 fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo);
68 cpmglob(optind,argc,argv,&root,&gargc,&gargv);
69 for (i=0; i<gargc; ++i)
73 if (cpmNamei(&root,gargv[i], &ino)==-1)
75 fprintf(stderr,"%s: can not find %s: %s\n",cmd,gargv[i],boo);
78 else if (cpmChmod(&ino, mode) == -1)
80 fprintf(stderr,"%s: Failed to set attributes for %s: %s\n",cmd,gargv[i],boo);