diff options
author | Jean Delvare <jdelvare@suse.de> | 2023-02-20 14:53:25 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2023-02-20 14:53:25 +0100 |
commit | d8cfbc808f387e87091c25e7d5b8c2bb348bb206 (patch) | |
tree | 77fcda85146e243cf1163fc2721db685b71e9734 /util.c | |
parent | 39b2dd7b6ab719b920e96ed832cfb4bdd664e808 (diff) | |
download | dmidecode-git-d8cfbc808f387e87091c25e7d5b8c2bb348bb206.tar.gz |
dmidecode: Write the whole dump file at once
When option --dump-bin is used, write the whole dump file at once,
instead of opening and closing the file separately for the table
and then for the entry point.
As the file writing function is no longer generic, it gets moved
from util.c to dmidecode.c.
One minor functional change resulting from the new implementation is
that the entry point is written first now, so the messages printed
are swapped.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 40 |
1 files changed, 0 insertions, 40 deletions
@@ -259,46 +259,6 @@ out: return p; } -int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add) -{ - FILE *f; - - f = fopen(dumpfile, add ? "r+b" : "wb"); - if (!f) - { - fprintf(stderr, "%s: ", dumpfile); - perror("fopen"); - return -1; - } - - if (fseek(f, base, SEEK_SET) != 0) - { - fprintf(stderr, "%s: ", dumpfile); - perror("fseek"); - goto err_close; - } - - if (fwrite(data, len, 1, f) != 1) - { - fprintf(stderr, "%s: ", dumpfile); - perror("fwrite"); - goto err_close; - } - - if (fclose(f)) - { - fprintf(stderr, "%s: ", dumpfile); - perror("fclose"); - return -1; - } - - return 0; - -err_close: - fclose(f); - return -1; -} - /* Returns end - start + 1, assuming start < end */ u64 u64_range(u64 start, u64 end) { |