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