10 * ISO 9660 file names must be uppercase, digits, or underscore.
11 * We use lowercase, digits, and underscore, translating lower to upper
12 * in mkisostring, and upper to lower in isostring.
13 * Files with uppercase letters in their names are thus nonconforming.
14 * Conforming files also must have a basename
15 * at most 8 letters and at most one suffix of at most 3 letters.
18 isostring(uchar *buf, int len)
25 while(len > 0 && p[len-1] == ' ')
28 *q = tolower((uchar)*q);
37 if(c >= '0' && c <= '9')
39 if(c >= 'a' && c <= 'z')
53 if((p = strchr(s, '.')) != nil) {
72 * we rename files of the form [FD]dddddd
73 * so they don't interfere with us.
75 if(strlen(s) == 7 && (s[0] == 'D' || s[0] == 'F')) {
77 if(s[i] < '0' || s[i] > '9')
87 * ISO9660 name comparison
89 * The standard algorithm is as follows:
90 * Take the filenames without extensions, pad the shorter with 0x20s (spaces),
91 * and do strcmp. If they are equal, go on.
92 * Take the extensions, pad the shorter with 0x20s (spaces),
93 * and do strcmp. If they are equal, go on.
94 * Compare the version numbers.
96 * Since Plan 9 names are not allowed to contain characters 0x00-0x1F,
97 * the padded comparisons are equivalent to using strcmp directly.
98 * We still need to handle the base and extension differently,
99 * so that .foo sorts before !foo.foo.
102 isocmp(const void *va, const void *vb)
105 char s1[32], s2[32], *b1, *b2, *e1, *e2;
111 strecpy(s1, s1+sizeof s1, a->confname);
113 strecpy(s2, s2+sizeof s2, b->confname);
115 if((e1 = strchr(b1, '.')) != nil)
119 if((e2 = strchr(b2, '.')) != nil)
124 if((i = strcmp(b1, b2)) != 0)
127 return strcmp(e1, e2);
131 mkisostring(char *isobuf, int n, char *s)
136 for(p=s, q=isobuf; *p && q < eq; p++)
137 if('a' <= *p && *p <= 'z')
149 Cputisopvd(Cdimg *cd, Cdinfo info)
153 Cputc(cd, 1); /* primary volume descriptor */
154 Cputs(cd, "CD001", 5); /* standard identifier */
155 Cputc(cd, 1); /* volume descriptor version */
156 Cputc(cd, 0); /* unused */
158 assert(~info.flags & (CDplan9|CDrockridge));
160 /* system identifier */
162 if(info.flags & CDplan9)
163 strcat(buf, "plan 9 ");
164 if(info.flags & CDrockridge)
165 strcat(buf, "rrip ");
166 if(info.flags & CDbootable)
167 strcat(buf, "boot ");
168 if(info.flags & CDconform)
169 strcat(buf, "iso9660");
176 Cputs(cd, mkisostring(buf, 32, info.volumename), 32); /* volume identifier */
178 Crepeat(cd, 0, 8); /* unused */
179 Cputn(cd, 0, 4); /* volume space size */
180 Crepeat(cd, 0, 32); /* unused */
181 Cputn(cd, 1, 2); /* volume set size */
182 Cputn(cd, 1, 2); /* volume sequence number */
183 Cputn(cd, Blocksize, 2); /* logical block size */
184 Cputn(cd, 0, 4); /* path table size */
185 Cputnl(cd, 0, 4); /* location of Lpath */
186 Cputnl(cd, 0, 4); /* location of optional Lpath */
187 Cputnm(cd, 0, 4); /* location of Mpath */
188 Cputnm(cd, 0, 4); /* location of optional Mpath */
189 Cputisodir(cd, nil, DTroot, 1, Cwoffset(cd)); /* root directory */
191 Cputs(cd, mkisostring(buf, 128, info.volumeset), 128); /* volume set identifier */
192 Cputs(cd, mkisostring(buf, 128, info.publisher), 128); /* publisher identifier */
193 Cputs(cd, mkisostring(buf, 128, info.preparer), 128); /* data preparer identifier */
194 Cputs(cd, mkisostring(buf, 128, info.application), 128); /* application identifier */
196 Cputs(cd, "", 37); /* copyright notice */
197 Cputs(cd, "", 37); /* abstract */
198 Cputs(cd, "", 37); /* bibliographic file */
199 Cputdate1(cd, now); /* volume creation date */
200 Cputdate1(cd, now); /* volume modification date */
201 Cputdate1(cd, 0); /* volume expiration date */
202 Cputdate1(cd, 0); /* volume effective date */
203 Cputc(cd, 1); /* file structure version */