1*44b3caf2SPatrick WilliamsFrom f512071dd3a4c29d4bf048c5a89c4ba9160e37b1 Mon Sep 17 00:00:00 2001 282c905dcSAndrew GeisslerFrom: Chen Qi <Qi.Chen@windriver.com> 382c905dcSAndrew GeisslerDate: Thu, 17 Jul 2014 15:53:34 +0800 482c905dcSAndrew GeisslerSubject: [PATCH] commonio.c-fix-unexpected-open-failure-in-chroot-env 582c905dcSAndrew Geissler 6eb8dc403SDave CobbleyUpstream-Status: Inappropriate [OE specific] 7eb8dc403SDave Cobbley 8eb8dc403SDave Cobbleycommonio.c: fix unexpected open failure in chroot environment 9eb8dc403SDave Cobbley 10eb8dc403SDave CobbleyWhen using commands with '-R <newroot>' option in our pseudo environment, 11eb8dc403SDave Cobbleywe would usually get the 'Pemission Denied' error. This patch serves as 12eb8dc403SDave Cobbleya workaround to this problem. 13eb8dc403SDave Cobbley 14eb8dc403SDave CobbleyNote that this patch doesn't change the logic in the code, it just expands 15eb8dc403SDave Cobbleythe codes. 16eb8dc403SDave Cobbley 17eb8dc403SDave CobbleySigned-off-by: Chen Qi <Qi.Chen@windriver.com> 18eb8dc403SDave Cobbley--- 19eb8dc403SDave Cobbley lib/commonio.c | 16 ++++++++++++---- 20eb8dc403SDave Cobbley 1 file changed, 12 insertions(+), 4 deletions(-) 21eb8dc403SDave Cobbley 22eb8dc403SDave Cobbleydiff --git a/lib/commonio.c b/lib/commonio.c 23*44b3caf2SPatrick Williamsindex 01a26c9..82b2868 100644 24eb8dc403SDave Cobbley--- a/lib/commonio.c 25eb8dc403SDave Cobbley+++ b/lib/commonio.c 26*44b3caf2SPatrick Williams@@ -601,10 +601,18 @@ int commonio_open (struct commonio_db *db, int mode) 27eb8dc403SDave Cobbley db->cursor = NULL; 28eb8dc403SDave Cobbley db->changed = false; 29eb8dc403SDave Cobbley 30eb8dc403SDave Cobbley- fd = open (db->filename, 31eb8dc403SDave Cobbley- (db->readonly ? O_RDONLY : O_RDWR) 32705982a5SPatrick Williams- | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC); 33eb8dc403SDave Cobbley- saved_errno = errno; 34eb8dc403SDave Cobbley+ if (db->readonly) { 35eb8dc403SDave Cobbley+ fd = open (db->filename, 36eb8dc403SDave Cobbley+ (true ? O_RDONLY : O_RDWR) 37705982a5SPatrick Williams+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC); 38eb8dc403SDave Cobbley+ saved_errno = errno; 39eb8dc403SDave Cobbley+ } else { 40eb8dc403SDave Cobbley+ fd = open (db->filename, 41eb8dc403SDave Cobbley+ (false ? O_RDONLY : O_RDWR) 42705982a5SPatrick Williams+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW| O_CLOEXEC); 43eb8dc403SDave Cobbley+ saved_errno = errno; 44eb8dc403SDave Cobbley+ } 45eb8dc403SDave Cobbley+ 46eb8dc403SDave Cobbley db->fp = NULL; 47eb8dc403SDave Cobbley if (fd >= 0) { 48eb8dc403SDave Cobbley #ifdef WITH_TCB 49