aboutsummaryrefslogtreecommitdiff
path: root/lib/common/perror.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
commit1fad07ce86fc2a506c59501d7fb7c7d7481525f6 (patch)
tree6ba41c514e2ddc692cb95a0fb2070dd222897c7c /lib/common/perror.c
parent5597dca9c6053cd19104e18d88edb199b32e3743 (diff)
Rename libsqfshelper to libcommon
That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common/perror.c')
-rw-r--r--lib/common/perror.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/common/perror.c b/lib/common/perror.c
new file mode 100644
index 0000000..9b9f041
--- /dev/null
+++ b/lib/common/perror.c
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * print_version.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "common.h"
+
+#include <stdio.h>
+
+void sqfs_perror(const char *file, const char *action, int error_code)
+{
+ const char *errstr;
+
+ switch (error_code) {
+ case SQFS_ERROR_ALLOC:
+ errstr = "out of memory";
+ break;
+ case SQFS_ERROR_IO:
+ errstr = "I/O error";
+ break;
+ case SQFS_ERROR_COMPRESSOR:
+ errstr = "internal compressor error";
+ break;
+ case SQFS_ERROR_INTERNAL:
+ errstr = "internal error";
+ break;
+ case SQFS_ERROR_CORRUPTED:
+ errstr = "data corrupted";
+ break;
+ case SQFS_ERROR_UNSUPPORTED:
+ errstr = "unknown or not supported";
+ break;
+ case SQFS_ERROR_OVERFLOW:
+ errstr = "numeric overflow";
+ break;
+ case SQFS_ERROR_OUT_OF_BOUNDS:
+ errstr = "location out of bounds";
+ break;
+ case SFQS_ERROR_SUPER_MAGIC:
+ errstr = "wrong magic value in super block";
+ break;
+ case SFQS_ERROR_SUPER_VERSION:
+ errstr = "wrong squashfs version in super block";
+ break;
+ case SQFS_ERROR_SUPER_BLOCK_SIZE:
+ errstr = "invalid block size specified in super block";
+ break;
+ case SQFS_ERROR_NOT_DIR:
+ errstr = "target is not a directory";
+ break;
+ case SQFS_ERROR_NO_ENTRY:
+ errstr = "no such file or directory";
+ break;
+ case SQFS_ERROR_LINK_LOOP:
+ errstr = "hard link loop detected";
+ break;
+ case SQFS_ERROR_NOT_FILE:
+ errstr = "target is not a file";
+ break;
+ default:
+ errstr = "libsquashfs returned an unknown error code";
+ break;
+ }
+
+ fprintf(stderr, "%s: %s: %s.\n", file, action, errstr);
+}