summaryrefslogtreecommitdiffstats
path: root/tools/patch-image/src/patch-cmdline.c
diff options
context:
space:
mode:
authorVishnu Swaroop Duddu <duddu.swaroop@intel.com>2016-05-12 20:07:29 +0530
committerHauke Mehrtens <hauke@hauke-m.de>2016-06-21 21:58:07 +0200
commitee613097bee89eec370c2118614ac39f65ea1f21 (patch)
treebc3315a7a66f93cad8f2c985e70442b7c32f6b18 /tools/patch-image/src/patch-cmdline.c
parent63cb2fb88d3c4f919a00743b1fdbed1cf977d935 (diff)
downloadmaster-31e0f0ae-ee613097bee89eec370c2118614ac39f65ea1f21.tar.gz
master-31e0f0ae-ee613097bee89eec370c2118614ac39f65ea1f21.tar.bz2
master-31e0f0ae-ee613097bee89eec370c2118614ac39f65ea1f21.zip
tools: patch-image: Added optional size option
Added optional command line option for patch-image tool Default 16KB size is still maintained as this is an optional argument. if one wants to specify or increase size they can provide this option. sample usage: patch-dtb <file> <dtb> [dtb max size] Signed-off-by: Vishnu Swaroop Duddu <duddu.swaroop@intel.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'tools/patch-image/src/patch-cmdline.c')
-rw-r--r--tools/patch-image/src/patch-cmdline.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/patch-image/src/patch-cmdline.c b/tools/patch-image/src/patch-cmdline.c
index d3a5b119e4..8d1fce9172 100644
--- a/tools/patch-image/src/patch-cmdline.c
+++ b/tools/patch-image/src/patch-cmdline.c
@@ -35,10 +35,16 @@ int main(int argc, char **argv)
{
int fd, found = 0, len, ret = -1;
char *ptr, *p;
+ unsigned int search_space;
- if (argc != 3) {
- fprintf(stderr, "Usage: %s <file> <cmdline>\n", argv[0]);
+ if (argc <= 2 || argc > 4) {
+ fprintf(stderr, "Usage: %s <file> <cmdline> [size]\n", argv[0]);
goto err1;
+ } else if (argc == 3) {
+ fprintf(stdout, "search space used is default of 16KB\n");
+ search_space = SEARCH_SPACE;
+ } else {
+ search_space = atoi(argv[3]);
}
len = strlen(argv[2]);
if (len + 9 > CMDLINE_MAX) {
@@ -47,12 +53,12 @@ int main(int argc, char **argv)
}
if (((fd = open(argv[1], O_RDWR)) < 0) ||
- (ptr = (char *) mmap(0, SEARCH_SPACE + CMDLINE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {
+ (ptr = (char *) mmap(0, search_space + CMDLINE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {
fprintf(stderr, "Could not open kernel image");
goto err2;
}
- for (p = ptr; p < (ptr + SEARCH_SPACE); p += 4) {
+ for (p = ptr; p < (ptr + search_space); p += 4) {
if (memcmp(p, "CMDLINE:", 8) == 0) {
found = 1;
p += 8;