summaryrefslogtreecommitdiffstats
path: root/fcp/src/misc.c
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 18:43:56 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 18:52:23 +1100
commit6bd1a1fe3ec12e177278303e6db0c79b1a14b631 (patch)
tree18cd0e0f28e71e089962eda1741a12cb4d93d8ce /fcp/src/misc.c
parent1ccd69266b2b71113d17de0d799e0de64aac2fb5 (diff)
downloadffs-6bd1a1fe3ec12e177278303e6db0c79b1a14b631.tar.gz
ffs-6bd1a1fe3ec12e177278303e6db0c79b1a14b631.zip
fix high memory usage during any operation with '--buffer'
The --buffer command line option was passed to setvbuf(3). Computers are fast enough and libc is good enough that we realistically do not need this. Hostboot's buildpnor.pl would pass --buffer 0x40000000 which resulted in a malloc(2GB), which would fail on systems with less than 2GB of memory because sometimes libc and the kernel are sane. So, we keep the command line option for backwards compatibility but completely ignore it. In the few places where it was used to allocate a buffer to do work in (and this was via a rather round-about way), we instead just allocate something the size of the PNOR image. Fixes: https://github.com/open-power/ffs/issues/7 Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'fcp/src/misc.c')
-rw-r--r--fcp/src/misc.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/fcp/src/misc.c b/fcp/src/misc.c
index 004db7d..519ea1d 100644
--- a/fcp/src/misc.c
+++ b/fcp/src/misc.c
@@ -551,11 +551,11 @@ int fcp_read_entry(ffs_t * src, const char * name, FILE * out)
if (__ffs_info(src, FFS_INFO_BLOCK_SIZE, &block_size) < 0)
return -1;
- uint32_t buffer_count;
- if (__ffs_info(src, FFS_INFO_BUFFER_COUNT, &buffer_count) < 0)
+ uint32_t block_count;
+ if (__ffs_info(src, FFS_INFO_BLOCK_COUNT, &block_count) < 0)
return -1;
- size_t buffer_size = block_size * buffer_count;
+ size_t buffer_size = block_size * block_count;
RAII(void*, buffer, malloc(buffer_size), free);
if (buffer == NULL) {
ERRNO(errno);
@@ -621,11 +621,11 @@ int fcp_write_entry(ffs_t * dst, const char * name, FILE * in)
if (__ffs_info(dst, FFS_INFO_BLOCK_SIZE, &block_size) < 0)
return -1;
- uint32_t buffer_count;
- if (__ffs_info(dst, FFS_INFO_BUFFER_COUNT, &buffer_count) < 0)
+ uint32_t block_count;
+ if (__ffs_info(dst, FFS_INFO_BLOCK_COUNT, &block_count) < 0)
return -1;
- size_t buffer_size = block_size * buffer_count;
+ size_t buffer_size = block_size * block_count;
RAII(void*, buffer, malloc(buffer_size), free);
if (buffer == NULL) {
ERRNO(errno);
@@ -697,11 +697,11 @@ int fcp_erase_entry(ffs_t * dst, const char * name, char fill)
if (__ffs_info(dst, FFS_INFO_BLOCK_SIZE, &block_size) < 0)
return -1;
- uint32_t buffer_count;
- if (__ffs_info(dst, FFS_INFO_BUFFER_COUNT, &buffer_count) < 0)
+ uint32_t block_count;
+ if (__ffs_info(dst, FFS_INFO_BLOCK_COUNT, &block_count) < 0)
return -1;
- size_t buffer_size = block_size * buffer_count;
+ size_t buffer_size = block_size * block_count;
RAII(void*, buffer, malloc(buffer_size), free);
if (buffer == NULL) {
ERRNO(errno);
@@ -774,11 +774,11 @@ int fcp_copy_entry(ffs_t * src, const char * src_name,
if (__ffs_info(src, FFS_INFO_BLOCK_SIZE, &block_size) < 0)
return -1;
- uint32_t buffer_count;
- if (__ffs_info(dst, FFS_INFO_BUFFER_COUNT, &buffer_count) < 0)
+ uint32_t block_count;
+ if (__ffs_info(dst, FFS_INFO_BLOCK_COUNT, &block_count) < 0)
return -1;
- size_t buffer_size = block_size * buffer_count;
+ size_t buffer_size = block_size * block_count;
RAII(void*, buffer, malloc(buffer_size), free);
if (buffer == NULL) {
ERRNO(errno);
@@ -851,11 +851,11 @@ int fcp_compare_entry(ffs_t * src, const char * src_name,
if (__ffs_info(src, FFS_INFO_BLOCK_SIZE, &block_size) < 0)
return -1;
- uint32_t buffer_count;
- if (__ffs_info(dst, FFS_INFO_BUFFER_COUNT, &buffer_count) < 0)
+ uint32_t block_count;
+ if (__ffs_info(dst, FFS_INFO_BLOCK_COUNT, &block_count) < 0)
return -1;
- size_t buffer_size = block_size * buffer_count;
+ size_t buffer_size = block_size * block_count;
RAII(void*, src_buffer, malloc(buffer_size), free);
if (src_buffer == NULL) {
OpenPOWER on IntegriCloud