Skip to contentSkip to conversation

ubi-utils: Fixup pddcustomize

PATCH In review Frank Haverkamp 2 participants 2 messages Feb 22, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubi-utils: Fixup pddcustomize

Subject: ubi-utils: pddcustomize fixup update volume
From: Frank Haverkamp <[email protected]>

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

---
 ubi-utils/src/bootenv.c      |    2 +-
 ubi-utils/src/pddcustomize.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
ubi-utils/src/bootenv.c +1 -1
@@ -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
ubi-utils/src/pddcustomize.c +12 -4
@@ -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;
 	}
Signature · 4 lines
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

Subject: ubi-utils: pddcustomize fixup update volume
From: Frank Haverkamp <[email protected]>

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

---
 ubi-utils/src/bootenv.c      |    2 +-
 ubi-utils/src/pddcustomize.c |   19 +++++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)
ubi-utils/src/bootenv.c +1 -1
@@ -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
ubi-utils/src/pddcustomize.c +13 -6
@@ -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);
 
#1 lore raw
Quoted 7 lines · Frank Haverkamp

Subject: ubi-utils: pddcustomize fixup update volume
From: Frank Haverkamp <[email protected]>

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

[dedekind@golum mtd-utils.git]$ git-am haver.eml Applying ubi-utils: pddcustomize fixup update volume .dotest/patch:11: trailing whitespace.
* Copyright (c) International Business Machines Corp., 2008
.dotest/patch:20: trailing whitespace.
* Copyright (c) International Business Machines Corp., 2008
.dotest/patch:28: trailing whitespace.
* 1.6 Fixed broken volume update
.dotest/patch:37: trailing whitespace.
#define PROGRAM_VERSION "1.6"
.dotest/patch:46: trailing whitespace.

        size_t nbytes;

error: patch failed: ubi-utils/src/bootenv.c:1
error: ubi-utils/src/bootenv.c: patch does not apply
error: patch failed: ubi-utils/src/pddcustomize.c:1
error: ubi-utils/src/pddcustomize.c: patch does not apply Patch failed at 0001.
When you have resolved this problem run "git-am --resolved". If you would prefer to skip this patch, instead run "git-am --skip".

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)