diff options
| author | Alexander Kanavin <alex.kanavin@gmail.com> | 2023-06-14 11:28:36 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-15 21:25:42 +0100 |
| commit | c365c810c60af08f53880eaf613e524b00e31077 (patch) | |
| tree | 38fa9ce49a7fb20686c6165f5614e07210b96095 | |
| parent | ee6305bdd0971d493148eb0e38e44aef63eeaba8 (diff) | |
| download | poky-c365c810c60af08f53880eaf613e524b00e31077.tar.gz | |
glib-2.0: backport a patch to address ptest fails caused by coreutils 9.2+
(From OE-Core rev: d6c1978846f708d852b52c04c4fd89642cbc7a0d)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-core/glib-2.0/glib-2.0/0001-glocalfile-Sum-apparent-size-only-for-files-and-syml.patch | 105 | ||||
| -rw-r--r-- | meta/recipes-core/glib-2.0/glib-2.0_2.76.3.bb | 1 |
2 files changed, 106 insertions, 0 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0001-glocalfile-Sum-apparent-size-only-for-files-and-syml.patch b/meta/recipes-core/glib-2.0/glib-2.0/0001-glocalfile-Sum-apparent-size-only-for-files-and-syml.patch new file mode 100644 index 0000000000..a881b25ef3 --- /dev/null +++ b/meta/recipes-core/glib-2.0/glib-2.0/0001-glocalfile-Sum-apparent-size-only-for-files-and-syml.patch | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | From d1a2117dc18dbcf87685891de7e2898108b66fc9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Joan Bruguera <joanbrugueram@gmail.com> | ||
| 3 | Date: Thu, 23 Mar 2023 02:24:30 +0000 | ||
| 4 | Subject: [PATCH] glocalfile: Sum apparent size only for files and symlinks | ||
| 5 | |||
| 6 | Since GNU Coreutils 9.2 (commit 110bcd28386b1f47a4cd876098acb708fdcbbb25), | ||
| 7 | `du --apparent-size` (including `du --bytes`) no longer counts all kinds of | ||
| 8 | files (directories, FIFOs, etc.), but only those for which `st_size` in | ||
| 9 | `struct stat` is defined by POSIX, namely regular files and symlinks | ||
| 10 | (and also rarely supported memory objects). | ||
| 11 | |||
| 12 | This aligns the behaviour of GLib's `G_FILE_MEASURE_APPARENT_SIZE` flag | ||
| 13 | with the new GNU Coreutils `du` and correct POSIX use. | ||
| 14 | |||
| 15 | Note that this may be a breaking change for some uses. | ||
| 16 | |||
| 17 | Link: https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00007.html | ||
| 18 | Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2965 | ||
| 19 | |||
| 20 | Upstream-Status: Backport | ||
| 21 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
| 22 | --- | ||
| 23 | gio/gioenums.h | 3 +++ | ||
| 24 | gio/glocalfile.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
| 25 | 2 files changed, 40 insertions(+) | ||
| 26 | |||
| 27 | diff --git a/gio/gioenums.h b/gio/gioenums.h | ||
| 28 | index 7fd74a43e..c820cd36d 100644 | ||
| 29 | --- a/gio/gioenums.h | ||
| 30 | +++ b/gio/gioenums.h | ||
| 31 | @@ -224,6 +224,9 @@ typedef enum { | ||
| 32 | * sizes. Normally, the block-size is used, if available, as this is a | ||
| 33 | * more accurate representation of disk space used. | ||
| 34 | * Compare with `du --apparent-size`. | ||
| 35 | + * Since GLib 2.78. and similarly to `du` since GNU Coreutils 9.2, this will | ||
| 36 | + * ignore the sizes of file types other than regular files and links, as the | ||
| 37 | + * sizes of other file types are not specified in a standard way. | ||
| 38 | * @G_FILE_MEASURE_NO_XDEV: Do not cross mount point boundaries. | ||
| 39 | * Compare with `du -x`. | ||
| 40 | * | ||
| 41 | diff --git a/gio/glocalfile.c b/gio/glocalfile.c | ||
| 42 | index 67d4b99fb..dbb56902d 100644 | ||
| 43 | --- a/gio/glocalfile.c | ||
| 44 | +++ b/gio/glocalfile.c | ||
| 45 | @@ -86,6 +86,9 @@ | ||
| 46 | #define FILE_READ_ONLY_VOLUME 0x00080000 | ||
| 47 | #endif | ||
| 48 | |||
| 49 | +#ifndef S_ISREG | ||
| 50 | +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) | ||
| 51 | +#endif | ||
| 52 | #ifndef S_ISDIR | ||
| 53 | #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) | ||
| 54 | #endif | ||
| 55 | @@ -2777,6 +2780,39 @@ g_local_file_measure_size_of_contents (gint fd, | ||
| 56 | MeasureState *state, | ||
| 57 | GError **error); | ||
| 58 | |||
| 59 | +/* | ||
| 60 | + * _g_stat_is_size_usable: | ||
| 61 | + * @buf: a #GLocalFileStat. | ||
| 62 | + * | ||
| 63 | + * Checks if the file type is such that the `st_size` field of `struct stat` is | ||
| 64 | + * well-defined by POSIX. | ||
| 65 | + * (see https://pubs.opengroup.org/onlinepubs/009696799/basedefs/sys/stat.h.html) | ||
| 66 | + * | ||
| 67 | + * This behaviour is aligned with `du` from GNU Coreutils 9.2+ | ||
| 68 | + * (see https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00007.html) | ||
| 69 | + * and makes apparent size sums well-defined; formerly, they depended on the | ||
| 70 | + * implementation, and could differ across filesystems. | ||
| 71 | + * | ||
| 72 | + * Returns: %TRUE if the size field is well-defined, %FALSE otherwise. | ||
| 73 | + **/ | ||
| 74 | +inline static gboolean | ||
| 75 | +_g_stat_is_size_usable (const GLocalFileStat *buf) | ||
| 76 | +{ | ||
| 77 | +#ifndef HAVE_STATX | ||
| 78 | + /* Memory objects are defined by POSIX, but are not supported by statx nor Windows */ | ||
| 79 | +#ifdef S_TYPEISSHM | ||
| 80 | + if (S_TYPEISSHM (buf)) | ||
| 81 | + return TRUE; | ||
| 82 | +#endif | ||
| 83 | +#ifdef S_TYPEISTMO | ||
| 84 | + if (S_TYPEISTMO (buf)) | ||
| 85 | + return TRUE; | ||
| 86 | +#endif | ||
| 87 | +#endif | ||
| 88 | + | ||
| 89 | + return S_ISREG (_g_stat_mode (buf)) || S_ISLNK (_g_stat_mode (buf)); | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | static gboolean | ||
| 93 | g_local_file_measure_size_of_file (gint parent_fd, | ||
| 94 | GSList *name, | ||
| 95 | @@ -2836,6 +2872,7 @@ g_local_file_measure_size_of_file (gint parent_fd, | ||
| 96 | state->disk_usage += _g_stat_blocks (&buf) * G_GUINT64_CONSTANT (512); | ||
| 97 | else | ||
| 98 | #endif | ||
| 99 | + if (_g_stat_is_size_usable (&buf)) | ||
| 100 | state->disk_usage += _g_stat_size (&buf); | ||
| 101 | |||
| 102 | if (S_ISDIR (_g_stat_mode (&buf))) | ||
| 103 | -- | ||
| 104 | 2.39.2 | ||
| 105 | |||
diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.76.3.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.76.3.bb index a60e768836..4327a13345 100644 --- a/meta/recipes-core/glib-2.0/glib-2.0_2.76.3.bb +++ b/meta/recipes-core/glib-2.0/glib-2.0_2.76.3.bb | |||
| @@ -15,6 +15,7 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \ | |||
| 15 | file://0001-meson-Run-atomics-test-on-clang-as-well.patch \ | 15 | file://0001-meson-Run-atomics-test-on-clang-as-well.patch \ |
| 16 | file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \ | 16 | file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \ |
| 17 | file://0001-gio-tests-portal-support-Fix-snap-test-ordering-race.patch \ | 17 | file://0001-gio-tests-portal-support-Fix-snap-test-ordering-race.patch \ |
| 18 | file://0001-glocalfile-Sum-apparent-size-only-for-files-and-syml.patch \ | ||
| 18 | " | 19 | " |
| 19 | SRC_URI:append:class-native = " file://relocate-modules.patch" | 20 | SRC_URI:append:class-native = " file://relocate-modules.patch" |
| 20 | 21 | ||
