Commit bffdeddd authored by topjohnwu's avatar topjohnwu

Fix fwrite/fread params

parent fd72f658
...@@ -109,7 +109,7 @@ bool cpio::exists(const char *name) { ...@@ -109,7 +109,7 @@ bool cpio::exists(const char *name) {
return entries.count(name) != 0; return entries.count(name) != 0;
} }
#define do_out(buf, len) pos += fwrite(buf, len, 1, out); #define do_out(buf, len) pos += fwrite(buf, 1, len, out);
#define out_align() do_out(zeros, align_off(pos, 4)) #define out_align() do_out(zeros, align_off(pos, 4))
void cpio::dump(FILE *out) { void cpio::dump(FILE *out) {
size_t pos = 0; size_t pos = 0;
...@@ -142,7 +142,7 @@ void cpio::dump(FILE *out) { ...@@ -142,7 +142,7 @@ void cpio::dump(FILE *out) {
} }
// Write trailer // Write trailer
sprintf(header, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", sprintf(header, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
inode++, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 11, 0); inode++, 0755, 0, 0, 1, 0, 0, 0, 0, 0, 0, 11, 0);
do_out(header, 110); do_out(header, 110);
do_out("TRAILER!!!\0", 11); do_out("TRAILER!!!\0", 11);
out_align(); out_align();
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <stdio.h> #include <stdio.h>
#include <memory> #include <memory>
// #include <utils.h>
class stream; class stream;
FILE *open_stream(stream *strm); FILE *open_stream(stream *strm);
......
...@@ -51,11 +51,11 @@ int stream::close() { ...@@ -51,11 +51,11 @@ int stream::close() {
} }
int filter_stream::read(void *buf, size_t len) { int filter_stream::read(void *buf, size_t len) {
return fread(buf, len, 1, fp); return fread(buf, 1, len, fp);
} }
int filter_stream::write(const void *buf, size_t len) { int filter_stream::write(const void *buf, size_t len) {
return fwrite(buf, len, 1, fp); return fwrite(buf, 1, len, fp);
} }
int filter_stream::close() { int filter_stream::close() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment