Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | From 66533c7c6f347d257020675a1ed6e0c59cbbc3f0 Mon Sep 17 00:00:00 2001 |
| 2 | From: Chen Qi <Qi.Chen@windriver.com> |
| 3 | Date: Thu, 17 Jul 2014 15:53:34 +0800 |
| 4 | Subject: [PATCH] commonio.c-fix-unexpected-open-failure-in-chroot-env |
| 5 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | Upstream-Status: Inappropriate [OE specific] |
| 7 | |
| 8 | commonio.c: fix unexpected open failure in chroot environment |
| 9 | |
| 10 | When using commands with '-R <newroot>' option in our pseudo environment, |
| 11 | we would usually get the 'Pemission Denied' error. This patch serves as |
| 12 | a workaround to this problem. |
| 13 | |
| 14 | Note that this patch doesn't change the logic in the code, it just expands |
| 15 | the codes. |
| 16 | |
| 17 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | --- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 20 | lib/commonio.c | 16 ++++++++++++---- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | 1 file changed, 12 insertions(+), 4 deletions(-) |
| 22 | |
| 23 | diff --git a/lib/commonio.c b/lib/commonio.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 24 | index 16fa7e7..d6bc297 100644 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | --- a/lib/commonio.c |
| 26 | +++ b/lib/commonio.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 27 | @@ -632,10 +632,18 @@ int commonio_open (struct commonio_db *db, int mode) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | db->cursor = NULL; |
| 29 | db->changed = false; |
| 30 | |
| 31 | - fd = open (db->filename, |
| 32 | - (db->readonly ? O_RDONLY : O_RDWR) |
| 33 | - | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); |
| 34 | - saved_errno = errno; |
| 35 | + if (db->readonly) { |
| 36 | + fd = open (db->filename, |
| 37 | + (true ? O_RDONLY : O_RDWR) |
| 38 | + | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); |
| 39 | + saved_errno = errno; |
| 40 | + } else { |
| 41 | + fd = open (db->filename, |
| 42 | + (false ? O_RDONLY : O_RDWR) |
| 43 | + | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); |
| 44 | + saved_errno = errno; |
| 45 | + } |
| 46 | + |
| 47 | db->fp = NULL; |
| 48 | if (fd >= 0) { |
| 49 | #ifdef WITH_TCB |