Update timothy test Makefile
[yaffs2.git] / direct / yaffs_error.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 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 "yaffsfs.h"
15
16 struct error_entry {
17   int code;
18   char * text;  
19 };
20
21 static const struct 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         { EROFS, "EROFS"},
41         { EFAULT, "EFAULT"},
42         { 0, NULL }
43 };
44
45 const char * yaffs_error_to_str(int err)
46 {
47         const struct error_entry *e = error_list;
48
49         if (err < 0) 
50                 err = -err;
51
52         while(e->code && e->text){
53                 if(err == e->code)
54                         return e->text;
55                 e++;
56         }
57         return "Unknown error code";
58 }