lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120924150239.1d87b868@notabene.brown>
Date:	Mon, 24 Sep 2012 15:02:39 +1000
From:	NeilBrown <neilb@...e.de>
To:	"Fox, Kevin M" <kevin.fox@...l.gov>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: Conditional Unlink

On Fri, 21 Sep 2012 10:32:36 -0700 "Fox, Kevin M" <kevin.fox@...l.gov> wrote:

> Quick question:
> Is there a syscall or some algorithm that would allow an unlink that would only happen if no writes to the file have occurred between a stat and an unlink, race free?
> 
> Background:
> I'm writing a program that sync's files up to a server. I would like to unlink the files that have successfully been uploaded. There is a race though. If the file changed after uploading but before the unlink (I do not control who can write to the files), the next upload should take care of things and the unlink should fail. Otherwise, data could be lost!

Probably your best bet is to rename the file in there.
 mv file file.tmp
 sleep 5
 cp file.tmp $server/file
 rm file.tmp

The "sleep 5" might not work for you, one would need to know more about total
context.

Is any locking done when writing to the file, or will there only ever be one
writer?

NeilBrown

Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ