~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/bpf/libbpf_errno.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/lib/bpf/libbpf_errno.c (Architecture m68k) and /tools/lib/bpf/libbpf_errno.c (Architecture ppc)


  1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2      1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
  2                                                     2 
  3 /*                                                  3 /*
  4  * Copyright (C) 2013-2015 Alexei Starovoitov       4  * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
  5  * Copyright (C) 2015 Wang Nan <wangnan0@huawe      5  * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
  6  * Copyright (C) 2015 Huawei Inc.                   6  * Copyright (C) 2015 Huawei Inc.
  7  * Copyright (C) 2017 Nicira, Inc.                  7  * Copyright (C) 2017 Nicira, Inc.
  8  */                                                 8  */
  9                                                     9 
 10 #undef _GNU_SOURCE                                 10 #undef _GNU_SOURCE
 11 #include <stdio.h>                                 11 #include <stdio.h>
 12 #include <string.h>                                12 #include <string.h>
 13                                                    13 
 14 #include "libbpf.h"                                14 #include "libbpf.h"
 15 #include "libbpf_internal.h"                       15 #include "libbpf_internal.h"
 16                                                    16 
 17 /* make sure libbpf doesn't use kernel-only in     17 /* make sure libbpf doesn't use kernel-only integer typedefs */
 18 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s     18 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
 19                                                    19 
 20 #define ERRNO_OFFSET(e)         ((e) - __LIBBP     20 #define ERRNO_OFFSET(e)         ((e) - __LIBBPF_ERRNO__START)
 21 #define ERRCODE_OFFSET(c)       ERRNO_OFFSET(L     21 #define ERRCODE_OFFSET(c)       ERRNO_OFFSET(LIBBPF_ERRNO__##c)
 22 #define NR_ERRNO        (__LIBBPF_ERRNO__END -     22 #define NR_ERRNO        (__LIBBPF_ERRNO__END - __LIBBPF_ERRNO__START)
 23                                                    23 
 24 static const char *libbpf_strerror_table[NR_ER     24 static const char *libbpf_strerror_table[NR_ERRNO] = {
 25         [ERRCODE_OFFSET(LIBELF)]        = "Som     25         [ERRCODE_OFFSET(LIBELF)]        = "Something wrong in libelf",
 26         [ERRCODE_OFFSET(FORMAT)]        = "BPF     26         [ERRCODE_OFFSET(FORMAT)]        = "BPF object format invalid",
 27         [ERRCODE_OFFSET(KVERSION)]      = "'ve     27         [ERRCODE_OFFSET(KVERSION)]      = "'version' section incorrect or lost",
 28         [ERRCODE_OFFSET(ENDIAN)]        = "End     28         [ERRCODE_OFFSET(ENDIAN)]        = "Endian mismatch",
 29         [ERRCODE_OFFSET(INTERNAL)]      = "Int     29         [ERRCODE_OFFSET(INTERNAL)]      = "Internal error in libbpf",
 30         [ERRCODE_OFFSET(RELOC)]         = "Rel     30         [ERRCODE_OFFSET(RELOC)]         = "Relocation failed",
 31         [ERRCODE_OFFSET(VERIFY)]        = "Ker     31         [ERRCODE_OFFSET(VERIFY)]        = "Kernel verifier blocks program loading",
 32         [ERRCODE_OFFSET(PROG2BIG)]      = "Pro     32         [ERRCODE_OFFSET(PROG2BIG)]      = "Program too big",
 33         [ERRCODE_OFFSET(KVER)]          = "Inc     33         [ERRCODE_OFFSET(KVER)]          = "Incorrect kernel version",
 34         [ERRCODE_OFFSET(PROGTYPE)]      = "Ker     34         [ERRCODE_OFFSET(PROGTYPE)]      = "Kernel doesn't support this program type",
 35         [ERRCODE_OFFSET(WRNGPID)]       = "Wro     35         [ERRCODE_OFFSET(WRNGPID)]       = "Wrong pid in netlink message",
 36         [ERRCODE_OFFSET(INVSEQ)]        = "Inv     36         [ERRCODE_OFFSET(INVSEQ)]        = "Invalid netlink sequence",
 37         [ERRCODE_OFFSET(NLPARSE)]       = "Inc     37         [ERRCODE_OFFSET(NLPARSE)]       = "Incorrect netlink message parsing",
 38 };                                                 38 };
 39                                                    39 
 40 int libbpf_strerror(int err, char *buf, size_t     40 int libbpf_strerror(int err, char *buf, size_t size)
 41 {                                                  41 {
 42         int ret;                                   42         int ret;
 43                                                    43 
 44         if (!buf || !size)                         44         if (!buf || !size)
 45                 return libbpf_err(-EINVAL);        45                 return libbpf_err(-EINVAL);
 46                                                    46 
 47         err = err > 0 ? err : -err;                47         err = err > 0 ? err : -err;
 48                                                    48 
 49         if (err < __LIBBPF_ERRNO__START) {         49         if (err < __LIBBPF_ERRNO__START) {
 50                 ret = strerror_r(err, buf, siz     50                 ret = strerror_r(err, buf, size);
 51                 buf[size - 1] = '\0';              51                 buf[size - 1] = '\0';
 52                 return libbpf_err_errno(ret);      52                 return libbpf_err_errno(ret);
 53         }                                          53         }
 54                                                    54 
 55         if (err < __LIBBPF_ERRNO__END) {           55         if (err < __LIBBPF_ERRNO__END) {
 56                 const char *msg;                   56                 const char *msg;
 57                                                    57 
 58                 msg = libbpf_strerror_table[ER     58                 msg = libbpf_strerror_table[ERRNO_OFFSET(err)];
 59                 ret = snprintf(buf, size, "%s"     59                 ret = snprintf(buf, size, "%s", msg);
 60                 buf[size - 1] = '\0';              60                 buf[size - 1] = '\0';
 61                 /* The length of the buf and m     61                 /* The length of the buf and msg is positive.
 62                  * A negative number may be re     62                  * A negative number may be returned only when the
 63                  * size exceeds INT_MAX. Not l     63                  * size exceeds INT_MAX. Not likely to appear.
 64                  */                                64                  */
 65                 if (ret >= size)                   65                 if (ret >= size)
 66                         return libbpf_err(-ERA     66                         return libbpf_err(-ERANGE);
 67                 return 0;                          67                 return 0;
 68         }                                          68         }
 69                                                    69 
 70         ret = snprintf(buf, size, "Unknown lib     70         ret = snprintf(buf, size, "Unknown libbpf error %d", err);
 71         buf[size - 1] = '\0';                      71         buf[size - 1] = '\0';
 72         if (ret >= size)                           72         if (ret >= size)
 73                 return libbpf_err(-ERANGE);        73                 return libbpf_err(-ERANGE);
 74         return libbpf_err(-ENOENT);                74         return libbpf_err(-ENOENT);
 75 }                                                  75 }
 76                                                    76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php