patch to add POSIX fsync and fdatasync to fs module

22 views
Skip to first unread message

billywhizz

unread,
Mar 22, 2010, 1:35:38 AM3/22/10
to nodejs
i have patched the latest 33 release of node from github master to add
fsync and fdatasync system calls to the fs module. patch is here:
http://gist.github.com/339815.

Ryan Dahl

unread,
Mar 22, 2010, 2:12:23 AM3/22/10
to nod...@googlegroups.com

Can you add a test which at least calls these functions? Also test
with node_g (./configure --debug && make)

billywhizz

unread,
Mar 22, 2010, 3:35:11 AM3/22/10
to nodejs
have created a test for this and have tested both debug and non debug
on my setup which is Fedora 12 (2.6.32.9) on x86_64.

patch is here:
http://gist.github.com/339869

the test script is here (couldn't figure out how to get this included
in the patch):
http://gist.github.com/339870

this goes in the test/simple/ directory in the node source tree. i
used file name test-fs-fsync.js.

if you need anything else, let me know.

On Mar 22, 6:12 am, Ryan Dahl <coldredle...@gmail.com> wrote:

Ryan Dahl

unread,
Mar 23, 2010, 11:56:36 AM3/23/10
to nod...@googlegroups.com
On Mon, Mar 22, 2010 at 12:35 AM, billywhizz <apjo...@gmail.com> wrote:
> have created a test for this and have tested both debug and non debug
> on my setup which is Fedora 12 (2.6.32.9) on x86_64.

The patch looks fine, but it appears as if deps/libeio/wscript is not
properly checking for fdatasync. It doesn't exist on OSX yet the
configure script still thinks it does. This is causing problems.

billywhizz

unread,
Mar 24, 2010, 6:58:48 PM3/24/10
to nodejs
do you want me to have a look at this? should be pretty easy to put
the check into wscript i imagine...

On Mar 23, 3:56 pm, Ryan Dahl <coldredle...@gmail.com> wrote:

Ryan Dahl

unread,
Mar 24, 2010, 7:52:13 PM3/24/10
to nod...@googlegroups.com
On Wed, Mar 24, 2010 at 3:58 PM, billywhizz <apjo...@gmail.com> wrote:
> do you want me to have a look at this? should be pretty easy to put
> the check into wscript i imagine...

Would be nice. Otherwise I can have a look at it, but it will take a week or so.

billywhizz

unread,
Mar 31, 2010, 7:34:03 AM3/31/10
to nodejs
i presume this is the section that does the checking:
conf.check_cc(msg="Checking for fdatasync(2)",
define_name="HAVE_FDATASYNC", fragment="""
#include <unistd.h>
int main(void)
{
int fd = 0;
fdatasync (fd);
return 0;
}
""")

do you know of any documentation explaining how these tests are
supposed to work? from looking at the others i presume the build
engine is compiling/running that snippet and then catching errors if
the function doesn't exist. is OSX not throwing errors during the
build for this snippet? afraid i don't have a mac to test on...

On Mar 25, 12:52 am, Ryan Dahl <coldredle...@gmail.com> wrote:

billywhizz

unread,
Mar 31, 2010, 7:35:30 AM3/31/10
to nodejs
also, it looks like OSX/FreeBSD do not support fdatasync so i'm not
sure why this isn't caught during the build on those platforms...

On Mar 25, 12:52 am, Ryan Dahl <coldredle...@gmail.com> wrote:

billywhizz

unread,
Apr 16, 2010, 11:00:55 PM4/16/10
to nodejs
i've had a bit of a dig on this issue again and i think this change in
the libeio wscript should fix the mac OSX issue.basically i changed
the script to always return a failure code for fdatasync on OSX so
that libeio will alias fdatasync to fsync and everything should build
and run. unfortunately, this is only a theory, as i don't have a mac
to test on. if anyone has a mac and can test this, i would be
grateful. i can fork the latest node on github and apply my patches if
you want to pull from there and do a build...

conf.check_cc(msg="Checking for fdatasync(2)",
define_name="HAVE_FDATASYNC", fragment="""
#include <unistd.h>
int main(void)
{
int fd = 0;
fdatasync (fd);
#if __APPLE__
return -1;
#else
return 0;
#endif
}
""")


On Mar 31, 12:35 pm, billywhizz <apjohn...@gmail.com> wrote:
> also, it looks like OSX/FreeBSD do not supportfdatasyncso i'm not
> sure why this isn't caught during the build on those platforms...
>
> On Mar 25, 12:52 am, Ryan Dahl <coldredle...@gmail.com> wrote:
>
>
>
> > On Wed, Mar 24, 2010 at 3:58 PM, billywhizz <apjohn...@gmail.com> wrote:
> > > do you want me to have a look at this? should be pretty easy to put
> > > the check into wscript i imagine...
>
> > Would be nice. Otherwise I can have a look at it, but it will take a week or so.

--
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.

billywhizz

unread,
Apr 16, 2010, 11:23:11 PM4/16/10
to nodejs
actually try this instead. waf doesn't seem to check return code from
applications - it just catches errors so i call a function that
doesn't exist to make sure the app craps out on OSX:

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;
}
""")


r...@tinyclouds.org

unread,
May 14, 2010, 9:43:37 PM5/14/10
to nod...@googlegroups.com, billywhizz
Landed in 9599607. Thanks and sorry for the delay.
Reply all
Reply to author
Forward
0 new messages