public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* utimensat and AT_EMPTY_PATH
@ 2017-04-10 16:05 Ian Pilcher
  2017-04-13 17:11 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Pilcher @ 2017-04-10 16:05 UTC (permalink / raw)
  To: libc-help

Given a file descriptor that refers to a symbolic link, is there a way
to call utimensat (or some other function) to update its timestamp?

I.e. what I would like to do is:

   utimensat(linkfd, "", times, AT_EMPTY_PATH);

Unlike futimens, utimensat *can* update the timestamp of a symlink
(verified with "strace touch -h ..."), but it doesn't seem to accept
AT_EMPTY_PATH.

Is there any non-racy way to do this?

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: utimensat and AT_EMPTY_PATH
  2017-04-10 16:05 utimensat and AT_EMPTY_PATH Ian Pilcher
@ 2017-04-13 17:11 ` Florian Weimer
  2017-04-13 20:40   ` Ian Pilcher
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2017-04-13 17:11 UTC (permalink / raw)
  To: Ian Pilcher, libc-help

On 04/10/2017 06:05 PM, Ian Pilcher wrote:
> Given a file descriptor that refers to a symbolic link, is there a way
> to call utimensat (or some other function) to update its timestamp?
> 
> I.e. what I would like to do is:
> 
>    utimensat(linkfd, "", times, AT_EMPTY_PATH);
> 
> Unlike futimens, utimensat *can* update the timestamp of a symlink
> (verified with "strace touch -h ..."), but it doesn't seem to accept
> AT_EMPTY_PATH.
> 
> Is there any non-racy way to do this?

Usually, it's possible to use the non-f, non-at system call variants 
with a /proc/fd/%d path.  Those appear as symbolic links in the proc 
file system, but they actually are not, and the kernel will do the right 
thing even when operating on O_PATH descriptors.

Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: utimensat and AT_EMPTY_PATH
  2017-04-13 17:11 ` Florian Weimer
@ 2017-04-13 20:40   ` Ian Pilcher
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Pilcher @ 2017-04-13 20:40 UTC (permalink / raw)
  To: libc-help

On 04/13/2017 12:11 PM, Florian Weimer wrote:
> Usually, it's possible to use the non-f, non-at system call variants 
> with a /proc/fd/%d path.  Those appear as symbolic links in the proc 
> file system, but they actually are not, and the kernel will do the right 
> thing even when operating on O_PATH descriptors.

Works for me.  Thank you!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-13 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 16:05 utimensat and AT_EMPTY_PATH Ian Pilcher
2017-04-13 17:11 ` Florian Weimer
2017-04-13 20:40   ` Ian Pilcher

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).