1.1 --- a/librazor/razor.c Mon Jan 12 16:37:55 2009 +0000
1.2 +++ b/librazor/razor.c Mon Jan 12 17:54:13 2009 +0000
1.3 @@ -39,6 +39,10 @@
1.4 #include "razor-internal.h"
1.5 #include "razor.h"
1.6
1.7 +#ifndef O_BINARY
1.8 +#define O_BINARY 0
1.9 +#endif
1.10 +
1.11 void *
1.12 zalloc(size_t size)
1.13 {
1.14 @@ -283,7 +287,7 @@
1.15 {
1.16 int fd, status;
1.17
1.18 - fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
1.19 + fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
1.20 if (fd < 0)
1.21 return -1;
1.22
2.1 --- a/librazor/root.c Mon Jan 12 16:37:55 2009 +0000
2.2 +++ b/librazor/root.c Mon Jan 12 17:54:13 2009 +0000
2.3 @@ -37,6 +37,10 @@
2.4 #include "razor.h"
2.5 #include "razor-internal.h"
2.6
2.7 +#ifndef O_BINARY
2.8 +#define O_BINARY 0
2.9 +#endif
2.10 +
2.11 static const char system_repo_filename[] = "system.rzdb";
2.12 static const char system_repo_details_filename[] = "system-details.rzdb";
2.13 static const char system_repo_files_filename[] = "system-files.rzdb";
2.14 @@ -149,7 +153,8 @@
2.15 snprintf(image->new_path, sizeof image->new_path,
2.16 "%s%s/%s", root, razor_root_path, next_repo_filename);
2.17 image->fd = open(image->new_path,
2.18 - O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0666);
2.19 + O_CREAT | O_WRONLY | O_TRUNC | O_EXCL | O_BINARY,
2.20 + 0666);
2.21 if (image->fd < 0) {
2.22 fprintf(stderr, "failed to get lock file, "
2.23 "maybe previous operation crashed?\n");
3.1 --- a/librazor/rpm.c Mon Jan 12 16:37:55 2009 +0000
3.2 +++ b/librazor/rpm.c Mon Jan 12 17:54:13 2009 +0000
3.3 @@ -44,6 +44,10 @@
3.4 #include "razor.h"
3.5 #include "razor-internal.h"
3.6
3.7 +#ifndef O_BINARY
3.8 +#define O_BINARY 0
3.9 +#endif
3.10 +
3.11 #define RPM_LEAD_SIZE 96
3.12
3.13 enum {
3.14 @@ -509,7 +513,8 @@
3.15 switch (mode >> 12) {
3.16 case REG:
3.17 /* FIXME: handle the case where a file is already there. */
3.18 - fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, mode & 0x1ff);
3.19 + fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
3.20 + mode & 0x1ff);
3.21 if (fd < 0){
3.22 fprintf(stderr, "failed to create file %s\n", buffer);
3.23 return -1;
4.1 --- a/src/main.c Mon Jan 12 16:37:55 2009 +0000
4.2 +++ b/src/main.c Mon Jan 12 17:54:13 2009 +0000
4.3 @@ -373,7 +373,7 @@
4.4 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, file);
4.5
4.6 if (stat(file, &buf) < 0) {
4.7 - fp = fopen(file, "w");
4.8 + fp = fopen(file, "wb");
4.9 if (fp == NULL) {
4.10 fprintf(stderr,
4.11 "failed to open %s for writing\n", file);