From 4be24c244e22ef029cf1f014c0cf8433a49a8a37 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Mon, 1 Nov 2010 11:06:56 +1300 Subject: [PATCH] yaffs direct: Add proper error handler for too many files open If you open too many files then you get -ENFILE. Signed-off-by: Charles Manning --- direct/python/yaffs_error_converter.c | 1 + direct/yaffsfs.c | 5 ++++- yportenv.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/direct/python/yaffs_error_converter.c b/direct/python/yaffs_error_converter.c index 5d9247a..e9a8070 100644 --- a/direct/python/yaffs_error_converter.c +++ b/direct/python/yaffs_error_converter.c @@ -36,6 +36,7 @@ const error_entry error_list[] = { { EEXIST , "EEXIST"}, { ENOTDIR , "ENOTDIR"}, { EISDIR , "EISDIR"}, + { ENFILE, "ENFILE"}, { 0, NULL } }; diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index ea33223..573c68b 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -612,7 +612,10 @@ int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing) handle = yaffsfs_GetNewHandle(); - if(handle >= 0){ + if(handle < 0){ + yaffsfs_SetError(-ENFILE); + errorReported = 1; + } else { yh = yaffsfs_GetHandlePointer(handle); diff --git a/yportenv.h b/yportenv.h index 2f9063b..38a3595 100644 --- a/yportenv.h +++ b/yportenv.h @@ -210,6 +210,10 @@ #define EINVAL 22 #endif +#ifndef ENFILE +#define ENFILE 23 +#endif + #ifndef EBADF #define EBADF 9 #endif -- 2.30.2