public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Frank Haverkamp <haver@vnet.ibm.com>
To: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: Josh Boyer <jwboyer@linux.ibm.com>,
	Alexander Schmidt <alexs@linux.vnet.ibm.com>,
	"Monte K. Copeland" <catboat@texas.net>,
	Andreas Arnez <arnez@de.ibm.com>,
	MTD Mailinglist <linux-mtd@lists.infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	haver@vnet.ibm.com
Subject: [PATCH] ubi-utils: Fixup pddcustomize
Date: Fri, 22 Feb 2008 09:47:35 +0100	[thread overview]
Message-ID: <1203670055.8489.4.camel@august> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2658 bytes --]

Subject: ubi-utils: pddcustomize fixup update volume
From: Frank Haverkamp <haver@vnet.ibm.com>

Somehow calling ubi_update_start was forgotten and caused the
tool not to write but silently ignore the write.

Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>
---
 ubi-utils/src/bootenv.c      |    2 +-
 ubi-utils/src/pddcustomize.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

--- mtd-utils.git.orig/ubi-utils/src/bootenv.c
+++ mtd-utils.git/ubi-utils/src/bootenv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) International Business Machines Corp., 2008
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- mtd-utils.git.orig/ubi-utils/src/pddcustomize.c
+++ mtd-utils.git/ubi-utils/src/pddcustomize.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) International Business Machines Corp., 2008
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,7 +46,7 @@
 #include "libubi.h"
 #include "ubimirror.h"
 
-#define PROGRAM_VERSION "1.5"
+#define PROGRAM_VERSION "1.6"
 
 #define DEFAULT_DEV_PATTERN    "/dev/ubi%d"
 #define DEFAULT_VOL_PATTERN    "/dev/ubi%d_%d"
@@ -369,7 +369,7 @@ ubi_write_bootenv(uint32_t devno, uint32
 	int rc = 0;
 	char path[PATH_MAX];
 	FILE* fp_out = NULL;
-	size_t nbytes ;
+	size_t nbytes;
 
 	rc = bootenv_size(env, &nbytes);
 	if (rc) {
@@ -387,6 +387,13 @@ ubi_write_bootenv(uint32_t devno, uint32
 	fp_out = fopen(path, "r+");
 	if (fp_out == NULL) {
 		err_msg("Cannot fopen volume:%d number:%d\n", devno, id);
+		rc = -EBADF;
+		goto err;
+	}
+
+	rc = ubi_update_start(ulib, fileno(fp_out), nbytes);
+	if (rc != 0) {
+		err_msg("Cannot start update for %s\n", path);
 		goto err;
 	}
 
@@ -396,7 +403,6 @@ ubi_write_bootenv(uint32_t devno, uint32
 			devno, id);
 		goto err;
 	}
-
 err:
 	if( fp_out )
 		fclose(fp_out);
@@ -495,6 +501,8 @@ main(int argc, char **argv) {
 		rc = write_bootenv(args.file_in, env);
 	else
 		rc = ubi_write_bootenv(EXAMPLE_UBI_DEVICE, boot_volno, env);
+
+	printf("rc=%d\n", rc);
 	if (rc != 0) {
 		goto err;
 	}

-- 
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032
Boeblingen, Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Herbert Kircher, Sitz der Gesellschaft: Böblingen,
Registergericht: Amtsgericht Stuttgart, HRB 243294

[-- Attachment #1.2: 001-ubi-utils-fixup-pddcustomize.patch --]
[-- Type: text/x-patch, Size: 2685 bytes --]

Subject: ubi-utils: pddcustomize fixup update volume
From: Frank Haverkamp <haver@vnet.ibm.com>

Somehow calling ubi_update_start was forgotten and caused the
tool not to write but silently ignore the write.

Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>
---
 ubi-utils/src/bootenv.c      |    2 +-
 ubi-utils/src/pddcustomize.c |   19 +++++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

--- mtd-utils.git.orig/ubi-utils/src/bootenv.c
+++ mtd-utils.git/ubi-utils/src/bootenv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) International Business Machines Corp., 2008
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- mtd-utils.git.orig/ubi-utils/src/pddcustomize.c
+++ mtd-utils.git/ubi-utils/src/pddcustomize.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) International Business Machines Corp., 2008
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
  * 1.3 Removed argp because we want to use uClibc.
  * 1.4 Minor cleanups
  * 1.5 Migrated to new libubi
+ * 1.6 Fixed broken volume update
  */
 
 #include <stdio.h>
@@ -46,7 +47,7 @@
 #include "libubi.h"
 #include "ubimirror.h"
 
-#define PROGRAM_VERSION "1.5"
+#define PROGRAM_VERSION "1.6"
 
 #define DEFAULT_DEV_PATTERN    "/dev/ubi%d"
 #define DEFAULT_VOL_PATTERN    "/dev/ubi%d_%d"
@@ -369,7 +370,7 @@ ubi_write_bootenv(uint32_t devno, uint32
 	int rc = 0;
 	char path[PATH_MAX];
 	FILE* fp_out = NULL;
-	size_t nbytes ;
+	size_t nbytes;
 
 	rc = bootenv_size(env, &nbytes);
 	if (rc) {
@@ -387,6 +388,13 @@ ubi_write_bootenv(uint32_t devno, uint32
 	fp_out = fopen(path, "r+");
 	if (fp_out == NULL) {
 		err_msg("Cannot fopen volume:%d number:%d\n", devno, id);
+		rc = -EBADF;
+		goto err;
+	}
+
+	rc = ubi_update_start(ulib, fileno(fp_out), nbytes);
+	if (rc != 0) {
+		err_msg("Cannot start update for %s\n", path);
 		goto err;
 	}
 
@@ -396,7 +404,6 @@ ubi_write_bootenv(uint32_t devno, uint32
 			devno, id);
 		goto err;
 	}
-
 err:
 	if( fp_out )
 		fclose(fp_out);
@@ -495,9 +502,9 @@ main(int argc, char **argv) {
 		rc = write_bootenv(args.file_in, env);
 	else
 		rc = ubi_write_bootenv(EXAMPLE_UBI_DEVICE, boot_volno, env);
-	if (rc != 0) {
+	if (rc != 0)
 		goto err;
-	}
+
 	if( args.both )		/* No side specified, update both */
 		rc = do_mirror(boot_volno);
 

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5269 bytes --]

             reply	other threads:[~2008-02-22  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-22  8:47 Frank Haverkamp [this message]
2008-02-22  8:51 ` [PATCH] ubi-utils: Fixup pddcustomize Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1203670055.8489.4.camel@august \
    --to=haver@vnet.ibm.com \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=alexs@linux.vnet.ibm.com \
    --cc=arnez@de.ibm.com \
    --cc=catboat@texas.net \
    --cc=jwboyer@linux.ibm.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox