core: Move reader and posix functions from mes.c