1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* (C) Copyright 2011 Logic Product Development, Inc.
* Author :
* Peter Barada <peter.barada@logicpd.com>
*
* YAFFS Errno handling
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include "yaffsfs_errno.h"
int yaffsfs_errno;
char *yaffsfs_errstr;
void yaffsfs_set_error(int x)
{
yaffsfs_errno = x;
switch(x) {
case 0:
yaffsfs_errstr = "Success";
break;
case -EPERM:
yaffsfs_errstr = "Operation not permitted";
break;
case -ENOENT:
yaffsfs_errstr = "No such file or directory";
break;
case -EBADF:
yaffsfs_errstr = "Bad file number";
break;
case -ENOMEM:
yaffsfs_errstr = "Out of memory";
break;
case -EACCES:
yaffsfs_errstr = "Permission denied";
break;
case -EFAULT:
yaffsfs_errstr = "Bad address";
break;
case -EBUSY:
yaffsfs_errstr = "Device or resource busy";
break;
case -EEXIST:
yaffsfs_errstr = "File exists";
break;
case -ENODEV:
yaffsfs_errstr = "No such device";
break;
case -ENOTDIR:
yaffsfs_errstr = "Not a directory";
break;
case -EISDIR:
yaffsfs_errstr = "Is a directory";
break;
case -EINVAL:
yaffsfs_errstr = "Invalid argument";
break;
case -ENFILE:
yaffsfs_errstr = "File table overflow";
break;
case -ENOSPC:
yaffsfs_errstr = "No space left on device";
break;
case -EROFS:
yaffsfs_errstr = "Read-only file system";
break;
case -ERANGE:
yaffsfs_errstr = "Math result not representable";
break;
case -ENAMETOOLONG:
yaffsfs_errstr = "File name too long";
break;
case -ENOTEMPTY:
yaffsfs_errstr = "Directory not empty";
break;
case -ELOOP:
yaffsfs_errstr = "Too many symbolic links encountered";
break;
case -ENODATA:
yaffsfs_errstr = "No data available";
break;
case -EBADMSG:
yaffsfs_errstr = "Not a data message";
break;
case -EUCLEAN:
yaffsfs_errstr = "Structure needs cleaning";
break;
default:
printf("%s: Huh? yaffs_errno called from %p with %d\n",
__FUNCTION__, __builtin_return_address(0), x);
yaffsfs_errstr = "Unknown!";
break;
}
}
int yaffsfs_get_error(char **errstr)
{
if (errstr)
*errstr = yaffsfs_errstr;
return yaffsfs_errno;
}
|