e9a80703c31b788fd3030e95bbda20766ac8724a
[yaffs2.git] / direct / python / yaffs_error_converter.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include "yaffs_error_converter.h"
15
16 typedef struct error_codes_template {
17   int code;
18   char * text;  
19 }error_entry;
20
21 const error_entry error_list[] = {
22         { ENOMEM , "ENOMEM" },
23         { EBUSY , "EBUSY"},
24         { ENODEV , "ENODEV"},
25         { EINVAL , "EINVAL"},
26         { EBADF , "EBADF"},
27         { EACCES , "EACCES"},
28         { EXDEV , "EXDEV" },
29         { ENOENT , "ENOENT"},
30         { ENOSPC , "ENOSPC"},
31         { ERANGE , "ERANGE"},
32         { ENODATA, "ENODATA"},
33         { ENOTEMPTY, "ENOTEMPTY"},
34         { ENAMETOOLONG,"ENAMETOOLONG"},
35         { ENOMEM , "ENOMEM"},
36         { EEXIST , "EEXIST"},
37         { ENOTDIR , "ENOTDIR"},
38         { EISDIR , "EISDIR"},
39         { ENFILE, "ENFILE"},
40         { 0, NULL }
41 };
42
43 const char * yaffs_error_to_str(int err)
44 {
45         error_entry *e = error_list;
46         if (err < 0) 
47                 err = -err;
48         while(e->code && e->text){
49                 if(err == e->code)
50                         return e->text;
51                 e++;
52         }
53         return "Unknown error code";
54 }
55