Open slurped files in binary mode, on systems where that matters.
Subsystems (2)
PATCH 1/1 Open slurped files in binary mode, on systems where that matters.
Signed-off-by Jamey Sharp <[email protected]>
---
This patch shouldn't hurt any system that doesn't distinguish between binary and text files, and helps when running on Windows.
kexec/kexec.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
kexec/kexec.c +5 -2
@@ -30,6 +30,9 @@#include <sys/stat.h> #include <unistd.h> #include <fcntl.h> +#ifndef _O_BINARY +#define _O_BINARY 0 +#endif #include <getopt.h> #include "config.h"
@@ -386,7 +389,7 @@ char *slurp_file(const char *filename, off_t *r_size) *r_size =0 ;return 0 ; } - fd =open (filename,O_RDONLY ); + fd =open (filename,O_RDONLY | _O_BINARY);if (fd <0 ) {die ("Cannot open `%s': %s\n" , filename,strerror (errno));
@@ -431,7 +434,7 @@ char *slurp_file_len(const char *filename, off_t size)if (!filename)return 0 ; - fd =open (filename,O_RDONLY ); + fd =open (filename,O_RDONLY | _O_BINARY);if (fd <0 ) {fprintf (stderr,"Cannot open %s: %s\n" , filename,strerror (errno));
Signature · 7 lines
1.5.4.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 4 lines · Jamey Sharp
Signed-off-by Jamey Sharp <[email protected]>---
This patch shouldn't hurt any system that doesn't distinguish between binary and text files, and helps when running on Windows.
Thanks,
I have to confess that I've never had to deal with _O_BINARY myself, but the patch does look correct to me. I have applied it.
Signature · 7 lines
Horms _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec