#include "razor-internal.h"
#include "razor.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
void *
zalloc(size_t size)
{
{
int fd, status;
- fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
+ fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
if (fd < 0)
return -1;
#include "razor.h"
#include "razor-internal.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
static const char system_repo_filename[] = "system.rzdb";
static const char system_repo_details_filename[] = "system-details.rzdb";
static const char system_repo_files_filename[] = "system-files.rzdb";
snprintf(image->new_path, sizeof image->new_path,
"%s%s/%s", root, razor_root_path, next_repo_filename);
image->fd = open(image->new_path,
- O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0666);
+ O_CREAT | O_WRONLY | O_TRUNC | O_EXCL | O_BINARY,
+ 0666);
if (image->fd < 0) {
fprintf(stderr, "failed to get lock file, "
"maybe previous operation crashed?\n");
#include "razor.h"
#include "razor-internal.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#define RPM_LEAD_SIZE 96
enum {
switch (mode >> 12) {
case REG:
/* FIXME: handle the case where a file is already there. */
- fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, mode & 0x1ff);
+ fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+ mode & 0x1ff);
if (fd < 0){
fprintf(stderr, "failed to create file %s\n", buffer);
return -1;
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, file);
if (stat(file, &buf) < 0) {
- fp = fopen(file, "w");
+ fp = fopen(file, "wb");
if (fp == NULL) {
fprintf(stderr,
"failed to open %s for writing\n", file);