From 3565df4546d97da4be573610a73f333d45a6287a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 12 Jul 2011 23:08:42 +0200 Subject: Define `O_NOTRANS' on GNU/Hurd. * libguile/filesys.c (scm_init_filesys): Define `O_NOTRANS' when available. --- libguile/filesys.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libguile/filesys.c') diff --git a/libguile/filesys.c b/libguile/filesys.c index ceec87776..5e547a493 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1856,7 +1856,10 @@ scm_init_filesys () #endif #ifdef O_LARGEFILE scm_c_define ("O_LARGEFILE", scm_from_int (O_LARGEFILE)); -#endif +#endif +#ifdef O_NOTRANS + scm_c_define ("O_NOTRANS", scm_from_int (O_NOTRANS)); +#endif #ifdef F_DUPFD scm_c_define ("F_DUPFD", scm_from_int (F_DUPFD)); -- cgit v1.2.3 From 126a32243146d9ad238a3a5adb8d6af5a87ad2aa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 12 Jul 2011 23:57:57 +0200 Subject: Fix `open' mode bits on GNU/Hurd. * libguile/filesys.c (scm_open): Fix check for read-write flags for systems such as GNU/Hurd, where O_RDWR == (O_WRONLY | O_RDONLY) and O_RDONLY != 0. --- libguile/filesys.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'libguile/filesys.c') diff --git a/libguile/filesys.c b/libguile/filesys.c index 5e547a493..f60032818 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -261,8 +261,10 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0, fd = scm_to_int (scm_open_fdes (path, flags, mode)); iflags = SCM_NUM2INT (2, flags); - if (iflags & O_RDWR) + + if ((iflags & O_RDWR) == O_RDWR) { + /* Opened read-write. */ if (iflags & O_APPEND) port_mode = "a+"; else if (iflags & O_CREAT) @@ -270,14 +272,17 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0, else port_mode = "r+"; } - else { - if (iflags & O_APPEND) - port_mode = "a"; - else if (iflags & O_WRONLY) - port_mode = "w"; - else - port_mode = "r"; - } + else + { + /* Opened read-only or write-only. */ + if (iflags & O_APPEND) + port_mode = "a"; + else if (iflags & O_WRONLY) + port_mode = "w"; + else + port_mode = "r"; + } + newpt = scm_fdes_to_port (fd, port_mode, path); return newpt; } -- cgit v1.2.3