mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [proposal] creating anonymous files
@ 2009-05-02  0:11 john slee
  0 siblings, 0 replies; only message in thread
From: john slee @ 2009-05-02  0:11 UTC (permalink / raw)
  To: linux-kernel

Hi,

At present developers seem to go through all kinds of ridiculous
antics to try to open a temporary file with some degree of safety.
Most of these seem to revolve around choosing a name, and in
many cases it gets unlinked immediately after open() anyway.

Temporary file creation/handling would be far less unpleasant if
it went something like this:

/* need to establish which fs the new inode goes on */
dirfd = open("/etc", O_RDONLY);

fd = openfdat(dirfd, O_CREAT, S_IWUSR|S_IRUSR);
/* file has no links, no need to unlink.  now use fd */

/* if we want to keep the file, add a link */
if (all_ok) {
    linkfdat(dirfd, fd, "nsswitch.conf");
} else {
   /* no cleanup required, inode has no links and */
   /* disappears at process exit */
}

I had a quick look through the Free/OpenBSD and Solaris 10
manpages in case they had implemented something similar, but
it seems that they haven't.

Sorry about lack of attached patch.  I did have a good look through
fs/namei.c and fs/open.c but I am more a sysadmin than a kernel
hacker

Comments/constructive abuse appreciated...

John

-- 
P-plate adventurer -- http://indigoid.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-02  0:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-02  0:11 [proposal] creating anonymous files john slee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®