strerror.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * C++ stream style string formatter and printer used in KUnit for outputting
  4. * KUnit messages.
  5. *
  6. * Copyright (C) 2019, Google LLC.
  7. * Author: Mike Krinkin <[email protected]>
  8. */
  9. #include <linux/types.h>
  10. /**
  11. * strerror() - returns a string representation for the given error code.
  12. * @errno: an error code defined in include/uapi/asm-generic/errno-base.h or
  13. * include/uapi/asm-generic/errno.h
  14. *
  15. * This function returns mnemonic representation of error code (for example,
  16. * EPERM, ENOENT, ESRCH, etc). For unsupported errors this function returns
  17. * NULL.
  18. */
  19. const char *strerror_str(int errno);
  20. /**
  21. * strerror_r() - returns a string representation of the given error code.
  22. * Unlike strerror() it may use provided buffer to store the string, so in
  23. * the case of unknown error it returns a message containing an error code
  24. * instead of returning NULL.
  25. * @errno: an error code defined in include/uapi/asm-generic/errno-base.h or
  26. * include/uapi/asm-generic/errno.h
  27. * @buf: pointer to a buffer that could be used to store the string.
  28. * @buflen: contains the capacity of the buffer
  29. *
  30. * When function uses provided buffer and it's capacity is not enough to
  31. * store the whole string the string is truncated and always contains '\0'.
  32. * If buflen == 0, the function returns NULL pointer as there is not enough
  33. * space to store even '\0'.
  34. */
  35. const char *strerror_r(int errno, char *buf, size_t buflen);