Feature #1377
closedPlease provide constant File::NOATIME
Description
=begin
I would like to be able to specify File::NOATIME mode when opening a file through File.new():
irb(main):001:0> f = File.new("file", File::RDONLY|File::NOATIME)
NameError: uninitialized constant File::NOATIME
from (irb):1
from :0
From the open(2) man page:
O_NOATIME (Since Linux 2.6.8)
Do not update the file last access time (st_atime in the inode) when the file is read(2). This flag is intended for
use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag
may not be effective on all file systems. One example is NFS, where the server maintains the access time.
Here's the definition of O_NOATIME from /usr/include/bits/fcntl.h:
#ifdef __USE_GNU
define O_DIRECT 040000 /* Direct disk access. */¶
define O_DIRECTORY 0200000 /* Must be a directory. */¶
define O_NOFOLLOW 0400000 /* Do not follow links. */¶
define O_NOATIME 01000000 /* Do not set atime. */¶
define O_CLOEXEC 02000000 /* Set close_on_exec. */¶
#endif
Thanks //Johan
Note to self: This is the upstream report for http://bugs.debian.org/518716
=end
Updated by walles (Johan Walles) about 15 years ago
=begin
For the curious, my intended use for this is in http://launchpad.net/foton when scanning for images.
=end
Updated by znz (Kazuhiro NISHIYAMA) almost 15 years ago
=begin
How about this patch?
Index: io.c¶
--- io.c (revision 23386)
+++ io.c (working copy)
@@ -8953,6 +8953,9 @@ Init_IO(void)
#ifdef O_NOFOLLOW
rb_file_const("NOFOLLOW", INT2FIX(O_NOFOLLOW)); /* FreeBSD, Linux */
#endif
+#ifdef O_NOATIME
-
rb_file_const("NOATIME", INT2FIX(O_NOATIME)); /* Linux */
+#endifsym_mode = ID2SYM(rb_intern("mode"));
sym_perm = ID2SYM(rb_intern("perm"));
% ruby-trunk -e 'printf "%#o\n", File::NOATIME'
01000000
%
=end
Updated by matz (Yukihiro Matsumoto) almost 15 years ago
=begin
Hi,
In message "Re: [ruby-core:23418] [Feature #1377] Please provide constant File::NOATIME"
on Mon, 11 May 2009 07:15:47 +0900, Kazuhiro NISHIYAMA redmine@ruby-lang.org writes:
|Issue #1377 has been updated by Kazuhiro NISHIYAMA.
|
|How about this patch?
|
|Index: io.c
|===================================================================
|--- io.c (revision 23386)
|+++ io.c (working copy)
Can you check in?
matz.
=end
Updated by Anonymous almost 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23392.
=end