Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.16-rc6 73 lines 1.5 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2 3#include "bcachefs.h" 4#include "errcode.h" 5#include "trace.h" 6 7#include <linux/errname.h> 8 9static const char * const bch2_errcode_strs[] = { 10#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = #err, 11 BCH_ERRCODES() 12#undef x 13 NULL 14}; 15 16static const unsigned bch2_errcode_parents[] = { 17#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = class, 18 BCH_ERRCODES() 19#undef x 20}; 21 22__attribute__((const)) 23const char *bch2_err_str(int err) 24{ 25 const char *errstr; 26 27 err = abs(err); 28 29 BUG_ON(err >= BCH_ERR_MAX); 30 31 if (err >= BCH_ERR_START) 32 errstr = bch2_errcode_strs[err - BCH_ERR_START]; 33 else if (err) 34 errstr = errname(err); 35 else 36 errstr = "(No error)"; 37 return errstr ?: "(Invalid error)"; 38} 39 40__attribute__((const)) 41bool __bch2_err_matches(int err, int class) 42{ 43 err = abs(err); 44 class = abs(class); 45 46 BUG_ON(err >= BCH_ERR_MAX); 47 BUG_ON(class >= BCH_ERR_MAX); 48 49 while (err >= BCH_ERR_START && err != class) 50 err = bch2_errcode_parents[err - BCH_ERR_START]; 51 52 return err == class; 53} 54 55int __bch2_err_class(int bch_err) 56{ 57 int std_err = -bch_err; 58 BUG_ON((unsigned) std_err >= BCH_ERR_MAX); 59 60 while (std_err >= BCH_ERR_START && bch2_errcode_parents[std_err - BCH_ERR_START]) 61 std_err = bch2_errcode_parents[std_err - BCH_ERR_START]; 62 63 trace_error_downcast(bch_err, std_err, _RET_IP_); 64 65 return -std_err; 66} 67 68const char *bch2_blk_status_to_str(blk_status_t status) 69{ 70 if (status == BLK_STS_REMOVED) 71 return "device removed"; 72 return blk_status_to_str(status); 73}