From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) From: arisawa In-Reply-To: Date: Thu, 17 Dec 2015 22:05:45 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <5E232682-7ABD-4564-96C1-89B1540FC4E2@ar.aichi-u.ac.jp> References: <73CCEA09-C492-439D-9E8A-AA2BA9CB93DB@ar.aichi-u.ac.jp> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] bug in exportfs Topicbox-Message-UUID: 7a988e18-ead9-11e9-9d60-3106f5b1d025 Thanks for your replay. however I don=E2=80=99t understand the intention of the manual. real needs in exporting is to export some different directories. it is impossible to do so under current code. can anyone show an example that exports two or more directories? > 2015/12/17 20:40=E3=80=81Peter Hull = =E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB=EF=BC=9A >=20 > On Wed, Dec 16, 2015 at 11:31 PM, arisawa = wrote: >> It seems cpu command is buggy in -P option. >> the sources of the problem is in command option -P of exportfs. >=20 > I had a look at the manpage for exportfs(4), it says: "For a file to > be exported, all lines with a prefix + must match and all those with > prefix - must not match." (http://man.9front.org/4/exportfs) >=20 > So isn't the original code correct according to the manpage? If any of > the regexps in 'include' fail to match, the function returns -1, then > if any in 'exclude' do match, -1 is returned. >=20 >> patternfile sample >> + /usr/arisawa >> + /usr/glenda >> - /adm >> - /sys/log >> - /mail >> - /usr/.* >>=20 > Is this sample invalid - no path could match /usr/arisawa and > /usr/glenda at the same time? >=20 > Pete I said: > int > excludefile(char *path) > { > Reprog **re; > char *p; >=20 > if(*(path+1) =3D=3D 0) > p =3D "/"; > else > p =3D path+1; >=20 > DEBUG(DFD, "checking %s\n", p); > for(re =3D include; *re !=3D nil; re++){ > - if(regexec(*re, p, nil, 0) !=3D 1){ > + if(regexec(*re, p, nil, 0) =3D=3D 1){ > DEBUG(DFD, "excluded+ %s\n", p); > - return -1; > + return 0; > } > } > for(re =3D exclude; *re !=3D nil; re++){ > if(regexec(*re, p, nil, 0) =3D=3D 1){ > DEBUG(DFD, "excluded- %s\n", p); > return -1; > } > } > return 0; > } >=20 >=20 > patternfile sample > + /usr/arisawa > + /usr/glenda > - /adm > - /sys/log > - /mail > - /usr/.* however this code has still a problem. trailing =E2=80=98/=E2=80=98 is removed in p even if p is a directory. assume we have users: /usr/rob and /usr/robin then we cannot export only /usr/rob. if we wish control this problem, we need tailing =E2=80=98/=E2=80=98 for = directory. then the code should be excludefile(char *path) { Reprog **re; char *p,*s; Dir *dir; if(*(path+1) =3D=3D 0) p =3D "/"; else p =3D path+1; s =3D p + strlen(p) - 1; /* tail */ dir =3D dirstat(p); /* should not be nil */ if((dir->mode)&DMDIR){ /* we have room to append '/' * look makepath() in exportfs.c */ *++s =3D '/'; *++s =3D 0; } DEBUG(DFD, "checking %s\n", p); for(re =3D include; *re !=3D nil; re++){ if(regexec(*re, p, nil, 0) =3D=3D 1){ DEBUG(DFD, "excluded+ %s\n", p); return 0; } } for(re =3D exclude; *re !=3D nil; re++){ if(regexec(*re, p, nil, 0) =3D=3D 1){ DEBUG(DFD, "excluded- %s\n", p); return -1; } } return 0; } then patternfile sample become: + /usr/arisawa/.* + /usr/glenda/.* - /adm/ - /sys/log/ - /mail/ - /usr/.+ adding tailing =E2=80=98/=E2=80=98 in p makes the pattern file = incompatible to existing one. I don=E2=80=99t know it is better to do so.