summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/util-linux/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/util-linux/util-linux')
-rw-r--r--meta/recipes-core/util-linux/util-linux/0001-lsfd-mkfds-foreign-sockets-skip-when-lacking-sock_di.patch36
-rw-r--r--meta/recipes-core/util-linux/util-linux/0001-tests-ts-kill-decode-avoid-using-shell-built-in-kill.patch36
-rw-r--r--meta/recipes-core/util-linux/util-linux/0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch58
-rw-r--r--meta/recipes-core/util-linux/util-linux/avoid_parallel_tests.patch26
-rw-r--r--meta/recipes-core/util-linux/util-linux/configure-sbindir.patch18
-rw-r--r--meta/recipes-core/util-linux/util-linux/display_testname_for_subtest.patch13
-rw-r--r--meta/recipes-core/util-linux/util-linux/fcntl-lock.c332
-rw-r--r--meta/recipes-core/util-linux/util-linux/ptest.patch14
-rw-r--r--meta/recipes-core/util-linux/util-linux/run-ptest29
9 files changed, 515 insertions, 47 deletions
diff --git a/meta/recipes-core/util-linux/util-linux/0001-lsfd-mkfds-foreign-sockets-skip-when-lacking-sock_di.patch b/meta/recipes-core/util-linux/util-linux/0001-lsfd-mkfds-foreign-sockets-skip-when-lacking-sock_di.patch
new file mode 100644
index 0000000000..e3f9112192
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/0001-lsfd-mkfds-foreign-sockets-skip-when-lacking-sock_di.patch
@@ -0,0 +1,36 @@
1From b3a1d92a9078fada31b2cf64b802edd616026766 Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Mon, 26 May 2025 15:24:16 +0800
4Subject: [PATCH] lsfd/mkfds-foreign-sockets: skip when lacking sock_diag
5 ability
6
7The ENDPOINTS will need sock_diag ability. The kernel might not
8enable related configs. Check and skip in case of lacking such ability.
9
10Fixes: https://github.com/util-linux/util-linux/issues/3590
11
12Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
13
14Upstream-Status: Submitted [https://github.com/util-linux/util-linux/pull/3591]
15
16Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
17---
18 tests/ts/lsfd/mkfds-foreign-sockets | 2 ++
19 1 file changed, 2 insertions(+)
20
21diff --git a/tests/ts/lsfd/mkfds-foreign-sockets b/tests/ts/lsfd/mkfds-foreign-sockets
22index cd94da799..76138a7a6 100755
23--- a/tests/ts/lsfd/mkfds-foreign-sockets
24+++ b/tests/ts/lsfd/mkfds-foreign-sockets
25@@ -30,6 +30,8 @@ ts_skip_nonroot
26 ts_skip_qemu_user
27 ts_cd "$TS_OUTDIR"
28
29+lsfd_check_sockdiag "unix"
30+
31 declare -A tcase
32 tcase[NAME]="state=connected"
33 tcase[SOCK.NETNS]=
34--
352.34.1
36
diff --git a/meta/recipes-core/util-linux/util-linux/0001-tests-ts-kill-decode-avoid-using-shell-built-in-kill.patch b/meta/recipes-core/util-linux/util-linux/0001-tests-ts-kill-decode-avoid-using-shell-built-in-kill.patch
new file mode 100644
index 0000000000..dece0e94b7
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/0001-tests-ts-kill-decode-avoid-using-shell-built-in-kill.patch
@@ -0,0 +1,36 @@
1From d2eeccf36542d506b660641a07a44f3976772897 Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Thu, 15 May 2025 16:44:33 +0800
4Subject: [PATCH] tests/ts/kill/decode: avoid using shell built-in kill command
5
6This test case should do the same as other kill test cases, avoiding
7using shell built-in kill command.
8
9Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
10
11Upstream-Status: Backport [https://github.com/util-linux/util-linux/commit/d2eeccf36542d506b660641a07a44f3976772897]
12
13Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
14---
15 tests/ts/kill/decode | 5 +++++
16 1 file changed, 5 insertions(+)
17
18diff --git a/tests/ts/kill/decode b/tests/ts/kill/decode
19index 03bc25ff6..57149899e 100755
20--- a/tests/ts/kill/decode
21+++ b/tests/ts/kill/decode
22@@ -18,6 +18,11 @@ TS_DESC="decode functions"
23 . "$TS_TOPDIR/functions.sh"
24 ts_init "$*"
25
26+# make sure we do not use shell built-in command
27+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
28+ TS_CMD_KILL="$(which kill)"
29+fi
30+
31 ts_skip_qemu_user
32
33 ts_check_test_command "$TS_CMD_KILL"
34--
352.34.1
36
diff --git a/meta/recipes-core/util-linux/util-linux/0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch b/meta/recipes-core/util-linux/util-linux/0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch
new file mode 100644
index 0000000000..f4e2f9e745
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch
@@ -0,0 +1,58 @@
1From c5d5e8873029d170fcab38a6fbd5d5a355574b9f Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Wed, 4 Jun 2025 16:27:19 +0800
4Subject: [PATCH] ts/kill/decode: use RTMIN from 'kill -L' instead of
5 hardcoding 34
6
7glibc uses 34 as the value of SIGRTMIN:
8https://sourceware.org/git/?p=glibc.git;a=blob;f=signal/allocrtsig.c;h=8ed8e37dd6c41f94be6eef042ce9db1af1153228;hb=HEAD#l27 """
9static int current_rtmin = __SIGRTMIN + RESERVED_SIGRT; """
10
11musl uses 35 as the value of SIGRTMIN:
12https://git.musl-libc.org/cgit/musl/tree/src/signal/sigrtmin.c
13
14With the hardcoded 34, test case fails with the following difference:
15
16-Ignored: HUP QUIT TRAP PIPE ALRM
17+Ignored: HUP QUIT TRAP PIPE ALRM 34
18
19Extract the value of RTMIN from 'kill -L' to avoid such hardcoding.
20
21Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
22
23Upstream-Status: Backport [https://github.com/util-linux/util-linux/commit/c5d5e8873029d170fcab38a6fbd5d5a355574b9f]
24
25Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
26---
27 tests/ts/kill/decode | 9 +++++++--
28 1 file changed, 7 insertions(+), 2 deletions(-)
29
30diff --git a/tests/ts/kill/decode b/tests/ts/kill/decode
31index 57149899e..524b4e5e2 100755
32--- a/tests/ts/kill/decode
33+++ b/tests/ts/kill/decode
34@@ -53,14 +53,19 @@ ACK=
35 # Sending one more USR1 is for making the signal pending state.
36 "$TS_CMD_KILL" -USR1 "$PID"
37 "$TS_CMD_KILL" -d "$PID" | {
38- if [[ $("$TS_CMD_KILL" --list=34) == RT0 ]]; then
39+ SIGRTMIN=$("$TS_CMD_KILL" -L | grep -o '[0-9]\+ RTMIN' | cut -d " " -f 1)
40+ if [[ $("$TS_CMD_KILL" --list=$SIGRTMIN) == RT0 ]]; then
41 # See man signal(7).
42 # The Linux kernel supports a range of 33 different real-time signals,
43 # numbered 32 to 64. However, the glibc POSIX threads implementation in‐
44 # ternally uses two (for NPTL) or three (for LinuxThreads) real-time sig‐
45 # nals (see pthreads(7)), and adjusts the value of SIGRTMIN suitably (to
46 # 34 or 35).
47- sed -e s/' 32 33'// -e s/' 34'//
48+ sed_cmd="sed"
49+ for ((i=32; i<=SIGRTMIN; i++)); do
50+ sed_cmd+=" -e s/' $i'//"
51+ done
52+ eval $sed_cmd
53 else
54 cat
55 fi
56--
572.34.1
58
diff --git a/meta/recipes-core/util-linux/util-linux/avoid_parallel_tests.patch b/meta/recipes-core/util-linux/util-linux/avoid_parallel_tests.patch
index 748b6ef096..fe92afbc53 100644
--- a/meta/recipes-core/util-linux/util-linux/avoid_parallel_tests.patch
+++ b/meta/recipes-core/util-linux/util-linux/avoid_parallel_tests.patch
@@ -1,20 +1,28 @@
1From 43030388e831642d36cb7b9d4b63755e9696714a Mon Sep 17 00:00:00 2001
2From: Tudor Florea <tudor.florea@enea.com>
3Date: Mon, 14 Jun 2021 14:00:31 +0200
4Subject: [PATCH] util-linux: Add ptest
5
1Ptest needs buildtest-TESTS and runtest-TESTS targets. 6Ptest needs buildtest-TESTS and runtest-TESTS targets.
2serial-tests is required to generate those targets. 7serial-tests is required to generate those targets.
3Revert run.sh script accordingly to serialize running tests 8Revert run.sh script accordingly to serialize running tests
4 9
5Signed-off-by: Tudor Florea <tudor.florea@enea.com> 10Signed-off-by: Tudor Florea <tudor.florea@enea.com>
6Upstream-Status: Inappropriate 11Upstream-Status: Inappropriate
12---
13 configure.ac | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
7 15
8Index: util-linux-2.32/configure.ac 16diff --git a/configure.ac b/configure.ac
9=================================================================== 17index 43a23a5..4a84531 100644
10--- util-linux-2.32.orig/configure.ac 18--- a/configure.ac
11+++ util-linux-2.32/configure.ac 19+++ b/configure.ac
12@@ -11,7 +11,7 @@ AC_CONFIG_MACRO_DIR([m4]) 20@@ -11,7 +11,7 @@ AC_CONFIG_MACRO_DIR([m4])
13 dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run 21 dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run
14 dnl the compiler (like AC_PROG_LIBTOOL) to avoid autoconf errors. 22 dnl the compiler (like LT_INIT) to avoid autoconf errors.
15 AC_USE_SYSTEM_EXTENSIONS 23 AC_USE_SYSTEM_EXTENSIONS
16-AM_INIT_AUTOMAKE([-Wall foreign 1.10 tar-pax no-dist-gzip dist-xz subdir-objects]) 24-AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign 1.10 tar-pax no-dist-gzip dist-xz subdir-objects])
17+AM_INIT_AUTOMAKE([-Wall foreign 1.10 tar-pax no-dist-gzip dist-xz subdir-objects serial-tests]) 25+AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign 1.10 tar-pax no-dist-gzip dist-xz subdir-objects serial-tests])
18 26
19 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], 27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
20 [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) 28 [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
diff --git a/meta/recipes-core/util-linux/util-linux/configure-sbindir.patch b/meta/recipes-core/util-linux/util-linux/configure-sbindir.patch
index e475289f65..ebb32a6845 100644
--- a/meta/recipes-core/util-linux/util-linux/configure-sbindir.patch
+++ b/meta/recipes-core/util-linux/util-linux/configure-sbindir.patch
@@ -1,15 +1,23 @@
1From 378998bf82e3b6ff46569077b29f95e72b734681 Mon Sep 17 00:00:00 2001
2From: Phil Blundell <pb@pbcl.net>
3Date: Mon, 24 Sep 2012 07:24:51 +0100
4Subject: [PATCH] util-linux: Ensure that ${sbindir} is respected
5
1util-linux: take ${sbindir} from the environment if it is set there 6util-linux: take ${sbindir} from the environment if it is set there
2fix the test, the [ ] syntax was getting eaten by autoconf 7fix the test, the [ ] syntax was getting eaten by autoconf
3 8
4Signed-off-by: Phil Blundell <pb@pbcl.net> 9Signed-off-by: Phil Blundell <pb@pbcl.net>
5Signed-off-by: Saul Wold <sgw@linux.intel.com 10Signed-off-by: Saul Wold <sgw@linux.intel.com
6Upstream-Status: Inappropriate [configuration] 11Upstream-Status: Inappropriate [configuration]
12---
13 configure.ac | 5 ++++-
14 1 file changed, 4 insertions(+), 1 deletion(-)
7 15
8Index: util-linux-2.31/configure.ac 16diff --git a/configure.ac b/configure.ac
9=================================================================== 17index a5d9102..43a23a5 100644
10--- util-linux-2.31.orig/configure.ac 18--- a/configure.ac
11+++ util-linux-2.31/configure.ac 19+++ b/configure.ac
12@@ -89,7 +89,10 @@ AC_SUBST([runstatedir]) 20@@ -110,7 +110,10 @@ AC_SUBST([runstatedir])
13 usrbin_execdir='${exec_prefix}/bin' 21 usrbin_execdir='${exec_prefix}/bin'
14 AC_SUBST([usrbin_execdir]) 22 AC_SUBST([usrbin_execdir])
15 23
diff --git a/meta/recipes-core/util-linux/util-linux/display_testname_for_subtest.patch b/meta/recipes-core/util-linux/util-linux/display_testname_for_subtest.patch
index 417ca1d98f..fa4ae02bc3 100644
--- a/meta/recipes-core/util-linux/util-linux/display_testname_for_subtest.patch
+++ b/meta/recipes-core/util-linux/util-linux/display_testname_for_subtest.patch
@@ -1,17 +1,19 @@
1Display testname for subtest 1From 728c2abd889d225535008c3e7a1eef4b8a0aeea2 Mon Sep 17 00:00:00 2001
2From: Tudor Florea <tudor.florea@enea.com>
3Date: Thu, 3 Dec 2015 04:08:00 +0100
4Subject: [PATCH] Display testname for subtest
2 5
3Signed-off-by: Tudor Florea <tudor.florea@enea.com> 6Signed-off-by: Tudor Florea <tudor.florea@enea.com>
4Upstream-Status: Pending 7Upstream-Status: Pending
5
6--- 8---
7 tests/functions.sh | 2 +- 9 tests/functions.sh | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-) 10 1 file changed, 1 insertion(+), 1 deletion(-)
9 11
10diff --git a/tests/functions.sh b/tests/functions.sh 12diff --git a/tests/functions.sh b/tests/functions.sh
11index 5246605..b24dc15 100644 13index 1d7a425..b1f0986 100644
12--- a/tests/functions.sh 14--- a/tests/functions.sh
13+++ b/tests/functions.sh 15+++ b/tests/functions.sh
14@@ -320,7 +320,7 @@ function ts_init_subtest { 16@@ -455,7 +455,7 @@ function ts_init_subtest {
15 17
16 if [ "$TS_PARSABLE" != "yes" ]; then 18 if [ "$TS_PARSABLE" != "yes" ]; then
17 [ $TS_NSUBTESTS -eq 1 ] && echo 19 [ $TS_NSUBTESTS -eq 1 ] && echo
@@ -20,6 +22,3 @@ index 5246605..b24dc15 100644
20 fi 22 fi
21 } 23 }
22 24
23--
242.8.3
25
diff --git a/meta/recipes-core/util-linux/util-linux/fcntl-lock.c b/meta/recipes-core/util-linux/util-linux/fcntl-lock.c
new file mode 100644
index 0000000000..966d8c5ecb
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/fcntl-lock.c
@@ -0,0 +1,332 @@
1// From https://github.com/magnumripper/fcntl-lock
2// SPDX-License-Identifier: MIT
3/* ----------------------------------------------------------------------- *
4 *
5 * Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
6 * Copyright 2015 magnum (fcntl version)
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense, and/or
13 * sell copies of the Software, and to permit persons to whom
14 * the Software is furnished to do so, subject to the following
15 * conditions:
16 *
17 * The above copyright notice and this permission notice shall
18 * be included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * ----------------------------------------------------------------------- */
30
31#include <errno.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <fcntl.h>
35#include <unistd.h>
36#include <getopt.h>
37#include <signal.h>
38#include <ctype.h>
39#include <string.h>
40#include <paths.h>
41#include <sysexits.h>
42#include <sys/types.h>
43#include <sys/file.h>
44#include <sys/time.h>
45#include <sys/wait.h>
46
47#define PACKAGE_STRING "magnum"
48#define _(x) (x)
49
50static const struct option long_options[] = {
51 { "shared", 0, NULL, 's' },
52 { "exclusive", 0, NULL, 'x' },
53 { "unlock", 0, NULL, 'u' },
54 { "nonblocking", 0, NULL, 'n' },
55 { "nb", 0, NULL, 'n' },
56 { "timeout", 1, NULL, 'w' },
57 { "wait", 1, NULL, 'w' },
58 { "close", 0, NULL, 'o' },
59 { "help", 0, NULL, 'h' },
60 { "version", 0, NULL, 'V' },
61 { 0, 0, 0, 0 }
62};
63
64const char *program;
65
66static void usage(int ex)
67{
68 fputs("fcntl-lock (" PACKAGE_STRING ")\n", stderr);
69 fprintf(stderr,
70 _("Usage: %1$s [-sxun][-w #] fd#\n"
71 " %1$s [-sxon][-w #] file [-c] command...\n"
72 " %1$s [-sxon][-w #] directory [-c] command...\n"
73 " -s --shared Get a shared lock\n"
74 " -x --exclusive Get an exclusive lock\n"
75 " -u --unlock Remove a lock\n"
76 " -n --nonblock Fail rather than wait\n"
77 " -w --timeout Wait for a limited amount of time\n"
78 " -o --close Close file descriptor before running command\n"
79 " -c --command Run a single command string through the shell\n"
80 " -h --help Display this text\n"
81 " -V --version Display version\n"),
82 program);
83 exit(ex);
84}
85
86
87static sig_atomic_t timeout_expired = 0;
88
89static void timeout_handler(int sig)
90{
91 (void)sig;
92
93 timeout_expired = 1;
94}
95
96
97static char * strtotimeval(const char *str, struct timeval *tv)
98{
99 char *s;
100 long fs; /* Fractional seconds */
101 int i;
102
103 tv->tv_sec = strtol(str, &s, 10);
104 fs = 0;
105
106 if ( *s == '.' ) {
107 s++;
108
109 for ( i = 0 ; i < 6 ; i++ ) {
110 if ( !isdigit(*s) )
111 break;
112
113 fs *= 10;
114 fs += *s++ - '0';
115 }
116
117 for ( ; i < 6; i++ )
118 fs *= 10;
119
120 while ( isdigit(*s) )
121 s++;
122 }
123
124 tv->tv_usec = fs;
125 return s;
126}
127
128int main(int argc, char *argv[])
129{
130 struct itimerval timeout, old_timer;
131 int have_timeout = 0;
132 int type = F_WRLCK;
133 int block = F_SETLKW;
134 int fd = -1;
135 int opt, ix;
136 int do_close = 0;
137 int err;
138 int status;
139 char *eon;
140 char **cmd_argv = NULL, *sh_c_argv[4];
141 struct flock lock;
142 const char *filename = NULL;
143 struct sigaction sa, old_sa;
144
145 program = argv[0];
146
147 if ( argc < 2 )
148 usage(EX_USAGE);
149
150 memset(&timeout, 0, sizeof timeout);
151
152 optopt = 0;
153 while ( (opt = getopt_long(argc, argv, "+sexnouw:hV?", long_options, &ix)) != EOF ) {
154 switch(opt) {
155 case 's':
156 type = F_RDLCK;
157 break;
158 case 'e':
159 case 'x':
160 type = F_WRLCK;
161 break;
162 case 'u':
163 type = F_UNLCK;
164 break;
165 case 'o':
166 do_close = 1;
167 break;
168 case 'n':
169 block = F_SETLK;
170 break;
171 case 'w':
172 have_timeout = 1;
173 eon = strtotimeval(optarg, &timeout.it_value);
174 if ( *eon )
175 usage(EX_USAGE);
176 break;
177 case 'V':
178 printf("fcntl-lock (%s)\n", PACKAGE_STRING);
179 exit(0);
180 default:
181 /* optopt will be set if this was an unrecognized option, i.e. *not* 'h' or '?' */
182 usage(optopt ? EX_USAGE : 0);
183 break;
184 }
185 }
186
187 if ( argc > optind+1 ) {
188 /* Run command */
189
190 if ( !strcmp(argv[optind+1], "-c") ||
191 !strcmp(argv[optind+1], "--command") ) {
192
193 if ( argc != optind+3 ) {
194 fprintf(stderr, _("%s: %s requires exactly one command argument\n"),
195 program, argv[optind+1]);
196 exit(EX_USAGE);
197 }
198
199 cmd_argv = sh_c_argv;
200
201 cmd_argv[0] = getenv("SHELL");
202 if ( !cmd_argv[0] || !*cmd_argv[0] )
203 cmd_argv[0] = _PATH_BSHELL;
204
205 cmd_argv[1] = "-c";
206 cmd_argv[2] = argv[optind+2];
207 cmd_argv[3] = 0;
208 } else {
209 cmd_argv = &argv[optind+1];
210 }
211
212 filename = argv[optind];
213 fd = open(filename, O_RDWR|O_NOCTTY|O_CREAT, 0666);
214 /* Linux doesn't like O_CREAT on a directory, even though it should be a
215 no-op */
216 if (fd < 0 && errno == EISDIR)
217 fd = open(filename, O_RDONLY|O_NOCTTY);
218
219 if ( fd < 0 ) {
220 err = errno;
221 fprintf(stderr, _("%s: cannot open lock file %s: %s\n"),
222 program, argv[optind], strerror(err));
223 exit((err == ENOMEM||err == EMFILE||err == ENFILE) ? EX_OSERR :
224 (err == EROFS||err == ENOSPC) ? EX_CANTCREAT :
225 EX_NOINPUT);
226 }
227
228 } else if (optind < argc) {
229 /* Use provided file descriptor */
230
231 fd = (int)strtol(argv[optind], &eon, 10);
232 if ( *eon || !argv[optind] ) {
233 fprintf(stderr, _("%s: bad number: %s\n"), program, argv[optind]);
234 exit(EX_USAGE);
235 }
236
237 } else {
238 /* Bad options */
239
240 fprintf(stderr, _("%s: requires file descriptor, file or directory\n"),
241 program);
242 exit(EX_USAGE);
243 }
244
245
246 if ( have_timeout ) {
247 if ( timeout.it_value.tv_sec == 0 &&
248 timeout.it_value.tv_usec == 0 ) {
249 /* -w 0 is equivalent to -n; this has to be special-cased
250 because setting an itimer to zero means disabled! */
251
252 have_timeout = 0;
253 block = F_SETLK;
254 } else {
255 memset(&sa, 0, sizeof sa);
256
257 sa.sa_handler = timeout_handler;
258 sa.sa_flags = SA_RESETHAND;
259 sigaction(SIGALRM, &sa, &old_sa);
260
261 setitimer(ITIMER_REAL, &timeout, &old_timer);
262 }
263 }
264
265 memset(&lock, 0, sizeof(lock));
266 lock.l_type = type;
267 while ( fcntl(fd, block, &lock) ) {
268 switch( (err = errno) ) {
269 case EAGAIN: /* -n option set and failed to lock */
270 case EACCES: /* -n option set and failed to lock */
271 exit(1);
272 case EINTR: /* Signal received */
273 if ( timeout_expired )
274 exit(1); /* -w option set and failed to lock */
275 continue; /* otherwise try again */
276 default: /* Other errors */
277 if ( filename )
278 fprintf(stderr, "%s: %s: %s\n", program, filename, strerror(err));
279 else
280 fprintf(stderr, "%s: %d: %s\n", program, fd, strerror(err));
281 exit((err == ENOLCK||err == ENOMEM) ? EX_OSERR : EX_DATAERR);
282 }
283 }
284
285 if ( have_timeout ) {
286 setitimer(ITIMER_REAL, &old_timer, NULL); /* Cancel itimer */
287 sigaction(SIGALRM, &old_sa, NULL); /* Cancel signal handler */
288 }
289
290 status = 0;
291
292 if ( cmd_argv ) {
293 pid_t w, f;
294
295 /* Clear any inherited settings */
296 signal(SIGCHLD, SIG_DFL);
297 f = fork();
298
299 if ( f < 0 ) {
300 err = errno;
301 fprintf(stderr, _("%s: fork failed: %s\n"), program, strerror(err));
302 exit(EX_OSERR);
303 } else if ( f == 0 ) {
304 if ( do_close )
305 close(fd);
306 err = errno;
307 execvp(cmd_argv[0], cmd_argv);
308 /* execvp() failed */
309 fprintf(stderr, "%s: %s: %s\n", program, cmd_argv[0], strerror(err));
310 _exit((err == ENOMEM) ? EX_OSERR: EX_UNAVAILABLE);
311 } else {
312 do {
313 w = waitpid(f, &status, 0);
314 if (w == -1 && errno != EINTR)
315 break;
316 } while ( w != f );
317
318 if (w == -1) {
319 err = errno;
320 status = EXIT_FAILURE;
321 fprintf(stderr, "%s: waitpid failed: %s\n", program, strerror(err));
322 } else if ( WIFEXITED(status) )
323 status = WEXITSTATUS(status);
324 else if ( WIFSIGNALED(status) )
325 status = WTERMSIG(status) + 128;
326 else
327 status = EX_OSERR; /* WTF? */
328 }
329 }
330
331 return status;
332}
diff --git a/meta/recipes-core/util-linux/util-linux/ptest.patch b/meta/recipes-core/util-linux/util-linux/ptest.patch
index 0537f7d856..ad23001cfa 100644
--- a/meta/recipes-core/util-linux/util-linux/ptest.patch
+++ b/meta/recipes-core/util-linux/util-linux/ptest.patch
@@ -1,4 +1,7 @@
1Define TESTS variable 1From 18bf6aded9b2a75185ae4b23a41cd2e4322c5e31 Mon Sep 17 00:00:00 2001
2From: Tudor Florea <tudor.florea@enea.com>
3Date: Thu, 3 Dec 2015 04:08:00 +0100
4Subject: [PATCH] Define TESTS variable
2 5
3Signed-off-by: Tudor Florea <tudor.florea@enea.com> 6Signed-off-by: Tudor Florea <tudor.florea@enea.com>
4Upstream-Status: Pending 7Upstream-Status: Pending
@@ -7,17 +10,14 @@ Upstream-Status: Pending
7 1 file changed, 1 insertion(+) 10 1 file changed, 1 insertion(+)
8 11
9diff --git a/Makefile.am b/Makefile.am 12diff --git a/Makefile.am b/Makefile.am
10index bbaccb1..7d5a6bb 100644 13index 01e9970..c3313ff 100644
11--- a/Makefile.am 14--- a/Makefile.am
12+++ b/Makefile.am 15+++ b/Makefile.am
13@@ -48,6 +48,7 @@ systemdsystemunit_DATA = 16@@ -66,6 +66,7 @@ sysusers_DATA =
14 dist_bashcompletion_DATA = 17 dist_bashcompletion_DATA =
15 check_PROGRAMS = 18 check_PROGRAMS =
16 dist_check_SCRIPTS = 19 dist_check_SCRIPTS =
17+TESTS = $(check_PROGRAMS) 20+TESTS = $(check_PROGRAMS)
18 21
19 PATHFILES = 22 BUILT_SOURCES =
20 23
21--
222.8.3
23
diff --git a/meta/recipes-core/util-linux/util-linux/run-ptest b/meta/recipes-core/util-linux/util-linux/run-ptest
index e135ee583b..1410229172 100644
--- a/meta/recipes-core/util-linux/util-linux/run-ptest
+++ b/meta/recipes-core/util-linux/util-linux/run-ptest
@@ -13,31 +13,22 @@ current_path=$(readlink -f $0)
13export bindir=$(dirname $current_path) 13export bindir=$(dirname $current_path)
14export PATH=$bindir/bin:$PATH 14export PATH=$bindir/bin:$PATH
15 15
16cd tests || exit 1 16# losetup tests will be skipped and/or fail otherwise
17modprobe loop
17 18
18comps=$(find ts/ -type f -perm -111 -regex ".*/[^\.~]*" | sort) 19# required for mount/fallback test to pass
20# systemd does this by default, but ptest images do not use it
21# see https://man7.org/linux/man-pages/man7/mount_namespaces.7.html
22# for a long description of mount namespaces in Linux
23mount --make-shared /
19 24
20 25# lsfd/mkfds-bpf* have issues with the gcc 15 upgrade
21echo 26./tests/run.sh --use-system-commands --parsable --show-diff --exclude='lsfd/mkfds-bpf-map lsfd/mkfds-bpf-prog' | sed -u '{
22echo "-------------------- util-linux regression tests --------------------"
23echo
24echo " For development purpose only. "
25echo " Don't execute on production system! "
26echo
27
28res=0
29count=0
30for ts in $comps;
31do
32 $ts | sed -u '{
33 s/^\(.*\):\(.*\) \.\.\. OK$/PASS: \1:\2/ 27 s/^\(.*\):\(.*\) \.\.\. OK$/PASS: \1:\2/
34 s/^\(.*\):\(.*\) \.\.\. FAILED \(.*\)$/FAIL: \1:\2 \3/ 28 s/^\(.*\):\(.*\) \.\.\. FAILED \(.*\)$/FAIL: \1:\2 \3/
35 s/^\(.*\):\(.*\) \.\.\. SKIPPED \(.*\)$/SKIP: \1:\2 \3/ 29 s/^\(.*\):\(.*\) \.\.\. SKIPPED \(.*\)$/SKIP: \1:\2 \3/
36 }' 30 }'
37done
38
39 31
40if [ "x$UDEV_PID" != "x" ]; then 32if [ "x$UDEV_PID" != "x" ]; then
41 /etc/init.d/udev start 33 /etc/init.d/udev start
42fi 34fi
43