X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fpython%2Fyaffs_error_converter.c;fp=direct%2Fpython%2Fyaffs_error_converter.c;h=5d9247a43a063753a310304a1eebdf94b6e666ee;hp=0000000000000000000000000000000000000000;hb=059630308f8d017ffe4b42d0e08d6ad4e7affeb1;hpb=baabf1227755653121fcd9e6139636ff9245e2c4 diff --git a/direct/python/yaffs_error_converter.c b/direct/python/yaffs_error_converter.c new file mode 100644 index 0000000..5d9247a --- /dev/null +++ b/direct/python/yaffs_error_converter.c @@ -0,0 +1,54 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "yaffs_error_converter.h" + +typedef struct error_codes_template { + int code; + char * text; +}error_entry; + +const error_entry error_list[] = { + { ENOMEM , "ENOMEM" }, + { EBUSY , "EBUSY"}, + { ENODEV , "ENODEV"}, + { EINVAL , "EINVAL"}, + { EBADF , "EBADF"}, + { EACCES , "EACCES"}, + { EXDEV , "EXDEV" }, + { ENOENT , "ENOENT"}, + { ENOSPC , "ENOSPC"}, + { ERANGE , "ERANGE"}, + { ENODATA, "ENODATA"}, + { ENOTEMPTY, "ENOTEMPTY"}, + { ENAMETOOLONG,"ENAMETOOLONG"}, + { ENOMEM , "ENOMEM"}, + { EEXIST , "EEXIST"}, + { ENOTDIR , "ENOTDIR"}, + { EISDIR , "EISDIR"}, + { 0, NULL } +}; + +const char * yaffs_error_to_str(int err) +{ + error_entry *e = error_list; + if (err < 0) + err = -err; + while(e->code && e->text){ + if(err == e->code) + return e->text; + e++; + } + return "Unknown error code"; +} +