coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX conformance of touch command


From: Eric Blake
Subject: Re: POSIX conformance of touch command
Date: Tue, 13 Jan 2015 08:25:05 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 01/13/2015 06:50 AM, Anoop Sharma wrote:
> Thanks Eric.

[please don't top-post on technical lists]

> 
> What if touch follows following steps:
> 1. Try same steps as in "touch -c" in an attempt to update timestamp of the
> file.
> 2. If this attempt fails due to errno indicating file was not present
> (ENOENT?), then it uses the same filefd (of step 1) and openat() to create
> the new file.

Because that costs more syscalls.  Step 1 involves an open(); if that
fails, then step 2 requires a second open, AND an additional futimens()
(three calls); the existing code only requires two calls.

> Why it bothers me? - Because "touch existing_file" and "touch -c
> existing_file" raise different file system events.

Sorry, but that's not a reason to change the implementation.  You'll
just have to adjust your code to check for different syscalls.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]