diff --git a/libisofs/data_source.c b/libisofs/data_source.c index f404250..9abb0e3 100644 --- a/libisofs/data_source.c +++ b/libisofs/data_source.c @@ -21,6 +21,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /** * Private data for File IsoDataSource */ @@ -65,7 +70,7 @@ int ds_open(IsoDataSource *src) return ISO_FILE_ALREADY_OPENED; } - fd = open(data->path, O_RDONLY); + fd = open(data->path, O_RDONLY | O_BINARY); if (fd == -1) { return ISO_FILE_ERROR; } diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 2cc56fe..da40f00 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -30,6 +30,11 @@ #include #include +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + static int iso_file_source_new_lfs(IsoFileSource *parent, const char *name, IsoFileSource **src); @@ -222,7 +227,7 @@ int lfs_open(IsoFileSource *src) data->info.dir = opendir(path); data->openned = data->info.dir ? 2 : 0; } else { - data->info.fd = open(path, O_RDONLY); + data->info.fd = open(path, O_RDONLY | O_BINARY); data->openned = data->info.fd != -1 ? 1 : 0; } free(path); diff --git a/libisofs/system_area.c b/libisofs/system_area.c index bc0d9fe..2c228b3 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -42,6 +42,11 @@ #include #endif +/* O_BINARY is needed for Cygwin but undefined elsewhere */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /* * Create a MBR for an isohybrid enabled ISOLINUX boot image. @@ -2079,7 +2084,7 @@ void iso_random_uuid(Ecma119Image *t, uint8_t uuid[16]) (Weakening the result by 8 bit saves a lot of pool entropy.) */ if ((counter & 0xff) == 0) { - fd = open("/dev/urandom", O_RDONLY); + fd = open("/dev/urandom", O_RDONLY | O_BINARY); if (fd == -1) goto fallback; ret = read(fd, uuid_urandom, 16);