|
35 | 35 | static int fat_error_remap(FRESULT res)
|
36 | 36 | {
|
37 | 37 | switch(res) {
|
38 |
| - case FR_OK: /* (0) Succeeded */ |
39 |
| - return 0; /* no error */ |
40 |
| - case FR_DISK_ERR: /* (1) A hard error occurred in the low level disk I/O layer */ |
41 |
| - case FR_NOT_READY: /* (3) The physical drive cannot work */ |
42 |
| - return -EIO; /* I/O error */ |
43 |
| - case FR_NO_FILE: /* (4) Could not find the file */ |
44 |
| - case FR_NO_PATH: /* (5) Could not find the path */ |
45 |
| - case FR_INVALID_NAME: /* (6) The path name format is invalid */ |
46 |
| - case FR_INVALID_DRIVE: /* (11) The logical drive number is invalid */ |
47 |
| - case FR_NO_FILESYSTEM: /* (13) There is no valid FAT volume */ |
48 |
| - return -ENOENT; /* No such file or directory */ |
49 |
| - case FR_DENIED: /* (7) Access denied due to prohibited access or directory full */ |
50 |
| - return -EACCES; /* Permission denied */ |
51 |
| - case FR_EXIST: /* (8) Access denied due to prohibited access */ |
52 |
| - return -EEXIST; /* File exists */ |
53 |
| - case FR_WRITE_PROTECTED: /* (10) The physical drive is write protected */ |
54 |
| - case FR_LOCKED: /* (16) The operation is rejected according to the file sharing policy */ |
55 |
| - return -EACCES; /* Permission denied */ |
56 |
| - case FR_INVALID_OBJECT: /* (9) The file/directory object is invalid */ |
57 |
| - return -EFAULT; /* Bad address */ |
58 |
| - case FR_NOT_ENABLED: /* (12) The volume has no work area */ |
59 |
| - return -ENXIO; /* No such device or address */ |
60 |
| - case FR_NOT_ENOUGH_CORE: /* (17) LFN working buffer could not be allocated */ |
61 |
| - return -ENOMEM; /* Not enough space */ |
62 |
| - case FR_TOO_MANY_OPEN_FILES: /* (18) Number of open files > _FS_LOCK */ |
63 |
| - return -ENFILE; /* Too many open files in system */ |
64 |
| - case FR_INVALID_PARAMETER: /* (19) Given parameter is invalid */ |
65 |
| - return -ENOEXEC; /* Exec format error */ |
66 |
| - case FR_INT_ERR: /* (2) Assertion failed */ |
67 |
| - case FR_MKFS_ABORTED: /* (14) The f_mkfs() aborted due to any parameter error */ |
68 |
| - case FR_TIMEOUT: /* (15) Could not get a grant to access the volume within defined period */ |
69 |
| - default: /* Bad file number */ |
70 |
| - return -EBADF; |
| 38 | + case FR_OK: return 0; // (0) Succeeded |
| 39 | + case FR_DISK_ERR: return -EIO; // (1) A hard error occurred in the low level disk I/O layer |
| 40 | + case FR_INT_ERR: return -1; // (2) Assertion failed |
| 41 | + case FR_NOT_READY: return -EIO; // (3) The physical drive cannot work |
| 42 | + case FR_NO_FILE: return -ENOENT; // (4) Could not find the file |
| 43 | + case FR_NO_PATH: return -ENOTDIR; // (5) Could not find the path |
| 44 | + case FR_INVALID_NAME: return -EINVAL; // (6) The path name format is invalid |
| 45 | + case FR_DENIED: return -EACCES; // (7) Access denied due to prohibited access or directory full |
| 46 | + case FR_EXIST: return -EEXIST; // (8) Access denied due to prohibited access |
| 47 | + case FR_INVALID_OBJECT: return -EBADF; // (9) The file/directory object is invalid |
| 48 | + case FR_WRITE_PROTECTED: return -EACCES; // (10) The physical drive is write protected |
| 49 | + case FR_INVALID_DRIVE: return -ENODEV; // (11) The logical drive number is invalid |
| 50 | + case FR_NOT_ENABLED: return -ENODEV; // (12) The volume has no work area |
| 51 | + case FR_NO_FILESYSTEM: return -EINVAL; // (13) There is no valid FAT volume |
| 52 | + case FR_MKFS_ABORTED: return -EIO; // (14) The f_mkfs() aborted due to any problem |
| 53 | + case FR_TIMEOUT: return -ETIMEDOUT; // (15) Could not get a grant to access the volume within defined period |
| 54 | + case FR_LOCKED: return -EBUSY; // (16) The operation is rejected according to the file sharing policy |
| 55 | + case FR_NOT_ENOUGH_CORE: return -ENOMEM; // (17) LFN working buffer could not be allocated |
| 56 | + case FR_TOO_MANY_OPEN_FILES: return -ENFILE; // (18) Number of open files > FF_FS_LOCK |
| 57 | + case FR_INVALID_PARAMETER: return -EINVAL; // (19) Given parameter is invalid |
| 58 | + default: return -res; |
71 | 59 | }
|
72 | 60 | }
|
73 | 61 |
|
|
0 commit comments