1 /* #includes */ /*{{{C}}}*//*{{{*/
17 const char cmd[]="cpmchattr";
19 int main(int argc, char *argv[]) /*{{{*/
21 /* variables */ /*{{{*/
24 const char *format=FORMAT;
25 const char *devopts=NULL;
26 int c,i,usage=0,exitcode=0;
27 struct cpmSuperBlock drive;
34 /* parse options */ /*{{{*/
35 while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c)
37 case 'T': devopts=optarg; break;
38 case 'f': format=optarg; break;
40 case '?': usage=1; break;
43 if (optind>=(argc-2)) usage=1;
47 attrs = argv[optind+1];
52 fprintf(stderr,"Usage: %s [-f format] [-T dsktype] image [NMrsa1234] pattern ...\n",cmd);
56 /* open image */ /*{{{*/
57 if ((err=Device_open(&drive.dev, image, O_RDWR, devopts)))
59 fprintf(stderr,"%s: can not open %s (%s)\n",cmd,image,err);
62 cpmReadSuper(&drive,&root,format);
64 cpmglob(optind,argc,argv,&root,&gargc,&gargv);
65 for (i=0; i<gargc; ++i)
71 rc = cpmNamei(&root,gargv[i], &ino)==-1;
72 if (!rc) rc = cpmAttrGet(&ino, &attrib);
77 for (n = 0; n < strlen(attrs); n++)
83 case 'N': mask = 0; attrib = 0; break;
85 case 'M': mask = 0; m = !m; break;
86 case '1': mask = CPM_ATTR_F1; break;
87 case '2': mask = CPM_ATTR_F2; break;
88 case '3': mask = CPM_ATTR_F3; break;
89 case '4': mask = CPM_ATTR_F4; break;
91 case 'R': mask = CPM_ATTR_RO; break;
93 case 'S': mask = CPM_ATTR_SYS; break;
95 case 'A': mask = CPM_ATTR_ARCV; break;
96 default: fprintf(stderr, "%s: Unknown attribute %c\n", cmd, attrs[n]);
99 if (m) attrib &= ~mask; else attrib |= mask;
101 rc = cpmAttrSet(&ino, attrib);
105 fprintf(stderr,"%s: can not set attributes for %s: %s\n",cmd,gargv[i],boo);