diff --git a/fs/Kconfig b/fs/Kconfig index cce2d2ab2b..34d9884689 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -30,6 +30,12 @@ config FS_AUTOMOUNTER_DEBUG system debug is not enable. This is useful primarily for in vivo unit testing of the auto-mount feature. +config FS_NEPOLL_DESCRIPTORS + int "Maximum number of default epoll descriptors for epoll_create1(2)" + default 8 + ---help--- + The maximum number of default epoll descriptors for epoll_create1(2) + config DISABLE_PSEUDOFS_OPERATIONS bool "Disable pseudo-filesystem operations" default y if DEFAULT_SMALL diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 35547f497b..f6f9bdf01a 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -80,6 +80,31 @@ int epoll_create(int size) return (int)((intptr_t)eph); } +/**************************************************************************** + * Name: epoll_create1 + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +int epoll_create1(int flags) +{ + /* For current implementation, Close-on-exec is a default behavior, + * the handle of epoll(2) is not a real file handle. + */ + + if (flags != EPOLL_CLOEXEC) + { + return EINVAL; + } + + return epoll_create(CONFIG_FS_NEPOLL_DESCRIPTORS); +} + /**************************************************************************** * Name: epoll_close * diff --git a/include/sys/epoll.h b/include/sys/epoll.h index b94ef0a360..d8f221972b 100644 --- a/include/sys/epoll.h +++ b/include/sys/epoll.h @@ -76,6 +76,14 @@ enum EPOLL_EVENTS #define EPOLLHUP EPOLLHUP }; +/* Flags to be passed to epoll_create1. */ + +enum +{ + EPOLL_CLOEXEC = 02000000 +#define EPOLL_CLOEXEC EPOLL_CLOEXEC +}; + typedef union poll_data { void *ptr; @@ -108,8 +116,10 @@ struct epoll_head ****************************************************************************/ int epoll_create(int size); +int epoll_create1(int flags); int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev); -int epoll_wait(int epfd, struct epoll_event *evs, int maxevents, int timeout); +int epoll_wait(int epfd, struct epoll_event *evs, + int maxevents, int timeout); void epoll_close(int epfd);