misc.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* miscellaneous bits
  2. *
  3. * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/errno.h>
  14. #include "internal.h"
  15. #include "afs_fs.h"
  16. /*
  17. * convert an AFS abort code to a Linux error number
  18. */
  19. int afs_abort_to_error(u32 abort_code)
  20. {
  21. switch (abort_code) {
  22. /* Low errno codes inserted into abort namespace */
  23. case 13: return -EACCES;
  24. case 27: return -EFBIG;
  25. case 30: return -EROFS;
  26. /* VICE "special error" codes; 101 - 111 */
  27. case VSALVAGE: return -EIO;
  28. case VNOVNODE: return -ENOENT;
  29. case VNOVOL: return -ENOMEDIUM;
  30. case VVOLEXISTS: return -EEXIST;
  31. case VNOSERVICE: return -EIO;
  32. case VOFFLINE: return -ENOENT;
  33. case VONLINE: return -EEXIST;
  34. case VDISKFULL: return -ENOSPC;
  35. case VOVERQUOTA: return -EDQUOT;
  36. case VBUSY: return -EBUSY;
  37. case VMOVED: return -ENXIO;
  38. /* Volume Location server errors */
  39. case AFSVL_IDEXIST: return -EEXIST;
  40. case AFSVL_IO: return -EREMOTEIO;
  41. case AFSVL_NAMEEXIST: return -EEXIST;
  42. case AFSVL_CREATEFAIL: return -EREMOTEIO;
  43. case AFSVL_NOENT: return -ENOMEDIUM;
  44. case AFSVL_EMPTY: return -ENOMEDIUM;
  45. case AFSVL_ENTDELETED: return -ENOMEDIUM;
  46. case AFSVL_BADNAME: return -EINVAL;
  47. case AFSVL_BADINDEX: return -EINVAL;
  48. case AFSVL_BADVOLTYPE: return -EINVAL;
  49. case AFSVL_BADSERVER: return -EINVAL;
  50. case AFSVL_BADPARTITION: return -EINVAL;
  51. case AFSVL_REPSFULL: return -EFBIG;
  52. case AFSVL_NOREPSERVER: return -ENOENT;
  53. case AFSVL_DUPREPSERVER: return -EEXIST;
  54. case AFSVL_RWNOTFOUND: return -ENOENT;
  55. case AFSVL_BADREFCOUNT: return -EINVAL;
  56. case AFSVL_SIZEEXCEEDED: return -EINVAL;
  57. case AFSVL_BADENTRY: return -EINVAL;
  58. case AFSVL_BADVOLIDBUMP: return -EINVAL;
  59. case AFSVL_IDALREADYHASHED: return -EINVAL;
  60. case AFSVL_ENTRYLOCKED: return -EBUSY;
  61. case AFSVL_BADVOLOPER: return -EBADRQC;
  62. case AFSVL_BADRELLOCKTYPE: return -EINVAL;
  63. case AFSVL_RERELEASE: return -EREMOTEIO;
  64. case AFSVL_BADSERVERFLAG: return -EINVAL;
  65. case AFSVL_PERM: return -EACCES;
  66. case AFSVL_NOMEM: return -EREMOTEIO;
  67. /* Unified AFS error table; ET "uae" == 0x2f6df00 */
  68. case 0x2f6df00: return -EPERM;
  69. case 0x2f6df01: return -ENOENT;
  70. case 0x2f6df04: return -EIO;
  71. case 0x2f6df0a: return -EAGAIN;
  72. case 0x2f6df0b: return -ENOMEM;
  73. case 0x2f6df0c: return -EACCES;
  74. case 0x2f6df0f: return -EBUSY;
  75. case 0x2f6df10: return -EEXIST;
  76. case 0x2f6df11: return -EXDEV;
  77. case 0x2f6df12: return -ENODEV;
  78. case 0x2f6df13: return -ENOTDIR;
  79. case 0x2f6df14: return -EISDIR;
  80. case 0x2f6df15: return -EINVAL;
  81. case 0x2f6df1a: return -EFBIG;
  82. case 0x2f6df1b: return -ENOSPC;
  83. case 0x2f6df1d: return -EROFS;
  84. case 0x2f6df1e: return -EMLINK;
  85. case 0x2f6df20: return -EDOM;
  86. case 0x2f6df21: return -ERANGE;
  87. case 0x2f6df22: return -EDEADLK;
  88. case 0x2f6df23: return -ENAMETOOLONG;
  89. case 0x2f6df24: return -ENOLCK;
  90. case 0x2f6df26: return -ENOTEMPTY;
  91. case 0x2f6df28: return -EWOULDBLOCK;
  92. case 0x2f6df69: return -ENOTCONN;
  93. case 0x2f6df6c: return -ETIMEDOUT;
  94. case 0x2f6df78: return -EDQUOT;
  95. /* RXKAD abort codes; from include/rxrpc/packet.h. ET "RXK" == 0x1260B00 */
  96. case RXKADINCONSISTENCY: return -EPROTO;
  97. case RXKADPACKETSHORT: return -EPROTO;
  98. case RXKADLEVELFAIL: return -EKEYREJECTED;
  99. case RXKADTICKETLEN: return -EKEYREJECTED;
  100. case RXKADOUTOFSEQUENCE: return -EPROTO;
  101. case RXKADNOAUTH: return -EKEYREJECTED;
  102. case RXKADBADKEY: return -EKEYREJECTED;
  103. case RXKADBADTICKET: return -EKEYREJECTED;
  104. case RXKADUNKNOWNKEY: return -EKEYREJECTED;
  105. case RXKADEXPIRED: return -EKEYEXPIRED;
  106. case RXKADSEALEDINCON: return -EKEYREJECTED;
  107. case RXKADDATALEN: return -EKEYREJECTED;
  108. case RXKADILLEGALLEVEL: return -EKEYREJECTED;
  109. case RXGEN_OPCODE: return -ENOTSUPP;
  110. default: return -EREMOTEIO;
  111. }
  112. }