Skip to contentSkip to conversation

Fixes the load command return code under btrfs

PATCH Superseded Stephane Gilbert 2 participants 2 messages Sep 13, 2018 – Sep 26, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixes the load command return code under btrfs

Hi,

I am submitting the following patch to resolve issue below:
When using the load command with a btrfs filesystem, the return code of that command if always success even if the command failed. The problem is the do_load command in fs.c who assume any positive return code from fs_read as success. However the brtfs read function returns positive error code in case of failure. Other fs read fonction like fat and ext4 returns negative error codes on failure. So this patch change the return code of the btrfs read function to be consistent with other read functions. This way it will be possible to use the return code in the Hush shell with btrfs file systems as with other filesystems.

#1 lore raw
Quoted 44 lines · Stephane Gilbert

Hi,

I am submitting the following patch to resolve issue below:
When using the load command with a btrfs filesystem, the return code of that command if always success even if the command failed. The problem is the do_load command in fs.c who assume any positive return code from fs_read as success. However the brtfs read function returns positive error code in case of failure. Other fs read fonction like fat and ext4 returns negative error codes on failure. So this patch change the return code of the btrfs read function to be consistent with other read functions. This way it will be possible to use the return code in the Hush shell with btrfs file systems as with other filesystems.

Quoted 1 line

From 8b8141dbdfc43456b85585e99a2dfa4340800a95 Mon Sep 17 00:00:00 2001

From: Stephane Gilbert <[email protected]>
Date: Thu, 13 Sep 2018 14:47:16 -0400
Subject: [PATCH] Fixes the load command return code under btrfs filesystem

---
 fs/btrfs/btrfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +1 -1
 	if (!len)
@@ -200,7 +200,7 @@ int btrfs_read(const char *file, void *buf, loff_t
 offset, loff_t len,
 	rd = btrfs_file_read(&root, inr, offset, len, buf);
 	if (rd == -1ULL) {
 		printf("An error occured while reading file %s\n",
 file);
-		return 1;
+		return -5;
 	}
(quoted diff) +0 -0
 	*actread = rd;
fs/btrfs/btrfs.c +0 -0
index 6f35854823..64ec1af5a9 100644
@@ -183,12 +183,12 @@ int btrfs_read(const char *file, void *buf,
 loff_t offset, loff_t len,
 
 	if (inr == -1ULL) {
 		printf("Cannot lookup file %s\n", file);

fs/btrfs/btrfs.c int btrfs_read(const char *file, void *buf, · line 194

Quoted 10 lines
fs/btrfs/btrfs.c +2 -2
-		return 1;
+		return -2;
 	}
 
 	if (type != BTRFS_FT_REG_FILE) {
 		printf("Not a regular file: %s\n", file);
-		return 1;
+		return -2;
 	}
 

Your patch itself seems to have been garbled, please resubmit as v2, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180925/ee6ac2c7/attachment.sig>