summaryrefslogtreecommitdiffstats
path: root/common/envfs-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/envfs-core.c')
-rw-r--r--common/envfs-core.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/common/envfs-core.c b/common/envfs-core.c
index 1898c1c8cb..20b3e647d3 100644
--- a/common/envfs-core.c
+++ b/common/envfs-core.c
@@ -12,6 +12,8 @@
* the default environment when building the barebox binary. So
* do not add any new barebox related functions here!
*/
+#define pr_fmt(fmt) "envfs: " fmt
+
#ifdef __BAREBOX__
#include <common.h>
#include <fs.h>
@@ -22,7 +24,8 @@
#include <environment.h>
#include <libfile.h>
#else
-# define errno_str(x) ("void")
+#define pr_info(fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__)
#endif
static int dir_remove_action(const char *filename, struct stat *statbuf,
@@ -39,17 +42,17 @@ static int dir_remove_action(const char *filename, struct stat *statbuf,
int envfs_check_super(struct envfs_super *super, size_t *size)
{
if (ENVFS_32(super->magic) != ENVFS_MAGIC) {
- printf("envfs: no envfs (magic mismatch) - envfs never written?\n");
+ pr_info("no envfs (magic mismatch) - envfs never written?\n");
return -EIO;
}
if (crc32(0, super, sizeof(*super) - 4) != ENVFS_32(super->sb_crc)) {
- printf("wrong crc on env superblock\n");
+ pr_warn("wrong crc on env superblock\n");
return -EIO;
}
if (super->major < ENVFS_MAJOR)
- printf("envfs version %d.%d loaded into %d.%d\n",
+ pr_info("version %d.%d loaded into %d.%d\n",
super->major, super->minor,
ENVFS_MAJOR, ENVFS_MINOR);
@@ -64,7 +67,7 @@ int envfs_check_data(struct envfs_super *super, const void *buf, size_t size)
crc = crc32(0, buf, size);
if (crc != ENVFS_32(super->crc)) {
- printf("wrong crc on env\n");
+ pr_warn("wrong crc on env\n");
return -EIO;
}
@@ -93,7 +96,7 @@ int envfs_load_data(struct envfs_super *super, void *buf, size_t size,
buf += sizeof(struct envfs_inode);
if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) {
- printf("envfs: wrong magic\n");
+ pr_warn("wrong magic\n");
ret = -EIO;
goto out;
}
@@ -147,7 +150,7 @@ int envfs_load_data(struct envfs_super *super, void *buf, size_t size,
fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
free(str);
if (fd < 0) {
- printf("Open %s\n", errno_str());
+ printf("Open %m\n");
ret = fd;
goto out;
}