aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0040-containers-userns05-use-unsigned-int-for-ns-id.patch
blob: 4dee1f5a9b4fbc6faa66004d332ff9bd6a0e793e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 3b63d350e9fe9e4271916cc0abfac65a5d6419ff Mon Sep 17 00:00:00 2001
From: Jiri Jaburek <jjaburek@redhat.com>
Date: Tue, 7 Feb 2017 07:58:16 +0000
Subject: [PATCH] containers/userns05: use unsigned int for ns id

The kernel defines it as 'unsigned int' in 'struct ns_common'
and formats it as

  snprintf(buf, size, "%s:[%u]", ns_ops->name, ns->inum);

This change makes the test work on 32bit systems where LONG_MAX
is smaller than UINT_MAX.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>

Upstream-Status: Backport

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
 testcases/kernel/containers/userns/userns05.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/containers/userns/userns05.c b/testcases/kernel/containers/userns/userns05.c
index 8d8c40a..8eac729 100644
--- a/testcases/kernel/containers/userns/userns05.c
+++ b/testcases/kernel/containers/userns/userns05.c
@@ -49,18 +49,18 @@ static int child_fn1(void)
 	return 0;
 }
 
-static long getusernsidbypid(int pid)
+static unsigned int getusernsidbypid(int pid)
 {
 	char path[BUFSIZ];
 	char userid[BUFSIZ];
-	long id = 0;
+	unsigned int id = 0;
 
 	sprintf(path, "/proc/%d/ns/user", pid);
 
 	if (readlink(path, userid, BUFSIZ) == -1)
 		tst_resm(TFAIL | TERRNO, "readlink failure.");
 
-	if (sscanf(userid, "user:[%ld]", &id) != 1)
+	if (sscanf(userid, "user:[%u]", &id) != 1)
 		tst_resm(TFAIL, "sscanf failure.");
 	return id;
 }
@@ -68,7 +68,7 @@ static long getusernsidbypid(int pid)
 static void test_userns_id(void)
 {
 	int cpid1, cpid2, cpid3;
-	long parentuserns, cpid1userns, cpid2userns, newparentuserns;
+	unsigned int parentuserns, cpid1userns, cpid2userns, newparentuserns;
 
 	parentuserns = getusernsidbypid(getpid());
 	cpid1 = ltp_clone_quick(SIGCHLD, (void *)child_fn1,
-- 
2.9.3