Re: [MLton] A bug in the Posix_FileSys_Dirstream_readDir
Matthew Fluet <[email protected]> Fri, 18 Oct 2019 09:09:09 -0400
| Newsgroups | gmane.comp.lang.ml.mlton.devel |
|---|---|
| Message-ID | <CAMrhFL4+pw-w6k+knwEh=G60Rvdz8R5e-SvT81-+LaQdx2-dow@mail.gmail.com> |
--===============3809808967797468609== Content-Type: multipart/alternative; boundary="000000000000d43f6005952f0ae2" --000000000000d43f6005952f0ae2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Oct 18, 2019 at 9:00 AM Kostirya <[email protected]> wrote: > I apologize. It is C string for linux. > d_namlen is freebsd feature > Right; POSIX only specifies the d_name field of struct dirent: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html and it should be a NUL terminated string. I'm looking for an error why MLton do not run on FreeBSD 12. > In this case, Mlton works on FreeBSD 11. > > I localized the error to: > > structure FS =3D OS.FileSys > > fun main () =3D > let > val stream =3D FS.openDir > "/home/nick/mlton-20180207/build/lib/mlton/targets"; > > fun loop () =3D > case FS.readDir stream of > NONE =3D> () > | SOME s =3D> ( > print ("FOLD: |" ^ s ^ "|" ^ Int.toString (String.size s) > ^"|\n"); > loop () > ) > in > loop (); > FS.closeDir stream > end > > val _ =3D main () > > If I build this code on FreeBSD 11 and run =D0=BE=D0=BD FreeBSD 12 - OK: > > ./1_old > FOLD: |self|4| > > But If I build on FreeBSD 12 I have got error: > > ./1 > FOLD: | > |1| > FOLD: ||1| > FOLD: ||0| > That's certainly curious. I would suggest writing a directory listing program in C and seeing what happens between FreeBSD 11 and FreeBSD 12. But, it does seem unlikely that ancient library functions like opendir and readdir would change. --000000000000d43f6005952f0ae2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon= t-family:courier new,monospace;font-size:large"><span style=3D"font-family:= Arial,Helvetica,sans-serif;font-size:small">On Fri, Oct 18, 2019 at 9:00 AM= Kostirya <<a href=3D"mailto:[email protected]">[email protected]</a>&= gt; wrote:</span><br></div></div><div class=3D"gmail_quote"><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex">I apologize. It is C string for linux.<b= r> d_namlen is freebsd feature<br></blockquote><div><br></div><div><div class= =3D"gmail_default" style=3D"font-family:"courier new",monospace;f= ont-size:large">Right; POSIX only specifies the d_name field of struct dire= nt: <a href=3D"https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/di= rent.h.html">https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dire= nt.h.html</a> and it should be a NUL terminated string.</div></div><div><br= ></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;= border-left:1px solid rgb(204,204,204);padding-left:1ex"> I'm looking for an error why MLton do not run on FreeBSD 12.<br> In this case, Mlton works on FreeBSD 11.<br><br> I localized the error to:<br> <br> structure FS =3D OS.FileSys<br> <br> fun main () =3D<br> =C2=A0 let<br> =C2=A0 =C2=A0 val stream =3D FS.openDir "/home/nick/mlton-20180207/bui= ld/lib/mlton/targets";<br> <br> =C2=A0 =C2=A0 fun loop () =3D<br> =C2=A0 =C2=A0 =C2=A0 case FS.readDir stream of<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NONE =3D> ()<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 | SOME s =3D> (<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ("FOLD: |" ^ s ^ = "|" ^ Int.toString (String.size s)=C2=A0 ^"|\n");<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 loop ()<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )<br> =C2=A0 in<br> =C2=A0 =C2=A0 loop ();<br> =C2=A0 =C2=A0 FS.closeDir stream<br> =C2=A0 end<br> <br> val _ =3D main ()<br> <br> If I build this code on FreeBSD 11 and run =D0=BE=D0=BD FreeBSD 12 -=C2=A0 = OK:<br> > ./1_old<br> FOLD: |self|4|<br> <br> But If I build on FreeBSD 12 I have got error:<br> > ./1<br> FOLD: |<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0|1|<br> FOLD: ||1|<br> FOLD: ||0|<br></blockquote><div><br></div><div class=3D"gmail_default" styl= e=3D"font-family:"courier new",monospace;font-size:large">That= 9;s certainly curious.=C2=A0 I would suggest writing a directory listing pr= ogram in C and seeing what happens between FreeBSD 11 and FreeBSD 12.=C2=A0= But, it does seem unlikely that ancient library functions like opendir and= readdir would change.</div></div></div> --000000000000d43f6005952f0ae2-- --===============3809808967797468609== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============3809808967797468609== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ MLton-devel mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-devel --===============3809808967797468609==--