On Thu, May 17, 2007 at 06:03:18PM -0700, Micah Cowan wrote: > > A completely different approach could be that the calls that > > actually write to a file check that the file does not exist. You > > could activate this with a system-wide flag, but I strongly suspect > > that this would be more work than the few words it took for me to > > write the idea. > The call of which you speak (open()) already does this, unless you > tell it that you specifically wish to overwrite files (which tar > does).
That's not quite right. Usually, you'll just pass the O_CREAT and O_TRUNC flags to open(2) in order to just open the file (creating it if it doesn't exist already), while you have to explicitly give it the O_EXCL flag to bail out if the file already exists. Passing --backup to tar makes it check if it should make a backup of the file, does so, and then proceeds to open the file with (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC) unless you pass it '-k', in which case O_TRUNC is replaced with O_EXCL. -- | Soren Hansen | Linux2Go | http://Linux2Go.dk/ | | Seniorkonsulent | Lindholmsvej 42, 2. TH | +45 46 90 26 42 | | [EMAIL PROTECTED] | 9400 Norresundby, Denmark | GPG key: E8BDA4E3 |
signature.asc
Description: Digital signature
-- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss