From 2c838f7175f297af8d76fe76c5a729e4d8dac4e0 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 26 Nov 2014 16:47:40 +0000 Subject: [PATCH] Equipped all non-system-dependent open(2) calls with O_BINARY --- libisoburn/trunk/test/compare_file.c | 10 +++++++--- libisoburn/trunk/xorriso/check_media.c | 13 +++++++++---- libisoburn/trunk/xorriso/cmp_update.c | 8 ++++++-- libisoburn/trunk/xorriso/disk_ops.c | 11 ++++++++--- libisoburn/trunk/xorriso/read_run.c | 7 ++++++- libisoburn/trunk/xorriso/text_io.c | 15 ++++++++++----- libisoburn/trunk/xorriso/write_run.c | 8 +++++++- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- 8 files changed, 54 insertions(+), 20 deletions(-) diff --git a/libisoburn/trunk/test/compare_file.c b/libisoburn/trunk/test/compare_file.c index d554c4e8..1660c1e0 100644 --- a/libisoburn/trunk/test/compare_file.c +++ b/libisoburn/trunk/test/compare_file.c @@ -5,7 +5,7 @@ To compare tree /media/dvd and /original/dir : find /media/dvd -exec compare_file '{}' /media/dvd /original/dir ';' - Copyright 2008 - 2010 Thomas Schmitt, + Copyright 2008 - 2014 Thomas Schmitt, Provided under GPL version 2 or later. @@ -28,6 +28,10 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif /* @param flag bit0= single letters */ char *Ftypetxt(mode_t st_mode, int flag) @@ -180,12 +184,12 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag) } } if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) { - fd1= open(adr1, O_RDONLY); + fd1= open(adr1, O_RDONLY | O_BINARY); if(fd1==-1) { printf("- %s : cannot open() : %s\n", adr1, strerror(errno)); return(0); } - fd2= open(adr2, O_RDONLY); + fd2= open(adr2, O_RDONLY | O_BINARY); if(fd2==-1) { printf("- %s : cannot open() : %s\n", adr2, strerror(errno)); close(fd1); diff --git a/libisoburn/trunk/xorriso/check_media.c b/libisoburn/trunk/xorriso/check_media.c index b3917732..43216198 100644 --- a/libisoburn/trunk/xorriso/check_media.c +++ b/libisoburn/trunk/xorriso/check_media.c @@ -1,7 +1,7 @@ /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. - Copyright 2007-2013 Thomas Schmitt, + Copyright 2007-2014 Thomas Schmitt, Provided under GPL version 2 or later. @@ -25,6 +25,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #include "xorriso.h" #include "xorriso_private.h" #include "xorrisoburn.h" @@ -293,7 +298,7 @@ int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg, *os_errno= 0; if(msg != NULL) msg[0]= 0; - fd= open(path, O_RDONLY); + fd= open(path, O_RDONLY | O_BINARY); if(fd == -1) { *os_errno= errno; if(msg != NULL) { @@ -373,7 +378,7 @@ int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info, unsigned char buf[40]; *os_errno= 0; - fd= open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); + fd= open(path, O_WRONLY | O_CREAT | O_BINARY, S_IRUSR | S_IWUSR); if(fd == -1) { *os_errno= errno; if(msg != NULL) { @@ -1074,7 +1079,7 @@ int Xorriso_open_job_data_to(struct XorrisO *xorriso, { if(job->data_to_path[0] == 0) return(2); - job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT, + job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT | O_BINARY, S_IRUSR | S_IWUSR); if(job->data_to_fd == -1) { sprintf(xorriso->info_text, "Cannot open path "); diff --git a/libisoburn/trunk/xorriso/cmp_update.c b/libisoburn/trunk/xorriso/cmp_update.c index fc1a17cb..63fbc4ae 100644 --- a/libisoburn/trunk/xorriso/cmp_update.c +++ b/libisoburn/trunk/xorriso/cmp_update.c @@ -1,7 +1,7 @@ /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. - Copyright 2007-2011 Thomas Schmitt, + Copyright 2007-2014 Thomas Schmitt, Provided under GPL version 2 or later. @@ -27,6 +27,10 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif #include "xorriso.h" #include "xorriso_private.h" @@ -64,7 +68,7 @@ int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr, respt= xorriso->result_line; - fd1= open(disk_adr, O_RDONLY); + fd1= open(disk_adr, O_RDONLY | O_BINARY); if(fd1==-1) { sprintf(respt, "- %s (DISK) : cannot open() : %s\n", disk_adr, strerror(errno)); diff --git a/libisoburn/trunk/xorriso/disk_ops.c b/libisoburn/trunk/xorriso/disk_ops.c index ee7e144d..b68cd4be 100644 --- a/libisoburn/trunk/xorriso/disk_ops.c +++ b/libisoburn/trunk/xorriso/disk_ops.c @@ -1,7 +1,7 @@ /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. - Copyright 2007-2012 Thomas Schmitt, + Copyright 2007-2014 Thomas Schmitt, Provided under GPL version 2 or later. @@ -27,6 +27,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #include "xorriso.h" #include "xorriso_private.h" @@ -2099,7 +2104,7 @@ int Xorriso_concat(struct XorrisO *xorriso, char *mode, char *target, open_mode |= O_TRUNC; } if(fd == -1) { - fd= open(target, O_WRONLY | O_TRUNC | O_CREAT, 0666); + fd= open(target, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666); fd_opened= 1; } } else if(strcmp(mode, "append") == 0) { @@ -2108,7 +2113,7 @@ int Xorriso_concat(struct XorrisO *xorriso, char *mode, char *target, goto ex; target_is_regular= (ret == 2); if(fd == -1) { - fd= open(target, O_WRONLY | O_CREAT, 0666); + fd= open(target, O_WRONLY | O_CREAT | O_BINARY, 0666); fd_opened= 1; if(fd != -1 && target_is_regular) { ret= lseek(fd, (off_t) 0, SEEK_END); diff --git a/libisoburn/trunk/xorriso/read_run.c b/libisoburn/trunk/xorriso/read_run.c index eca0d931..59024328 100644 --- a/libisoburn/trunk/xorriso/read_run.c +++ b/libisoburn/trunk/xorriso/read_run.c @@ -28,6 +28,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #include "lib_mgt.h" #include "drive_mgt.h" @@ -561,7 +566,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, open_flags= O_WRONLY|O_CREAT; if(disk_offset==0 || !(flag&2)) open_flags|= O_EXCL; - write_fd= open(open_path_pt, open_flags, S_IRUSR|S_IWUSR); + write_fd= open(open_path_pt, open_flags | O_BINARY, S_IRUSR | S_IWUSR); l_errno= errno; if(write_fd == -1 && errno == EACCES && (flag & 128)) {ret= 4; goto ex;} diff --git a/libisoburn/trunk/xorriso/text_io.c b/libisoburn/trunk/xorriso/text_io.c index 6eed1751..33caf2a8 100644 --- a/libisoburn/trunk/xorriso/text_io.c +++ b/libisoburn/trunk/xorriso/text_io.c @@ -26,6 +26,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /* for -charset */ #include @@ -4168,7 +4173,7 @@ no_pipe_open: xorriso->use_stdin= 1; if(cmd_pipe_adr[0] && reply_pipe_adr[0]) { - command_pipe[0]= open(cmd_pipe_adr, O_RDONLY); + command_pipe[0]= open(cmd_pipe_adr, O_RDONLY | O_BINARY); if(command_pipe[0] == -1) { sprintf(xorriso->info_text, "-launch_frontend: Failed to open named command pipe %s", @@ -4177,7 +4182,7 @@ no_pipe_open: "FAILURE", 0); ret= 0; goto ex; } - reply_pipe[1]= open(reply_pipe_adr, O_WRONLY | O_APPEND); + reply_pipe[1]= open(reply_pipe_adr, O_WRONLY | O_APPEND | O_BINARY); if(reply_pipe[1] == -1) { sprintf(xorriso->info_text, "-launch_frontend: Failed to open named reply pipe %s", @@ -4215,7 +4220,7 @@ no_dup:; /* Close unused pipe ends */; if(cmd_pipe_adr[0] && reply_pipe_adr[0]) { - command_pipe[1]= open(cmd_pipe_adr, O_WRONLY | O_APPEND); + command_pipe[1]= open(cmd_pipe_adr, O_WRONLY | O_APPEND | O_BINARY); if(command_pipe[1] == -1) { fprintf(stderr, "xorriso: -launch_frontend: Failed to open named command pipe '%s'\n", @@ -4223,7 +4228,7 @@ no_dup:; perror("xorriso: -launch_frontend"); exit(1); } - reply_pipe[0]= open(reply_pipe_adr, O_RDONLY); + reply_pipe[0]= open(reply_pipe_adr, O_RDONLY | O_BINARY); if(reply_pipe[0] == -1) { fprintf(stderr, "xorriso: -launch_frontend: Failed to open named reply pipe '%s'\n", @@ -4267,7 +4272,7 @@ int Xorriso_open_named_pipe(struct XorrisO *xorriso, char fd_names[3][20], { if(mem_fds[i] == -1) return(2); - pipe_fds[i]= open(pipe_paths[i], i == 0 ? O_RDONLY : O_WRONLY); + pipe_fds[i]= open(pipe_paths[i], (i == 0 ? O_RDONLY : O_WRONLY) | O_BINARY); if(pipe_fds[i] == -1) { sprintf(xorriso->info_text, "-named_pipe_loop: Failed to open %s pipe ", fd_names[i]); diff --git a/libisoburn/trunk/xorriso/write_run.c b/libisoburn/trunk/xorriso/write_run.c index 71cfbb16..09e9c202 100644 --- a/libisoburn/trunk/xorriso/write_run.c +++ b/libisoburn/trunk/xorriso/write_run.c @@ -34,6 +34,12 @@ #endif #endif +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + + #ifdef Xorriso_standalonE #ifdef Xorriso_with_libjtE @@ -2025,7 +2031,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address, if(xorriso->fs >= 64) fd= burn_os_open_track_src(track_source, O_RDONLY, 0); else - fd= open(track_source, O_RDONLY); + fd= open(track_source, O_RDONLY | O_BINARY); if(fd>=0) if(fstat(fd,&stbuf)!=-1) if((stbuf.st_mode&S_IFMT)==S_IFREG) diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index 8422c8db..673765a7 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2014.11.26.134709" +#define Xorriso_timestamP "2014.11.26.164605"