summaryrefslogtreecommitdiff
path: root/fs/bcachefs/errcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/errcode.c')
-rw-r--r--fs/bcachefs/errcode.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/bcachefs/errcode.c b/fs/bcachefs/errcode.c
index 9da8a5973af0..cc9ce0be356e 100644
--- a/fs/bcachefs/errcode.c
+++ b/fs/bcachefs/errcode.c
@@ -15,7 +15,7 @@ static const char * const bch2_errcode_strs[] = {
#define BCH_ERR_0 0
static unsigned bch2_errcode_parents[] = {
-#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = BCH_ERR_##class,
+#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = class,
BCH_ERRCODES()
#undef x
};
@@ -49,3 +49,14 @@ bool __bch2_err_matches(int err, int class)
return err == class;
}
+
+int __bch2_err_class(int err)
+{
+ err = -err;
+ BUG_ON((unsigned) err >= BCH_ERR_MAX);
+
+ while (err >= BCH_ERR_START && bch2_errcode_parents[err - BCH_ERR_START])
+ err = bch2_errcode_parents[err - BCH_ERR_START];
+
+ return -err;
+}