Fix fwrite/fread params

This commit is contained in:
topjohnwu 2019-11-21 17:43:31 -05:00
parent fd72f658c0
commit bffdedddb4
3 changed files with 4 additions and 6 deletions

View File

@ -109,7 +109,7 @@ bool cpio::exists(const char *name) {
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))
void cpio::dump(FILE *out) {
size_t pos = 0;
@ -142,7 +142,7 @@ void cpio::dump(FILE *out) {
}
// Write trailer
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("TRAILER!!!\0", 11);
out_align();

View File

@ -4,8 +4,6 @@
#include <stdio.h>
#include <memory>
// #include <utils.h>
class stream;
FILE *open_stream(stream *strm);

View File

@ -51,11 +51,11 @@ int stream::close() {
}
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) {
return fwrite(buf, len, 1, fp);
return fwrite(buf, 1, len, fp);
}
int filter_stream::close() {