blob: 4fa3d184edf73f4d7811e6762d0de11ddf4d83dd [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Upstream-Status: Inappropriate [OE specific]
2
3commonio.c: fix unexpected open failure in chroot environment
4
5When using commands with '-R <newroot>' option in our pseudo environment,
6we would usually get the 'Pemission Denied' error. This patch serves as
7a workaround to this problem.
8
9Note that this patch doesn't change the logic in the code, it just expands
10the codes.
11
12Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
13---
14 lib/commonio.c | 16 ++++++++++++----
15 1 file changed, 12 insertions(+), 4 deletions(-)
16
17diff --git a/lib/commonio.c b/lib/commonio.c
18index cc536bf..51cafd9 100644
19--- a/lib/commonio.c
20+++ b/lib/commonio.c
21@@ -613,10 +613,18 @@ int commonio_open (struct commonio_db *db, int mode)
22 db->cursor = NULL;
23 db->changed = false;
24
25- fd = open (db->filename,
26- (db->readonly ? O_RDONLY : O_RDWR)
27- | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
28- saved_errno = errno;
29+ if (db->readonly) {
30+ fd = open (db->filename,
31+ (true ? O_RDONLY : O_RDWR)
32+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
33+ saved_errno = errno;
34+ } else {
35+ fd = open (db->filename,
36+ (false ? O_RDONLY : O_RDWR)
37+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
38+ saved_errno = errno;
39+ }
40+
41 db->fp = NULL;
42 if (fd >= 0) {
43 #ifdef WITH_TCB
44--
451.7.9.5
46