blob: 11b75f7a0b24f6a5420b960f402c5c1dfde3d3a8 [file] [log] [blame]
Charles Manning753ac612012-05-09 16:55:17 +00001/*
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
16struct error_entry {
17 int code;
18 const char *text;
19};
20
21static 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
45const 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}