yaffs_error.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * YAFFS: Yet another FFS. A NAND-flash specific file system.
  3. *
  4. * Copyright (C) 2002-2011 Aleph One Ltd.
  5. * for Toby Churchill Ltd and Brightstar Engineering
  6. *
  7. * Created by Timothy Manning <timothy@yaffs.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include "yaffsfs.h"
  14. struct error_entry {
  15. int code;
  16. const char *text;
  17. };
  18. static const struct error_entry error_list[] = {
  19. { ENOMEM , "ENOMEM" },
  20. { EBUSY , "EBUSY"},
  21. { ENODEV , "ENODEV"},
  22. { EINVAL , "EINVAL"},
  23. { EBADF , "EBADF"},
  24. { EACCES , "EACCES"},
  25. { EXDEV , "EXDEV" },
  26. { ENOENT , "ENOENT"},
  27. { ENOSPC , "ENOSPC"},
  28. { ERANGE , "ERANGE"},
  29. { ENODATA, "ENODATA"},
  30. { ENOTEMPTY, "ENOTEMPTY"},
  31. { ENAMETOOLONG, "ENAMETOOLONG"},
  32. { ENOMEM , "ENOMEM"},
  33. { EEXIST , "EEXIST"},
  34. { ENOTDIR , "ENOTDIR"},
  35. { EISDIR , "EISDIR"},
  36. { ENFILE, "ENFILE"},
  37. { EROFS, "EROFS"},
  38. { EFAULT, "EFAULT"},
  39. { 0, NULL }
  40. };
  41. const char *yaffs_error_to_str(int err)
  42. {
  43. const struct error_entry *e = error_list;
  44. if (err < 0)
  45. err = -err;
  46. while (e->code && e->text) {
  47. if (err == e->code)
  48. return e->text;
  49. e++;
  50. }
  51. return "Unknown error code";
  52. }