2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Timothy Manning <timothy@yaffs.net>
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.
14 * error_handler.c contains code for checking yaffs function calls for errors.
16 #include "error_handler.h"
19 typedef struct error_codes_template {
24 const error_entry error_list[] = {
25 { ENOMEM , "ENOMEM" },
35 { ENODATA, "ENODATA"},
36 { ENOTEMPTY, "ENOTEMPTY"},
37 { ENAMETOOLONG,"ENAMETOOLONG"},
40 { ENOTDIR , "ENOTDIR"},
45 const char * error_to_str(int err)
47 error_entry *e = error_list;
50 while(e->code && e->text){
55 return "Unknown error code";
58 void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]){
65 add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT);
66 add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT);
67 add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,NPRINT);
68 yaffs_error=yaffs_get_error();
69 append_int_to_buffer(message_buffer, yaffs_error,MESSAGE_LEVEL_ERROR,PRINT);
71 add_to_buffer(message_buffer, error_to_str(yaffs_error),MESSAGE_LEVEL_ERROR,NPRINT);
72 append_to_buffer(message_buffer, "\n\n",MESSAGE_LEVEL_ERROR,PRINT);
74 //scanf("%c",dummy); /*this line causes a segmentation fault. Need a better way of waiting for a key press*/
75 //print_buffer(message_buffer,PRINT_ALL);
79 add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT);