1*82c905dcSAndrew GeisslerFrom 66533c7c6f347d257020675a1ed6e0c59cbbc3f0 Mon Sep 17 00:00:00 2001 2*82c905dcSAndrew GeisslerFrom: Chen Qi <Qi.Chen@windriver.com> 3*82c905dcSAndrew GeisslerDate: Thu, 17 Jul 2014 15:53:34 +0800 4*82c905dcSAndrew GeisslerSubject: [PATCH] commonio.c-fix-unexpected-open-failure-in-chroot-env 5*82c905dcSAndrew 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> 18*82c905dcSAndrew Geissler 19eb8dc403SDave Cobbley--- 20eb8dc403SDave Cobbley lib/commonio.c | 16 ++++++++++++---- 21eb8dc403SDave Cobbley 1 file changed, 12 insertions(+), 4 deletions(-) 22eb8dc403SDave Cobbley 23eb8dc403SDave Cobbleydiff --git a/lib/commonio.c b/lib/commonio.c 24*82c905dcSAndrew Geisslerindex 16fa7e7..d6bc297 100644 25eb8dc403SDave Cobbley--- a/lib/commonio.c 26eb8dc403SDave Cobbley+++ b/lib/commonio.c 27*82c905dcSAndrew Geissler@@ -632,10 +632,18 @@ int commonio_open (struct commonio_db *db, int mode) 28eb8dc403SDave Cobbley db->cursor = NULL; 29eb8dc403SDave Cobbley db->changed = false; 30eb8dc403SDave Cobbley 31eb8dc403SDave Cobbley- fd = open (db->filename, 32eb8dc403SDave Cobbley- (db->readonly ? O_RDONLY : O_RDWR) 33eb8dc403SDave Cobbley- | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); 34eb8dc403SDave Cobbley- saved_errno = errno; 35eb8dc403SDave Cobbley+ if (db->readonly) { 36eb8dc403SDave Cobbley+ fd = open (db->filename, 37eb8dc403SDave Cobbley+ (true ? O_RDONLY : O_RDWR) 38eb8dc403SDave Cobbley+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); 39eb8dc403SDave Cobbley+ saved_errno = errno; 40eb8dc403SDave Cobbley+ } else { 41eb8dc403SDave Cobbley+ fd = open (db->filename, 42eb8dc403SDave Cobbley+ (false ? O_RDONLY : O_RDWR) 43eb8dc403SDave Cobbley+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW); 44eb8dc403SDave Cobbley+ saved_errno = errno; 45eb8dc403SDave Cobbley+ } 46eb8dc403SDave Cobbley+ 47eb8dc403SDave Cobbley db->fp = NULL; 48eb8dc403SDave Cobbley if (fd >= 0) { 49eb8dc403SDave Cobbley #ifdef WITH_TCB 50