blob: 4a932d2dbb14568cdf70010755f9c38af23f5feb [file] [log] [blame]
Patrick Williams705982a2024-01-12 09:51:57 -06001From a773c6b240d27e23d6be41decef0edf24fcee523 Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Chen Qi <Qi.Chen@windriver.com>
3Date: Thu, 17 Jul 2014 15:53:34 +0800
4Subject: [PATCH] commonio.c-fix-unexpected-open-failure-in-chroot-env
5
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006Upstream-Status: Inappropriate [OE specific]
7
8commonio.c: fix unexpected open failure in chroot environment
9
10When using commands with '-R <newroot>' option in our pseudo environment,
11we would usually get the 'Pemission Denied' error. This patch serves as
12a workaround to this problem.
13
14Note that this patch doesn't change the logic in the code, it just expands
15the codes.
16
17Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
18---
Andrew Geissler82c905d2020-04-13 13:39:40 -050019 lib/commonio.c | 16 ++++++++++++----
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 1 file changed, 12 insertions(+), 4 deletions(-)
21
22diff --git a/lib/commonio.c b/lib/commonio.c
Patrick Williams705982a2024-01-12 09:51:57 -060023index 73fdb3a..d1231e9 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024--- a/lib/commonio.c
25+++ b/lib/commonio.c
Patrick Williams705982a2024-01-12 09:51:57 -060026@@ -606,10 +606,18 @@ int commonio_open (struct commonio_db *db, int mode)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 db->cursor = NULL;
28 db->changed = false;
29
30- fd = open (db->filename,
31- (db->readonly ? O_RDONLY : O_RDWR)
Patrick Williams705982a2024-01-12 09:51:57 -060032- | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC);
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033- saved_errno = errno;
34+ if (db->readonly) {
35+ fd = open (db->filename,
36+ (true ? O_RDONLY : O_RDWR)
Patrick Williams705982a2024-01-12 09:51:57 -060037+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC);
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038+ saved_errno = errno;
39+ } else {
40+ fd = open (db->filename,
41+ (false ? O_RDONLY : O_RDWR)
Patrick Williams705982a2024-01-12 09:51:57 -060042+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW| O_CLOEXEC);
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043+ saved_errno = errno;
44+ }
45+
46 db->fp = NULL;
47 if (fd >= 0) {
48 #ifdef WITH_TCB
Patrick Williams705982a2024-01-12 09:51:57 -060049--
502.30.2
51