lkml.org 
[lkml]   [2013]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [git pull] vfs.git part 2
On Fri, Jul 12, 2013 at 12:42:15PM -0700, Linus Torvalds wrote:

> As to the mode argument: we should encourage people to have it, since
> the inode *may* become visible afterwards. See above (can you do
> linkat() to just turn an fd into a name? I didn't really check, but I
> think you can do it as a "link(/proc/sef/fd/..)" thing regardless).

link() won't do it, linkat() with the right arguments will (link(2)
doesn't follow symlinks on the oldname). It's a bit more complicated,
though:
* vfs_link() will refuse to link with link count that went down to 0
(always had, and that's a damn good idea for security reasons)
* with O_TMPFILE, vfs_link() will act as usual *if* you give open()
O_EXCL as well - files created that way cannot be linked in, ever. They
stay with link count 0 and they die as soon as they are closed. Again,
that's the behaviour we'd have with O_CREAT open + unlink. tmpfile(3) ought
to call it that way.
* O_TMPFILE _without_ O_EXCL == you may link it in once you've
decided that you've set it up enough. In that case you are supposed to
open it, write whatever you want to write, fchmod/fchown/fsetxattr/etc.
and use linkat() to put it in place. Or use vfs_link() if you are doing
that kernel-side.


\
 
 \ /
  Last update: 2013-07-12 22:41    [W:0.085 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site