1*433d6423SLionel Sambuc /* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
2*433d6423SLionel Sambuc
3*433d6423SLionel Sambuc #include "inc.h"
4*433d6423SLionel Sambuc
5*433d6423SLionel Sambuc /* Not sure if all of these occur in the HGFS v1 protocol, but at least some
6*433d6423SLionel Sambuc * that weren't in the original protocol, are being returned now.
7*433d6423SLionel Sambuc */
8*433d6423SLionel Sambuc #define NERRS 16
9*433d6423SLionel Sambuc static int error_map[NERRS] = {
10*433d6423SLionel Sambuc OK, /* no error */
11*433d6423SLionel Sambuc ENOENT, /* no such file/directory */
12*433d6423SLionel Sambuc EBADF, /* invalid handle */
13*433d6423SLionel Sambuc EPERM, /* operation not permitted */
14*433d6423SLionel Sambuc EEXIST, /* file already exists */
15*433d6423SLionel Sambuc ENOTDIR, /* not a directory */
16*433d6423SLionel Sambuc ENOTEMPTY, /* directory not empty */
17*433d6423SLionel Sambuc EIO, /* protocol error */
18*433d6423SLionel Sambuc EACCES, /* access denied */
19*433d6423SLionel Sambuc EINVAL, /* invalid name */
20*433d6423SLionel Sambuc EIO, /* generic error */
21*433d6423SLionel Sambuc EIO, /* sharing violation */
22*433d6423SLionel Sambuc ENOSPC, /* no space */
23*433d6423SLionel Sambuc ENOSYS, /* operation not supported */
24*433d6423SLionel Sambuc ENAMETOOLONG, /* name too long */
25*433d6423SLionel Sambuc EINVAL, /* invalid parameter */
26*433d6423SLionel Sambuc };
27*433d6423SLionel Sambuc
28*433d6423SLionel Sambuc /*===========================================================================*
29*433d6423SLionel Sambuc * error_convert *
30*433d6423SLionel Sambuc *===========================================================================*/
error_convert(int err)31*433d6423SLionel Sambuc int error_convert(int err)
32*433d6423SLionel Sambuc {
33*433d6423SLionel Sambuc /* Convert a HGFS error into an errno error code.
34*433d6423SLionel Sambuc */
35*433d6423SLionel Sambuc
36*433d6423SLionel Sambuc if (err < 0 || err >= NERRS) return EIO;
37*433d6423SLionel Sambuc
38*433d6423SLionel Sambuc return error_map[err];
39*433d6423SLionel Sambuc }
40