diff options
author | Luotao Fu <l.fu@pengutronix.de> | 2010-03-26 13:52:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-05-03 15:01:28 +0200 |
commit | f498576cb62ef8fe9cd39b49d91197b5d8c41fed (patch) | |
tree | f26ea06ffcb229ab39188f1097558aaa5b68e9dc | |
parent | 1d6d5108e56b6b6f2fc72d2b35118f8bf545280d (diff) | |
download | barebox-f498576cb62ef8fe9cd39b49d91197b5d8c41fed.tar.gz barebox-f498576cb62ef8fe9cd39b49d91197b5d8c41fed.tar.xz |
fix error return value while loading environment
Signed-off-by: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/environment.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/environment.c b/common/environment.c index 0c7de84b5f..0eb7e6b6fc 100644 --- a/common/environment.c +++ b/common/environment.c @@ -198,6 +198,7 @@ int envfs_load(char *filename, char *dir) if (crc32(0, (unsigned char *)&super, sizeof(struct envfs_super) - 4) != ENVFS_32(super.sb_crc)) { printf("wrong crc on env superblock\n"); + ret = -EIO; goto out; } @@ -207,18 +208,20 @@ int envfs_load(char *filename, char *dir) ret = read(envfd, buf, size); if (ret < size) { perror("read"); + ret = errno; goto out; } if (crc32(0, (unsigned char *)buf, size) != ENVFS_32(super.crc)) { printf("wrong crc on env\n"); + ret = -EIO; goto out; } while (size) { struct envfs_inode *inode; - uint32_t inode_size,inode_namelen; + uint32_t inode_size, inode_namelen; inode = (struct envfs_inode *)buf; @@ -251,6 +254,7 @@ int envfs_load(char *filename, char *dir) inode_size); if (ret < inode_size) { perror("write"); + ret = errno; close(fd); goto out; } |