From 35fa3b58087fa4e52f9c04c974a6091800dfb432 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Fri, 17 Jun 2016 17:10:10 +0200 Subject: [PATCH] xbps-create: remove mmap to load files to archive. --- bin/xbps-create/main.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index 61cb1a4f..3bd30219 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -526,8 +526,9 @@ static void write_entry(struct archive *ar, struct archive_entry *entry) { const char *name; - char *mmf; - size_t mmflen, filelen; + int fd; + char buf[65536]; + ssize_t len; if (archive_entry_pathname(entry) == NULL) return; @@ -546,11 +547,16 @@ write_entry(struct archive *ar, struct archive_entry *entry) } name = archive_entry_sourcepath(entry); - if (!xbps_mmap_file(name, (void *)&mmf, &mmflen, &filelen)) - die("cannot read %s file", name); - archive_write_data(ar, mmf, filelen); - (void)munmap(mmf, mmflen); + if ((fd = open(name, O_RDONLY)) < 0) + die("cannot open %s file", name); + while ((len = read(fd, buf, sizeof(buf))) > 0) + archive_write_data(ar, buf, len); + (void)close(fd); + + if(len < 0) + die("cannot open %s file", name); + archive_entry_free(entry); }