diff options
author | hen Qi <Qi.Chen@windriver.com> | 2023-04-24 22:05:17 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-05-05 11:07:25 +0100 |
commit | 8a6f52393ec874e3d401f9faf620ebf5075889dc (patch) | |
tree | 01585263c337ddbb60dc89048a9ad70026564e00 /meta/recipes-devtools/unfs3 | |
parent | f91783635446e5bc391235272444d6dcb268a034 (diff) | |
download | poky-8a6f52393ec874e3d401f9faf620ebf5075889dc.tar.gz |
unfs3: fix symlink time setting issue
Add back the dropped 0001-attr-fix-utime-for-symlink.patch
to fix symlink time setting issue on NFS.
The problem could be reproduced by runing the following command
on nfs booted qemu:
ln -s dest src && touch -h src
Apart from the rpm operations mentioned in the original patch,
'docker pull' also fails with a 'stale file' error. The common
pattern here is extracting files from a bundle and setting times
for them.
(From OE-Core rev: fe35a2c11ba6f87735bccae244817016f9c1b5db)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/unfs3')
-rw-r--r-- | meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch | 88 | ||||
-rw-r--r-- | meta/recipes-devtools/unfs3/unfs3_git.bb | 1 |
2 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch b/meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch new file mode 100644 index 0000000000..a0f3740d6a --- /dev/null +++ b/meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch | |||
@@ -0,0 +1,88 @@ | |||
1 | From 7e789895919d57d573ebb8faa147d1286104cd01 Mon Sep 17 00:00:00 2001 | ||
2 | From: Rui Wang <rui.wang@windriver.com> | ||
3 | Date: Mon, 24 Apr 2023 02:57:57 -0700 | ||
4 | Subject: [PATCH] attr: fix utime for symlink | ||
5 | |||
6 | unfs3 has an old defect that it can not change the timestamps of a | ||
7 | symlink file because it only uses utime(), which will follow the | ||
8 | symlink. This will not cause an error if the symlink points to an | ||
9 | existent file. But under some special situation, such as installing | ||
10 | a rpm package, rpm tool will create the symlink first and try to | ||
11 | modify the timestamps of it, when the target file is non-existent. | ||
12 | This will cause an ESTALE error. Making rpm tool ignore this error | ||
13 | is a solution, but not the best one. An acceptable approach is | ||
14 | Making unfs3 support lutimes(), which can modify the symlink file | ||
15 | itself. Considering not every system support this function, so a | ||
16 | function checking is necessary. | ||
17 | |||
18 | Upstream-Status: Submitted [https://github.com/unfs3/unfs3/pull/35] | ||
19 | |||
20 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
21 | --- | ||
22 | attr.c | 15 +++++++++++---- | ||
23 | backend_unix.h | 2 ++ | ||
24 | configure.ac | 1 + | ||
25 | 3 files changed, 14 insertions(+), 4 deletions(-) | ||
26 | |||
27 | diff --git a/attr.c b/attr.c | ||
28 | index 0ce9375..930ce6e 100644 | ||
29 | --- a/attr.c | ||
30 | +++ b/attr.c | ||
31 | @@ -285,7 +285,7 @@ post_op_attr get_post_cached(struct svc_req * req) | ||
32 | static nfsstat3 set_time(const char *path, backend_statstruct buf, sattr3 new) | ||
33 | { | ||
34 | time_t new_atime, new_mtime; | ||
35 | - struct utimbuf utim; | ||
36 | + struct timeval stamps[2]; | ||
37 | int res; | ||
38 | |||
39 | /* set atime and mtime */ | ||
40 | @@ -307,10 +307,17 @@ static nfsstat3 set_time(const char *path, backend_statstruct buf, sattr3 new) | ||
41 | else /* DONT_CHANGE */ | ||
42 | new_mtime = buf.st_mtime; | ||
43 | |||
44 | - utim.actime = new_atime; | ||
45 | - utim.modtime = new_mtime; | ||
46 | + stamps[0].tv_sec = new_atime; | ||
47 | + stamps[0].tv_usec = 0; | ||
48 | + stamps[1].tv_sec = new_mtime; | ||
49 | + stamps[1].tv_usec = 0; | ||
50 | + | ||
51 | +#if HAVE_LUTIMES | ||
52 | + res = backend_lutimes(path, stamps); | ||
53 | +#else | ||
54 | + res = backend_utimes(path, stamps); | ||
55 | +#endif | ||
56 | |||
57 | - res = backend_utime(path, &utim); | ||
58 | if (res == -1) | ||
59 | return setattr_err(); | ||
60 | } | ||
61 | diff --git a/backend_unix.h b/backend_unix.h | ||
62 | index 4db72ae..9cce9ab 100644 | ||
63 | --- a/backend_unix.h | ||
64 | +++ b/backend_unix.h | ||
65 | @@ -61,6 +61,8 @@ | ||
66 | #define backend_symlink symlink | ||
67 | #define backend_truncate truncate | ||
68 | #define backend_utime utime | ||
69 | +#define backend_utimes utimes | ||
70 | +#define backend_lutimes lutimes | ||
71 | #define backend_statstruct struct stat | ||
72 | #define backend_dirstream DIR | ||
73 | #define backend_statvfsstruct struct statvfs | ||
74 | diff --git a/configure.ac b/configure.ac | ||
75 | index d46c905..c21afe3 100644 | ||
76 | --- a/configure.ac | ||
77 | +++ b/configure.ac | ||
78 | @@ -32,6 +32,7 @@ AC_CHECK_FUNCS(setresuid setresgid) | ||
79 | AC_CHECK_FUNCS(vsyslog) | ||
80 | AC_CHECK_FUNCS(lchown) | ||
81 | AC_CHECK_FUNCS(setgroups) | ||
82 | +AC_CHECK_FUNCS(lutimes) | ||
83 | UNFS3_COMPILE_WARNINGS | ||
84 | |||
85 | PKG_CHECK_MODULES([TIRPC], [libtirpc]) | ||
86 | -- | ||
87 | 2.40.0 | ||
88 | |||
diff --git a/meta/recipes-devtools/unfs3/unfs3_git.bb b/meta/recipes-devtools/unfs3/unfs3_git.bb index 9913a503e8..c5b7898b3c 100644 --- a/meta/recipes-devtools/unfs3/unfs3_git.bb +++ b/meta/recipes-devtools/unfs3/unfs3_git.bb | |||
@@ -17,6 +17,7 @@ SRC_URI = "git://github.com/unfs3/unfs3.git;protocol=https;branch=master \ | |||
17 | file://0001-Alias-off64_t-to-off_t-on-linux-if-not-defined.patch \ | 17 | file://0001-Alias-off64_t-to-off_t-on-linux-if-not-defined.patch \ |
18 | file://0001-locate.c-Include-attr.h.patch \ | 18 | file://0001-locate.c-Include-attr.h.patch \ |
19 | file://0001-fix-building-on-macOS.patch \ | 19 | file://0001-fix-building-on-macOS.patch \ |
20 | file://0001-attr-fix-utime-for-symlink.patch \ | ||
20 | " | 21 | " |
21 | SRCREV = "c8f2d2cd4529955419bad0e163f88d47ff176b8d" | 22 | SRCREV = "c8f2d2cd4529955419bad0e163f88d47ff176b8d" |
22 | UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>\d+(\.\d+)+)" | 23 | UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>\d+(\.\d+)+)" |