diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-11-30 18:43:56 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-11-30 18:52:23 +1100 |
commit | 6bd1a1fe3ec12e177278303e6db0c79b1a14b631 (patch) | |
tree | 18cd0e0f28e71e089962eda1741a12cb4d93d8ce /fcp/src/main.c | |
parent | 1ccd69266b2b71113d17de0d799e0de64aac2fb5 (diff) | |
download | ffs-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/main.c')
-rw-r--r-- | fcp/src/main.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/fcp/src/main.c b/fcp/src/main.c index 335bcf2..00ca3b3 100644 --- a/fcp/src/main.c +++ b/fcp/src/main.c @@ -205,9 +205,7 @@ static void usage(bool verbose) fprintf(e, " -b, --buffer <value>\n"); if (verbose) fprintf(e, - "\n Specifies the buffer size used by --read, --write," - " --copy and --compare\n commands <value> is a " - "decimal (or hex) number, default is buffer size.\n\n"); + "\n Ignored.\n\n"); fprintf(e, "\n"); /* =============================== */ @@ -266,7 +264,7 @@ static int process_argument(args_t * args, int opt, const char *optarg) args->offset = strdup(optarg); break; case o_BUFFER: /* buffer */ - args->buffer = strdup(optarg); + /* We ignore it, it's useless but kept for backwards compat */ break; case f_FORCE: /* force */ args->force = (flag_t) opt; @@ -449,7 +447,6 @@ static int validate_args(args_t * args) return -1; } - UNSUP_OPT(buffer, probe); } else if (args->cmd == c_LIST) { void syntax(void) { fprintf(stderr, "Syntax: %s [<dst_type>:]<dst_target>" @@ -462,7 +459,6 @@ static int validate_args(args_t * args) return -1; } - UNSUP_OPT(buffer, list); } else if (args->cmd == c_READ) { void syntax(void) { fprintf(stderr, "Syntax: %s [<src_type>:]<src_source>" @@ -520,7 +516,6 @@ static int validate_args(args_t * args) REQ_FIELD(dst_name, trunc); - UNSUP_OPT(buffer, trunc); } else if (args->cmd == c_USER) { void syntax(void) { fprintf(stderr, "Syntax: %s [<dst_type>:]<dst_target>" @@ -531,7 +526,6 @@ static int validate_args(args_t * args) REQ_FIELD(dst_name, user); - UNSUP_OPT(buffer, user); } else if (args->cmd == c_COPY) { void syntax(void) { fprintf(stderr, "Syntax: %s [<src_type>:]<src_target>" @@ -614,8 +608,6 @@ static void args_dump(args_t * args) printf("cmd[%c]\n", args->cmd); if (args->offset != NULL) printf("offset[%s]\n", args->offset); - if (args->buffer != NULL) - printf("buffer[%s]\n", args->buffer); if (args->force != 0) printf("force[%c]\n", args->force); if (args->protected != 0) |