Skip to contentSkip to conversation

get rid of qemu_utimens()

PATCH In review Greg Kurz 2 participants 4 messages May 19, 2017 – May 22, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

cover get rid of qemu_utimens()

It is currently only used by 9pfs and virtfs-proxy-helper. This series convert them to utimensat() and futimens().

--
Greg

---

Greg Kurz (2):
9pfs: assume utimensat() and futimens() are present
util: drop old utimensat() compat code

 configure                   |   22 --------------------
 fsdev/virtfs-proxy-helper.c |    3 ++-
 hw/9pfs/9p-handle.c         |    5 -----
 include/sysemu/os-posix.h   |   11 ----------
 util/oslib-posix.c          |   47 -------------------------------------------
 5 files changed, 2 insertions(+), 86 deletions(-)
author
#1 lore raw

PATCH 1/2 9pfs: assume utimensat() and futimens() are present

The utimensat() and futimens() syscalls have been around for ages (ie, glibc 2.6 and linux 2.6.22), and the decision was already taken to switch to utimensat() anyway when fixing CVE-2016-9602 in 2.9.

---
 fsdev/virtfs-proxy-helper.c |    3 ++-
 hw/9pfs/9p-handle.c         |    5 -----
 2 files changed, 2 insertions(+), 6 deletions(-)
fsdev/virtfs-proxy-helper.c +2 -1
index 54f7ad1c48f0..617e19cd0b88 100644
@@ -945,7 +945,8 @@ static int process_requests(int sock)
                                      &spec[0].tv_sec, &spec[0].tv_nsec,
                                      &spec[1].tv_sec, &spec[1].tv_nsec);
             if (retval > 0) {
-                retval = qemu_utimens(path.data, spec);
+                retval = utimensat(AT_FDCWD, path.data, spec,
+                                   AT_SYMLINK_NOFOLLOW);
                 if (retval < 0) {
                     retval = -errno;
                 }
hw/9pfs/9p-handle.c +0 -5
index 1687661bc95a..9875f1894cc5 100644
@@ -378,7 +378,6 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,
                             const struct timespec *buf)
 {
     int ret;
-#ifdef CONFIG_UTIMENSAT
     int fd;
     struct handle_data *data = (struct handle_data *)ctx->private;
 
@@ -388,10 +387,6 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,
     }
     ret = futimens(fd, buf);
     close(fd);
-#else
-    ret = -1;
-    errno = ENOSYS;
-#endif
     return ret;
 }
 
author
#2 lore raw

PATCH 2/2 util: drop old utimensat() compat code

In reply to Greg Kurz

Now that 9pfs and virtfs-proxy-helper have been converted to utimensat(), we don't need to keep qemu_utimens() anymore.

---
 configure                 |   22 ---------------------
 include/sysemu/os-posix.h |   11 -----------
 util/oslib-posix.c        |   47 ---------------------------------------------
 3 files changed, 80 deletions(-)
configure +0 -22
index 139638e922e0..1dea17ed2e73 100755
@@ -3623,25 +3623,6 @@ if compile_prog "" "" ; then
   inotify1=yes
 fi
 
-# check if utimensat and futimens are supported
-utimens=no
-cat > $TMPC << EOF
-#define _ATFILE_SOURCE
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-int main(void)
-{
-    utimensat(AT_FDCWD, "foo", NULL, 0);
-    futimens(0, NULL);
-    return 0;
-}
-EOF
-if compile_prog "" "" ; then
-  utimens=yes
-fi
-
 # check if pipe2 is there
 pipe2=no
 cat > $TMPC << EOF
@@ -5427,9 +5408,6 @@ fi
 if test "$curses" = "yes" ; then
   echo "CONFIG_CURSES=y" >> $config_host_mak
 fi
-if test "$utimens" = "yes" ; then
-  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
-fi
 if test "$pipe2" = "yes" ; then
   echo "CONFIG_PIPE2=y" >> $config_host_mak
 fi
include/sysemu/os-posix.h +0 -11
index 900bdcb45ad0..629c8c648b7a 100644
@@ -51,17 +51,6 @@ int os_mlock(void);
 typedef struct timeval qemu_timeval;
 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL)
 
-#ifndef CONFIG_UTIMENSAT
-#ifndef UTIME_NOW
-# define UTIME_NOW     ((1l << 30) - 1l)
-#endif
-#ifndef UTIME_OMIT
-# define UTIME_OMIT    ((1l << 30) - 2l)
-#endif
-#endif
-typedef struct timespec qemu_timespec;
-int qemu_utimens(const char *path, const qemu_timespec *times);
-
 bool is_daemonized(void);
 
 /**
util/oslib-posix.c +0 -47

53 lines not on this page · raw message

Reviewed-by on the v1 series
#3 lore raw
In reply to Greg Kurz
Quoted 11 lines · Greg Kurz

It is currently only used by 9pfs and virtfs-proxy-helper. This series convert them to utimensat() and futimens().

--
Greg

---

Greg Kurz (2):
9pfs: assume utimensat() and futimens() are present
util: drop old utimensat() compat code

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org