diff mbox

[U-Boot] common, ubi: use positive return values for ubi check

Message ID 1428657943-5522-1-git-send-email-stefan@agner.ch
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Stefan Agner April 10, 2015, 9:25 a.m. UTC
The ubi check command is expected to not fail and just check whether
a volume exist or not. Currently, when a volume does not exist, the
command fails which leads to an error:
"exit not allowed from main input shell."

Use 1 to indicate that a volume does not exist. This allows to use
ubi check in an if statement, e.g.
if ubi check rootfs; then; echo "exists"; else; echo "not there"; fi
---
 common/cmd_ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini April 10, 2015, 6:49 p.m. UTC | #1
On Fri, Apr 10, 2015 at 11:25:43AM +0200, Stefan Agner wrote:

> The ubi check command is expected to not fail and just check whether
> a volume exist or not. Currently, when a volume does not exist, the
> command fails which leads to an error:
> "exit not allowed from main input shell."
> 
> Use 1 to indicate that a volume does not exist. This allows to use
> ubi check in an if statement, e.g.
> if ubi check rootfs; then; echo "exists"; else; echo "not there"; fi

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 6c85703..cbc10c5 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -114,7 +114,7 @@  static int ubi_check(char *name)
 			return 0;
 	}
 
-	return -EEXIST;
+	return 1;
 }