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

TOMOYO Linux Cross Reference
Linux/fs/nfs_common/common.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 
  3 #include <linux/module.h>
  4 #include <linux/nfs_common.h>
  5 #include <linux/nfs4.h>
  6 
  7 /*
  8  * We need to translate between nfs status return values and
  9  * the local errno values which may not be the same.
 10  */
 11 static const struct {
 12         int stat;
 13         int errno;
 14 } nfs_errtbl[] = {
 15         { NFS_OK,               0               },
 16         { NFSERR_PERM,          -EPERM          },
 17         { NFSERR_NOENT,         -ENOENT         },
 18         { NFSERR_IO,            -errno_NFSERR_IO},
 19         { NFSERR_NXIO,          -ENXIO          },
 20 /*      { NFSERR_EAGAIN,        -EAGAIN         }, */
 21         { NFSERR_ACCES,         -EACCES         },
 22         { NFSERR_EXIST,         -EEXIST         },
 23         { NFSERR_XDEV,          -EXDEV          },
 24         { NFSERR_NODEV,         -ENODEV         },
 25         { NFSERR_NOTDIR,        -ENOTDIR        },
 26         { NFSERR_ISDIR,         -EISDIR         },
 27         { NFSERR_INVAL,         -EINVAL         },
 28         { NFSERR_FBIG,          -EFBIG          },
 29         { NFSERR_NOSPC,         -ENOSPC         },
 30         { NFSERR_ROFS,          -EROFS          },
 31         { NFSERR_MLINK,         -EMLINK         },
 32         { NFSERR_NAMETOOLONG,   -ENAMETOOLONG   },
 33         { NFSERR_NOTEMPTY,      -ENOTEMPTY      },
 34         { NFSERR_DQUOT,         -EDQUOT         },
 35         { NFSERR_STALE,         -ESTALE         },
 36         { NFSERR_REMOTE,        -EREMOTE        },
 37 #ifdef EWFLUSH
 38         { NFSERR_WFLUSH,        -EWFLUSH        },
 39 #endif
 40         { NFSERR_BADHANDLE,     -EBADHANDLE     },
 41         { NFSERR_NOT_SYNC,      -ENOTSYNC       },
 42         { NFSERR_BAD_COOKIE,    -EBADCOOKIE     },
 43         { NFSERR_NOTSUPP,       -ENOTSUPP       },
 44         { NFSERR_TOOSMALL,      -ETOOSMALL      },
 45         { NFSERR_SERVERFAULT,   -EREMOTEIO      },
 46         { NFSERR_BADTYPE,       -EBADTYPE       },
 47         { NFSERR_JUKEBOX,       -EJUKEBOX       },
 48         { -1,                   -EIO            }
 49 };
 50 
 51 /**
 52  * nfs_stat_to_errno - convert an NFS status code to a local errno
 53  * @status: NFS status code to convert
 54  *
 55  * Returns a local errno value, or -EIO if the NFS status code is
 56  * not recognized.  This function is used jointly by NFSv2 and NFSv3.
 57  */
 58 int nfs_stat_to_errno(enum nfs_stat status)
 59 {
 60         int i;
 61 
 62         for (i = 0; nfs_errtbl[i].stat != -1; i++) {
 63                 if (nfs_errtbl[i].stat == (int)status)
 64                         return nfs_errtbl[i].errno;
 65         }
 66         return nfs_errtbl[i].errno;
 67 }
 68 EXPORT_SYMBOL_GPL(nfs_stat_to_errno);
 69 
 70 /*
 71  * We need to translate between nfs v4 status return values and
 72  * the local errno values which may not be the same.
 73  */
 74 static const struct {
 75         int stat;
 76         int errno;
 77 } nfs4_errtbl[] = {
 78         { NFS4_OK,              0               },
 79         { NFS4ERR_PERM,         -EPERM          },
 80         { NFS4ERR_NOENT,        -ENOENT         },
 81         { NFS4ERR_IO,           -errno_NFSERR_IO},
 82         { NFS4ERR_NXIO,         -ENXIO          },
 83         { NFS4ERR_ACCESS,       -EACCES         },
 84         { NFS4ERR_EXIST,        -EEXIST         },
 85         { NFS4ERR_XDEV,         -EXDEV          },
 86         { NFS4ERR_NOTDIR,       -ENOTDIR        },
 87         { NFS4ERR_ISDIR,        -EISDIR         },
 88         { NFS4ERR_INVAL,        -EINVAL         },
 89         { NFS4ERR_FBIG,         -EFBIG          },
 90         { NFS4ERR_NOSPC,        -ENOSPC         },
 91         { NFS4ERR_ROFS,         -EROFS          },
 92         { NFS4ERR_MLINK,        -EMLINK         },
 93         { NFS4ERR_NAMETOOLONG,  -ENAMETOOLONG   },
 94         { NFS4ERR_NOTEMPTY,     -ENOTEMPTY      },
 95         { NFS4ERR_DQUOT,        -EDQUOT         },
 96         { NFS4ERR_STALE,        -ESTALE         },
 97         { NFS4ERR_BADHANDLE,    -EBADHANDLE     },
 98         { NFS4ERR_BAD_COOKIE,   -EBADCOOKIE     },
 99         { NFS4ERR_NOTSUPP,      -ENOTSUPP       },
100         { NFS4ERR_TOOSMALL,     -ETOOSMALL      },
101         { NFS4ERR_SERVERFAULT,  -EREMOTEIO      },
102         { NFS4ERR_BADTYPE,      -EBADTYPE       },
103         { NFS4ERR_LOCKED,       -EAGAIN         },
104         { NFS4ERR_SYMLINK,      -ELOOP          },
105         { NFS4ERR_OP_ILLEGAL,   -EOPNOTSUPP     },
106         { NFS4ERR_DEADLOCK,     -EDEADLK        },
107         { NFS4ERR_NOXATTR,      -ENODATA        },
108         { NFS4ERR_XATTR2BIG,    -E2BIG          },
109         { -1,                   -EIO            }
110 };
111 
112 /*
113  * Convert an NFS error code to a local one.
114  * This one is used by NFSv4.
115  */
116 int nfs4_stat_to_errno(int stat)
117 {
118         int i;
119         for (i = 0; nfs4_errtbl[i].stat != -1; i++) {
120                 if (nfs4_errtbl[i].stat == stat)
121                         return nfs4_errtbl[i].errno;
122         }
123         if (stat <= 10000 || stat > 10100) {
124                 /* The server is looney tunes. */
125                 return -EREMOTEIO;
126         }
127         /* If we cannot translate the error, the recovery routines should
128          * handle it.
129          * Note: remaining NFSv4 error codes have values > 10000, so should
130          * not conflict with native Linux error codes.
131          */
132         return -stat;
133 }
134 EXPORT_SYMBOL_GPL(nfs4_stat_to_errno);
135 

~ [ 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