Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / pios / common / libraries / yaffs2 / yaffs_error.c
blob11b75f7a0b24f6a5420b960f402c5c1dfde3d3a8
1 /*
2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
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.
14 #include "yaffsfs.h"
16 struct error_entry {
17 int code;
18 const char *text;
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 }
45 const char *yaffs_error_to_str(int err)
47 const struct error_entry *e = error_list;
49 if (err < 0)
50 err = -err;
52 while (e->code && e->text) {
53 if (err == e->code)
54 return e->text;
55 e++;
57 return "Unknown error code";