[ruby-cvs:66882] sorah:r59704 (trunk): File#path: Raise IOError when a file is O_TMPFILE

sorah at ruby-lang.org sorah at ruby-lang.org
Thu Aug 31 20:14:36 JST 2017


sorah	2017-08-31 20:14:36 +0900 (Thu, 31 Aug 2017)

  New Revision: 59704

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59704

  Log:
    File#path: Raise IOError when a file is O_TMPFILE
    
    File#path for a file opened with O_TMPFILE has no meaning.
    
    A filepath returned by this method isn't guarranteed about its accuracy,
    but files opened with O_TMPFILE are known its recorded path has no
    meaning. So let them not to return any pathname.
    
    After a discussion in ruby-core, just returning Qnil makes guessing the
    root cause difficult. Instead, this patch makes the method to raise an
    error.
    
    Other consideration is calling fnctl(2) on rb_file_path, but it adds a
    overhead, and it's difficult to determine O_TMPFILE status  after fd has
    been closed.
    
    [Feature #13568]
    
    * io.c(rb_file_open_generic): Set Qnil to fptr->pathv when opening a
      file using O_TMPFILE
    
    * file.c(rb_file_path): Raise IOError when fptr->pathv is Qnil
    
    * file.c(rb_file_path): [DOC] Update for the new behavior

  Modified files:
    trunk/file.c
    trunk/io.c
    trunk/test/ruby/test_file.rb


More information about the ruby-cvs mailing list