[nodejs] fsync/fdatasync on OSX

234 views
Skip to first unread message

billywhizz

unread,
Apr 18, 2010, 6:32:25 AM4/18/10
to nodejs
can someone with access to Mac OSX please check this out when you have
a chance?

http://groups.google.com/group/nodejs/t/ba7682ba734184fe

thx.

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Marco Rogers

unread,
Apr 19, 2010, 10:07:52 AM4/19/10
to nodejs
I can give it a run this evening and tell you if the test passes.
When would you use this?

:Marco

billywhizz

unread,
Apr 19, 2010, 10:35:49 AM4/19/10
to nodejs
i am trying to add fsync and fdatasync to the fs library as i need
them for some work i am doing, and they are pretty standard posix
functions so should prolly be fs.js in the long run anyway. everything
works fine on linux but when ryan tried to build on OSX he was getting
issues with deps/libeio/wscript. The issue seems to be that when
configuring on OSX, the wscript for libeio doesn't pick up the fact
that fdatasync is not available and it then breaks when compiling. i
have tried to change the script so it always marks fdatasync as
unavailable when configuring on OSX. All should work fine then, as
there are define tests in the libeio code to alias fdatasync to fsync
on OSX.

clear as mud?

basically, i just need someone to confirm that when configuring on
OSX, fdatasync shows up correctly as not available using this change
to deps/libeio/wscript:

conf.check_cc(msg="Checking for fdatasync(2)",
define_name="HAVE_FDATASYNC", fragment="""
#include <unistd.h>
int main(void)
{
int fd = 0;
#if __APPLE__
//make the application crash
sdskdfjhskjhsdf();
#endif
fdatasync (fd);
return 0;
}
""")

if you could confirm this, then i'll resubmit a full patch to ryan for
the latest node.js release.

Thanks

Jorge

unread,
Apr 19, 2010, 11:11:18 AM4/19/10
to nod...@googlegroups.com
On 19/04/2010, at 16:35, billywhizz wrote:

> i am trying to add fsync and fdatasync to the fs library as i need
> them for some work i am doing, and they are pretty standard posix
> functions so should prolly be fs.js in the long run anyway. everything
> works fine on linux but when ryan tried to build on OSX he was getting
> issues with deps/libeio/wscript. The issue seems to be that when
> configuring on OSX, the wscript for libeio doesn't pick up the fact
> that fdatasync is not available and it then breaks when compiling. i
> have tried to change the script so it always marks fdatasync as
> unavailable when configuring on OSX. All should work fine then, as
> there are define tests in the libeio code to alias fdatasync to fsync
> on OSX.
> (...)

I don't know if that helps, but fdatasync(fileDescriptor) is fcntl(fileDescriptor, F_FULLFSYNC) in OSX.

F_FULLFSYNC Does the same thing as fsync(2) then asks the drive to
flush all buffered data to the permanent storage
device (arg is ignored). This is currently imple-
mented on HFS, MS-DOS (FAT), and Universal Disk Format
(UDF) file systems. The operation may take quite a
while to complete. Certain FireWire drives have also
been known to ignore the request to flush their
buffered data.
--
Jorge.

billywhizz

unread,
Apr 19, 2010, 8:22:18 PM4/19/10
to nodejs
hmmm.... libeio has this code to deal with the case where fdatasync is
not available.

#if !HAVE_FDATASYNC
# undef fdatasync
# define fdatasync(fd) fsync (fd)
#endif

this is really a bug in libeio as far as i can see... should we just
raise it to the maintainers of that??

Marco Rogers

unread,
Apr 19, 2010, 8:58:34 PM4/19/10
to nodejs
I tried your patch to the libeio wscript. It doesn't report fdatasync
as availabe for me. With or without the patch. I'm running OS X
10.5.8. Also, I couldn't get your original patch to apply cleanly. I
had to do it manually, but when I did, everything compiled fine. Got
the crash when running the test.

I'm out of my element here so I don't have much more info. Hope this
is helpful.

:Marco

billywhizz

unread,
Apr 20, 2010, 12:24:39 PM4/20/10
to nodejs
Thanks Marco. I just wanted to confirm that fdatasync shows as not
available when configuring. i don't want it to on OSX. I'll put
together a new patch for the latest release and will post up here and
hopefully ryan can integrate it into an upcoming release.

Much appreciated!
Reply all
Reply to author
Forward
0 new messages