Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[qemu-usermode] make sure utimensat from glibc is being used so sb2 c…
…an wrap it. JB#48738
- Loading branch information
Showing
16 changed files
with
168 additions
and
28 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
rpm/0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0005-Revert-linux-user-Use-safe_syscall-for-wait-system-c.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0006-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0007-Revert-linux-user-Use-direct-syscall-for-utimensat.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0008-Revert-target-arm-Use-vector-operations-for-saturati.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0009-linux-user-Also-ignore-attempts-to-block-SIGTERM-SIG.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0010-Revert-tcg-i386-Fix-dupi-dupm-for-avx1-and-32-bit-ho.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
rpm/0013-crypto-check-if-getrandom-is-available-properly.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
rpm/0016-Revert-util-drop-old-utimensat-compat-code.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
From 1a464d4a8eec73e1a481c9b02787ce24ac9a79d3 Mon Sep 17 00:00:00 2001 | ||
From: Frajo Haider <f_haider@gmx.at> | ||
Date: Wed, 29 Jan 2020 11:21:54 +0000 | ||
Subject: [PATCH 16/16] Revert "util: drop old utimensat() compat code" | ||
|
||
This reverts commit fcdcf1eed2fd26bfe836080755ba4322d3c1f2cc. | ||
|
||
Conflicts: | ||
slirp | ||
--- | ||
configure | 22 ++++++++++++++++++++++ | ||
include/sysemu/os-posix.h | 11 +++++++++++ | ||
util/oslib-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ | ||
3 files changed, 80 insertions(+) | ||
|
||
diff --git a/configure b/configure | ||
index 6099be1..cdc4f46 100755 | ||
--- a/configure | ||
+++ b/configure | ||
@@ -4325,6 +4325,25 @@ 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 | ||
@@ -6840,6 +6859,9 @@ if test "$curses" = "yes" ; then | ||
echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak | ||
echo "CURSES_LIBS=$curses_lib" >> $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 | ||
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h | ||
index 629c8c6..900bdcb 100644 | ||
--- a/include/sysemu/os-posix.h | ||
+++ b/include/sysemu/os-posix.h | ||
@@ -51,6 +51,17 @@ 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); | ||
|
||
/** | ||
diff --git a/util/oslib-posix.c b/util/oslib-posix.c | ||
index 5a291cc..eb57405 100644 | ||
--- a/util/oslib-posix.c | ||
+++ b/util/oslib-posix.c | ||
@@ -304,6 +304,53 @@ int qemu_pipe(int pipefd[2]) | ||
return ret; | ||
} | ||
|
||
+int qemu_utimens(const char *path, const struct timespec *times) | ||
+{ | ||
+ struct timeval tv[2], tv_now; | ||
+ struct stat st; | ||
+ int i; | ||
+#ifdef CONFIG_UTIMENSAT | ||
+ int ret; | ||
+ | ||
+ ret = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); | ||
+ if (ret != -1 || errno != ENOSYS) { | ||
+ return ret; | ||
+ } | ||
+#endif | ||
+ /* Fallback: use utimes() instead of utimensat() */ | ||
+ | ||
+ /* happy if special cases */ | ||
+ if (times[0].tv_nsec == UTIME_OMIT && times[1].tv_nsec == UTIME_OMIT) { | ||
+ return 0; | ||
+ } | ||
+ if (times[0].tv_nsec == UTIME_NOW && times[1].tv_nsec == UTIME_NOW) { | ||
+ return utimes(path, NULL); | ||
+ } | ||
+ | ||
+ /* prepare for hard cases */ | ||
+ if (times[0].tv_nsec == UTIME_NOW || times[1].tv_nsec == UTIME_NOW) { | ||
+ gettimeofday(&tv_now, NULL); | ||
+ } | ||
+ if (times[0].tv_nsec == UTIME_OMIT || times[1].tv_nsec == UTIME_OMIT) { | ||
+ stat(path, &st); | ||
+ } | ||
+ | ||
+ for (i = 0; i < 2; i++) { | ||
+ if (times[i].tv_nsec == UTIME_NOW) { | ||
+ tv[i].tv_sec = tv_now.tv_sec; | ||
+ tv[i].tv_usec = tv_now.tv_usec; | ||
+ } else if (times[i].tv_nsec == UTIME_OMIT) { | ||
+ tv[i].tv_sec = (i == 0) ? st.st_atime : st.st_mtime; | ||
+ tv[i].tv_usec = 0; | ||
+ } else { | ||
+ tv[i].tv_sec = times[i].tv_sec; | ||
+ tv[i].tv_usec = times[i].tv_nsec / 1000; | ||
+ } | ||
+ } | ||
+ | ||
+ return utimes(path, &tv[0]); | ||
+} | ||
+ | ||
char * | ||
qemu_get_local_state_pathname(const char *relative_pathname) | ||
{ | ||
-- | ||
1.8.3-rc3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters