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