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