mailing list of musl libc
 help / color / mirror / code / Atom feed
f80752bc4c60e2a8bc8adef4a14430791222fd2b blob 768 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#define _BSD_SOURCE
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdint.h>
#include "syscall.h"
#include "kstat.h"
#include "statx.h"

const char unsigned *__map_file(const char *pathname, size_t *size)
{
	const unsigned char *map = MAP_FAILED;
	int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
	if (fd < 0) return 0;
#ifdef SYS_fstat
	struct kstat st;
	if (!syscall(SYS_fstat, fd, &st)) {
		map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
		*size = st.st_size;
	}
#else
	struct statx st;
	if (!syscall(SYS_statx, fd, "", AT_EMPTY_PATH, STATX_SIZE, &st)) {
		map = __mmap(0, st.stx_size, PROT_READ, MAP_SHARED, fd, 0);
		*size = st.stx_size;
	}
#endif
	__syscall(SYS_close, fd);
	return map == MAP_FAILED ? 0 : map;
}
debug log:

solving f80752bc ...
found f80752bc in https://inbox.vuxu.org/musl/20200903112309.102601-7-sorear@fastmail.com/
found d3cefa82 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 d3cefa8284cc80f2b2205065372b1a3e30fef43b	src/time/__map_file.c

applying [1/1] https://inbox.vuxu.org/musl/20200903112309.102601-7-sorear@fastmail.com/
diff --git a/src/time/__map_file.c b/src/time/__map_file.c
index d3cefa82..f80752bc 100644

Checking patch src/time/__map_file.c...
Applied patch src/time/__map_file.c cleanly.

index at:
100644 f80752bc4c60e2a8bc8adef4a14430791222fd2b	src/time/__map_file.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).