<commit_before>#include <errno.h>
#include <stddef.h>
#include <sys/mman.h>


extern void *mmap_userspace_add(void *addr, size_t len, int prot);

void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off) {
	if (len == 0) {
		SET_ERRNO(EINVAL);
		return MAP_FAILED;
	}

	if (flags & MAP_ANONYMOUS) {
		void *ptr = mmap_userspace_add(addr, len, prot);

		if (ptr == NULL) {
			errno = EPERM;
		}

		return MAP_FAILED;
	} else {
		SET_ERRNO(ENOTSUP);
		return MAP_FAILED;
	}
}<commit_msg>mmap: Add logging<commit_after>#include <util/log.h>

#include <errno.h>
#include <stddef.h>
#include <sys/mman.h>


extern void *mmap_userspace_add(void *addr, size_t len, int prot);

void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off) {
	log_debug("addr=%p, len=%d, prot=%d, flags=%d, fd=%d, off=%d", addr, len, prot, flags, fd, off);
	if (len == 0) {
		SET_ERRNO(EINVAL);
		return MAP_FAILED;
	}

	if (flags & MAP_ANONYMOUS) {
		void *ptr = mmap_userspace_add(addr, len, prot);

		if (ptr == NULL) {
			errno = EPERM;
		}

		return MAP_FAILED;
	} else {
		SET_ERRNO(ENOTSUP);
		return MAP_FAILED;
	}
}
{'fraction_non_alphanumeric': 0.15589016829052257, 'fraction_numerical': 0.001771479185119575, 'mean_word_length': 4.113122171945701, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3995164', 'n_tokens_mistral': 516, 'n_tokens_neox': 480, 'n_words': 120}