mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john slee <indigoid@oldcorollas.org>
To: linux-kernel@vger.kernel.org
Subject: [proposal] creating anonymous files
Date: Sat, 2 May 2009 10:11:21 +1000	[thread overview]
Message-ID: <9641a91e0905011711j75e33219yf520d0e40171908e@mail.gmail.com> (raw)

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/

                 reply	other threads:[~2009-05-02  0:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9641a91e0905011711j75e33219yf520d0e40171908e@mail.gmail.com \
    --to=indigoid@oldcorollas.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®