* io.c (rb_io_fdatasync): new method IO#fdatasync.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-06-22 04:50:29 +00:00
parent 5d30ddec17
commit a7dedc272e
4 changed files with 37 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Mon Jun 22 13:50:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_fdatasync): new method IO#fdatasync.
Sun Jun 21 22:33:05 2009 Yusuke Endoh <mame@tsg.ne.jp> Sun Jun 21 22:33:05 2009 Yusuke Endoh <mame@tsg.ne.jp>
* load.c (Init_load): $: must be readonly. [ruby-dev:38690] * load.c (Init_load): $: must be readonly. [ruby-dev:38690]

View File

@ -1076,9 +1076,9 @@ AC_REPLACE_FUNCS(dup2 memmove strerror\
strchr strstr crypt flock vsnprintf\ strchr strstr crypt flock vsnprintf\
isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \ isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \
strlcpy strlcat) strlcpy strlcat)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd eaccess\ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eaccess\
truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\ truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\
link symlink readlink readdir_r\ link symlink readlink readdir_r fsync fdatasync\
setitimer setruid seteuid setreuid setresuid setproctitle socketpair\ setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
setrgid setegid setregid setresgid issetugid pause lchown lchmod\ setrgid setegid setregid setresgid issetugid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\ getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\

29
io.c
View File

@ -1319,6 +1319,34 @@ rb_io_fsync(VALUE io)
#define rb_io_fsync rb_f_notimplement #define rb_io_fsync rb_f_notimplement
#endif #endif
#ifdef HAVE_FDATASYNC
/*
* call-seq:
* ios.fdatasync => 0 or nil
*
* Immediately writes all buffered data in <em>ios</em> to disk.
* Returns <code>nil</code> if the underlying operating system does not
* support <em>fdatasync(2)</em>.
*/
static VALUE
rb_io_fdatasync(VALUE io)
{
rb_io_t *fptr;
io = GetWriteIO(io);
GetOpenFile(io, fptr);
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
if (fdatasync(fptr->fd) < 0)
rb_sys_fail_path(fptr->pathv);
return INT2FIX(0);
}
#else
#define rb_io_fdatasync rb_f_notimplement
#endif
/* /*
* call-seq: * call-seq:
* ios.fileno => fixnum * ios.fileno => fixnum
@ -8781,6 +8809,7 @@ Init_IO(void)
rb_define_method(rb_cIO, "to_io", rb_io_to_io, 0); rb_define_method(rb_cIO, "to_io", rb_io_to_io, 0);
rb_define_method(rb_cIO, "fsync", rb_io_fsync, 0); rb_define_method(rb_cIO, "fsync", rb_io_fsync, 0);
rb_define_method(rb_cIO, "fdatasync", rb_io_fdatasync, 0);
rb_define_method(rb_cIO, "sync", rb_io_sync, 0); rb_define_method(rb_cIO, "sync", rb_io_sync, 0);
rb_define_method(rb_cIO, "sync=", rb_io_set_sync, 1); rb_define_method(rb_cIO, "sync=", rb_io_set_sync, 1);

View File

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2" #define RUBY_VERSION "1.9.2"
#define RUBY_RELEASE_DATE "2009-06-21" #define RUBY_RELEASE_DATE "2009-06-22"
#define RUBY_PATCHLEVEL -1 #define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk" #define RUBY_BRANCH_NAME "trunk"
@ -8,7 +8,7 @@
#define RUBY_VERSION_TEENY 1 #define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 6 #define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 21 #define RUBY_RELEASE_DAY 22
#include "ruby/version.h" #include "ruby/version.h"