misc.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. /* Unified AFS error table; ET "uae" == 0x2f6df00 */
  39. case 0x2f6df00: return -EPERM;
  40. case 0x2f6df01: return -ENOENT;
  41. case 0x2f6df04: return -EIO;
  42. case 0x2f6df0a: return -EAGAIN;
  43. case 0x2f6df0b: return -ENOMEM;
  44. case 0x2f6df0c: return -EACCES;
  45. case 0x2f6df0f: return -EBUSY;
  46. case 0x2f6df10: return -EEXIST;
  47. case 0x2f6df11: return -EXDEV;
  48. case 0x2f6df12: return -ENODEV;
  49. case 0x2f6df13: return -ENOTDIR;
  50. case 0x2f6df14: return -EISDIR;
  51. case 0x2f6df15: return -EINVAL;
  52. case 0x2f6df1a: return -EFBIG;
  53. case 0x2f6df1b: return -ENOSPC;
  54. case 0x2f6df1d: return -EROFS;
  55. case 0x2f6df1e: return -EMLINK;
  56. case 0x2f6df20: return -EDOM;
  57. case 0x2f6df21: return -ERANGE;
  58. case 0x2f6df22: return -EDEADLK;
  59. case 0x2f6df23: return -ENAMETOOLONG;
  60. case 0x2f6df24: return -ENOLCK;
  61. case 0x2f6df26: return -ENOTEMPTY;
  62. case 0x2f6df28: return -EWOULDBLOCK;
  63. case 0x2f6df69: return -ENOTCONN;
  64. case 0x2f6df6c: return -ETIMEDOUT;
  65. case 0x2f6df78: return -EDQUOT;
  66. /* RXKAD abort codes; from include/rxrpc/packet.h. ET "RXK" == 0x1260B00 */
  67. case RXKADINCONSISTENCY: return -EPROTO;
  68. case RXKADPACKETSHORT: return -EPROTO;
  69. case RXKADLEVELFAIL: return -EKEYREJECTED;
  70. case RXKADTICKETLEN: return -EKEYREJECTED;
  71. case RXKADOUTOFSEQUENCE: return -EPROTO;
  72. case RXKADNOAUTH: return -EKEYREJECTED;
  73. case RXKADBADKEY: return -EKEYREJECTED;
  74. case RXKADBADTICKET: return -EKEYREJECTED;
  75. case RXKADUNKNOWNKEY: return -EKEYREJECTED;
  76. case RXKADEXPIRED: return -EKEYEXPIRED;
  77. case RXKADSEALEDINCON: return -EKEYREJECTED;
  78. case RXKADDATALEN: return -EKEYREJECTED;
  79. case RXKADILLEGALLEVEL: return -EKEYREJECTED;
  80. case RXGEN_OPCODE: return -ENOTSUPP;
  81. default: return -EREMOTEIO;
  82. }
  83. }