[proposal] creating anonymous files

From: john slee
Date: Fri May 01 2009 - 20:11:50 EST


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/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/