summaryrefslogtreecommitdiff
path: root/ubi-utils/src/pfiflash.c
diff options
context:
space:
mode:
authorAlexander Schmidt <alexs@linux.vnet.ibm.com>2007-07-10 17:53:54 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-07-10 21:00:43 +0300
commit0d62e6a7338d8f25727f56ca14236954fc8f2cef (patch)
tree767442d91fe044f6671cf618b3f08165f171fef0 /ubi-utils/src/pfiflash.c
parent8496f75b4897056a1423e30a41649dbc11b421d4 (diff)
UBI-utils: add compare feature
This is a new feature for pfiflash, called "--compare". It allows the user to simulate a pfiflash session without actually changing the flash content. If the flash content is equal to the data in the pfif file, pfiflash returns zero. A positive value is returned when the flash content differs from the pfi file, which indicates that an update is necessary. This feature is useful when a controller mounts an NFS share during boot and has to determine if a pfi file stored on this share contains a code update. Modified PDD values are also registered by the compare feature. Signed-off-by: Alexander Schmidt <alexs@linux.vnet.ibm.com>
Diffstat (limited to 'ubi-utils/src/pfiflash.c')
-rw-r--r--ubi-utils/src/pfiflash.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ubi-utils/src/pfiflash.c b/ubi-utils/src/pfiflash.c
index d5b5406..bac62e6 100644
--- a/ubi-utils/src/pfiflash.c
+++ b/ubi-utils/src/pfiflash.c
@@ -63,6 +63,9 @@ static const char *optionsstr =
" 'keep', 'merge' or 'overwrite'.\n"
" -r, --raw-flash=<dev> Flash the raw data. Use the specified mtd device.\n"
" -s, --side=<seqnum> Select the side which shall be updated.\n"
+" -x, --compare Only compare on-flash and pfi data, print info if\n"
+" an update is neccessary and return appropriate\n"
+" error code.\n"
"\n"
" -?, --help Give this help list\n"
" --usage Give a short usage message\n"
@@ -72,7 +75,7 @@ static const char *usage =
"Usage: pfiflash [-cvC?V] [-l <file>] [-p <type>] [-r <dev>] [-s <seqnum>]\n"
" [--copyright] [--logfile=<file>] [--verbose] [--complete]\n"
" [--pdd-update=<type>] [--raw-flash=<dev>] [--side=<seqnum>]\n"
-" [--help] [--usage] [--version] [pfifile]\n";
+" [--compare] [--help] [--usage] [--version] [pfifile]\n";
static const char copyright [] __attribute__((unused)) =
"Copyright IBM Corp 2006";
@@ -85,6 +88,7 @@ struct option long_options[] = {
{ .name = "pdd-update", .has_arg = 1, .flag = NULL, .val = 'p' },
{ .name = "raw-flash", .has_arg = 1, .flag = NULL, .val = 'r' },
{ .name = "side", .has_arg = 1, .flag = NULL, .val = 's' },
+ { .name = "compare", .has_arg = 0, .flag = NULL, .val = 'x' },
{ .name = "help", .has_arg = 0, .flag = NULL, .val = '?' },
{ .name = "usage", .has_arg = 0, .flag = NULL, .val = 0 },
{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
@@ -98,6 +102,7 @@ typedef struct myargs {
pdd_handling_t pdd_handling;
int seqnum;
+ int compare;
int complete;
FILE* fp_in;
@@ -142,7 +147,7 @@ parse_opt(int argc, char **argv, myargs *args)
while (1) {
int key;
- key = getopt_long(argc, argv, "cl:vCp:r:s:?V",
+ key = getopt_long(argc, argv, "cl:vCp:r:s:x?V",
long_options, NULL);
if (key == -1)
break;
@@ -180,6 +185,9 @@ parse_opt(int argc, char **argv, myargs *args)
"and '1'\n", optarg);
}
break;
+ case 'x':
+ args->compare = 1;
+ break;
case 'r':
args->raw_dev = optarg;
break;
@@ -222,6 +230,7 @@ int main (int argc, char** argv)
myargs args = {
.verbose = 0,
.seqnum = -1,
+ .compare = 0,
.complete = 0,
.logfile = NULL, /* "/tmp/pfiflash.log", */
.pdd_handling = PDD_KEEP,
@@ -239,17 +248,10 @@ int main (int argc, char** argv)
goto err;
}
- if (!args.raw_dev) {
- rc = pfiflash(args.fp_in, args.complete, args.seqnum,
- args.pdd_handling, err_buf,
- PFIFLASH_MAX_ERR_BUF_SIZE);
- } else {
- rc = pfiflash_with_raw(args.fp_in, args.complete, args.seqnum,
- args.pdd_handling, args.raw_dev, err_buf,
- PFIFLASH_MAX_ERR_BUF_SIZE);
- }
-
- if (rc != 0) {
+ rc = pfiflash_with_options(args.fp_in, args.complete, args.seqnum,
+ args.compare, args.pdd_handling, args.raw_dev, err_buf,
+ PFIFLASH_MAX_ERR_BUF_SIZE);
+ if (rc < 0) {
goto err_fp;
}