Skip to contentSkip to conversation

Use utime rather than utimes

PATCH In review Jon Ringle 4 participants 7 messages Mar 10, 2010

lore
Share & tools
lore

Jon Ringle

author
#0 lore raw

PATCH 1/1 Use utime rather than utimes

uclibc does not have lutimes and legacy function utimes should be replaced with utime

---
 udev/udev-node.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
udev/udev-node.c +2 -2
index a70c147..f90567d 100644
@@ -57,7 +57,7 @@ int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mod
 			preserve = 1;
 			udev_selinux_lsetfilecon(udev, file, mode);
 			/* update time stamp when we re-use the node, like on media change events */
-			utimes(file, NULL);
+			utime(file, NULL);
 		} else {
 			char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
 
@@ -178,7 +178,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink)
 					info(udev, "preserve already existing symlink '%s' to '%s'\n",
 					     slink, target);
 					udev_selinux_lsetfilecon(udev, slink, S_IFLNK);
-					lutimes(slink, NULL);
+					utime(target, NULL);
 					goto exit;
 				}
 			}
Signature · 1 line
1.7.0.rc2
#1 lore raw
Quoted 2 lines · Jon Ringle

uclibc does not have lutimes and legacy function utimes should be replaced with utime

utime(): POSIX.1-2008 marks utime() as obsolete. I guess uclibc needs to be fixed if it is supposed to compile udev.

Quoted 2 lines

-                                       lutimes(slink, NULL);
+                                       utime(target, NULL);

We do not care about the target, also utime() follows links which is why we can't use it.

Kay

#2 lore raw
In reply to Jon Ringle

Kay Sievers [2010-03-10 9:34 +0100]:

Quoted 1 line

utime(): POSIX.1-2008 marks utime() as obsolete.

That's actually what the manpage says, indeed. However, it contradicts what's written in the standard:

http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html#tag_13_64

says utimes() is obsolete and

http://www.opengroup.org/onlinepubs/009695399/basedefs/utime.h.html#tag_13_81

says nothing about being obsolete. However, this might not be _the_ POSIX standard?

Martin

Signature · 2 lines
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
#3 lore raw
In reply to Jon Ringle
Quoted 6 lines · Martin Pitt

Kay Sievers [2010-03-10  9:34 +0100]:

Quoted 1 line

utime(): POSIX.1-2008 marks utime() as obsolete.

That's actually what the manpage says, indeed. However, it contradicts what's written in the standard:

Quoted 8 lines

 http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html#tag_13_64

says utimes() is obsolete and

 http://www.opengroup.org/onlinepubs/009695399/basedefs/utime.h.html#tag_13_81

says nothing about being obsolete. However, this might not be _the_ POSIX standard?

Sounds all pretty weird. Maybe we just go for utimensat(AT_FDCWD, ..., if that is in uclibc. Jon, care to check?

Thanks,
Kay

#4 lore raw
In reply to Jon Ringle
Quoted 11 lines · Kay Sievers
Quoted 10 lines · Martin Pitt

Kay Sievers [2010-03-10 9:34 +0100]:

Quoted 1 line

utime(): POSIX.1-2008 marks utime() as obsolete.

That's actually what the manpage says, indeed. However, it contradicts what's written in the standard:

http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html#tag_13_64

says utimes() is obsolete and

Quoted 7 lines
Quoted 4 lines

http://www.opengroup.org/onlinepubs/009695399/basedefs/utime.h.html#tag_13_81

says nothing about being obsolete. However, this might not be _the_ POSIX standard?

Sounds all pretty weird. Maybe we just go for utimensat(AT_FDCWD, ..., if that is in uclibc. Jon, care to check?

Jon, care to try if this compiles?

Thanks,
Kay

udev/udev-node.c +2 -2
index a70c147..23bfade 100644
@@ -57,7 +57,7 @@ int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mod
 			preserve = 1;
 			udev_selinux_lsetfilecon(udev, file, mode);
 			/* update time stamp when we re-use the node, like on media change events */
-			utimes(file, NULL);
+			utimensat(AT_FDCWD, file, NULL, 0);
 		} else {
 			char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
 
@@ -178,7 +178,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink)
 					info(udev, "preserve already existing symlink '%s' to '%s'\n",
 					     slink, target);
 					udev_selinux_lsetfilecon(udev, slink, S_IFLNK);
-					lutimes(slink, NULL);
+					utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW);
 					goto exit;
 				}
 			}
#5 lore raw
In reply to Jon Ringle
Quoted 6 lines · Martin Pitt

Kay Sievers [2010-03-10 9:34 +0100]:

Quoted 1 line

utime(): POSIX.1-2008 marks utime() as obsolete.

That's actually what the manpage says, indeed. However, it contradicts what's written in the standard:

Quoted 9 lines

http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html#tag_13_64

says utimes() is obsolete and

http://www.opengroup.org/onlinepubs/009695399/basedefs/utime.h.html#tag_13_81

says nothing about being obsolete. However, this might not be _the_ POSIX standard?

That's the 2004 version of the standard you're quoting. 2008 changed its mind ;-)

http://www.opengroup.org/onlinepubs/9699919799/functions/utime.html

This notes:

The utime() function is marked obsolescent.

http://www.opengroup.org/onlinepubs/9699919799/functions/utimes.html

This notes:

The LEGACY marking is removed.

Scott

Signature · 2 lines
Scott James Remnant
[email protected]
author
#6 lore raw
In reply to Jon Ringle

I'm not subscribed to the list, but saw the discussion in the archive. I tested your patch here: http://www.spinics.net/lists/hotplug/msg03470.html
And it builds successfully with uclibc

Jon

Quoted 15 lines · Kay Sievers
Quoted 2 lines · Jon Ringle

uclibc does not have lutimes and legacy function utimes should be replaced with utime

utime(): POSIX.1-2008 marks utime() as obsolete. I guess uclibc needs to be fixed if it is supposed to compile udev.

Quoted 2 lines

-                                       lutimes(slink, NULL);
+                                       utime(target, NULL);

We do not care about the target, also utime() follows links which is why we can't use it.

Kay