unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: herring@lanl.gov
Cc: rms@gnu.org, Andreas Schwab <schwab@suse.de>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-pretest-bug@gnu.org, christopher.ian.moore@gmail.com,
	svenjoac@gmx.de
Subject: Re: creating backups in temporary directories
Date: Mon, 10 Sep 2007 21:55:11 +0200	[thread overview]
Message-ID: <85abrumh28.fsf@lola.goethe.zz> (raw)
In-Reply-To: <37852.128.165.123.18.1189451916.squirrel@webmail.lanl.gov> (Davis Herring's message of "Mon\, 10 Sep 2007 12\:18\:36 -0700 \(PDT\)")

"Davis Herring" <herring@lanl.gov> writes:

>> Well, seems I misread the manual page for open/creat.  I thought that
>> without O_EXCL, the file would get replaced.
>>
>> Well, then there still is the contorted way of hard linking /tmp/foo
>> to /tmp/foo~, opening /tmp/randomfilename for write, renaming it to
>> /tmp/foo and then finishing the write operation.
>
> Why not just rename /tmp/foo to /tmp/foo~, then open /tmp/foo with O_EXCL?
>  If it fails, then write (again with O_EXCL) to /tmp/randomfile so that
> the user's work is on disk -somewhere-, and tell them that they have
> enemies.

I would simply not save at all if O_EXCL fails, leave the buffer
marked as modified, and set a buffer-permanent local variable
save-only-when-nonexistent to buffer-filename.  Attempts to save the
buffer to a file with the filename save-only-when-nonexistent will use
O_EXCL.

Auto save files should always be opened O_EXCL.

When a file lock for a non-existing file is created,
save-only-when-nonexistent is set at the same time.  Hm, this is sort
of a mess.  There will always be somewhat predictable names on /tmp
and similar.  Perhaps we should have some rule not to write through
symlinks in such directories after all.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2007-09-10 19:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-07 10:42 creating backups in temporary directories Chris Moore
2007-09-07 15:36 ` David Kastrup
2007-09-07 17:57   ` Stefan Monnier
2007-09-07 19:43     ` Davis Herring
2007-09-07 19:49     ` Sven Joachim
2007-09-07 19:52       ` David Kastrup
2007-09-08 19:47         ` Richard Stallman
2007-09-07 20:47       ` Stefan Monnier
2007-09-08 19:47         ` Richard Stallman
2007-09-09 19:44           ` Stefan Monnier
2007-09-09 20:01             ` David Kastrup
2007-09-09 20:27               ` Andreas Schwab
2007-09-10  1:11                 ` David Kastrup
2007-09-10 19:18                   ` Davis Herring
2007-09-10 19:55                     ` David Kastrup [this message]
     [not found]                   ` <37852.128.165.123.18.1189451917.squirrel@webmail.lanl.gov>
2007-09-10 19:23                     ` Davis Herring
2007-09-11 20:32                       ` Richard Stallman
2007-09-11 21:17                         ` Davis Herring
2007-09-10  1:12             ` Richard Stallman
2007-09-10  2:59               ` Stefan Monnier
2007-09-08 14:38     ` Chris Moore
2007-09-08 19:48     ` Richard Stallman
2007-09-09 19:41       ` Stefan Monnier
2007-09-09 19:45         ` David Kastrup
2007-09-10  1:12         ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=85abrumh28.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=christopher.ian.moore@gmail.com \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=herring@lanl.gov \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    --cc=schwab@suse.de \
    --cc=svenjoac@gmx.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).