From b8251024ac0635ec025886f71f3e065886c9cef4 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Tue, 10 Nov 2015 14:51:04 +0100 Subject: mtools: Remove local xpread/xpwrite, use ones from syslxcom Signed-off-by: Nicolas Cornu Signed-off-by: Paulo Alcantara --- mtools/Makefile | 1 + mtools/syslinux.c | 59 +------------------------------------------------------ 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/mtools/Makefile b/mtools/Makefile index 0d0b1b27..c9804209 100755 --- a/mtools/Makefile +++ b/mtools/Makefile @@ -9,6 +9,7 @@ SRCS = syslinux.c \ ../libinstaller/fs.c \ ../libinstaller/syslxmod.c \ ../libinstaller/syslxopt.c \ + ../libinstaller/syslxcom.c \ ../libinstaller/setadv.c \ ../libinstaller/bootsect_bin.c \ ../libinstaller/ldlinux_bin.c \ diff --git a/mtools/syslinux.c b/mtools/syslinux.c index 59244307..3686be0a 100755 --- a/mtools/syslinux.c +++ b/mtools/syslinux.c @@ -42,8 +42,8 @@ #include "setadv.h" #include "syslxopt.h" #include "syslxfs.h" +#include "syslxcom.h" -char *program; /* Name of program */ pid_t mypid; void __attribute__ ((noreturn)) die(const char *msg) @@ -58,63 +58,6 @@ void __attribute__ ((noreturn)) die_err(const char *msg) exit(1); } -/* - * read/write wrapper functions - */ -ssize_t xpread(int fd, void *buf, size_t count, off_t offset) -{ - char *bufp = (char *)buf; - ssize_t rv; - ssize_t done = 0; - - while (count) { - rv = pread(fd, bufp, count, offset); - if (rv == 0) { - die("short read"); - } else if (rv == -1) { - if (errno == EINTR) { - continue; - } else { - die(strerror(errno)); - } - } else { - bufp += rv; - offset += rv; - done += rv; - count -= rv; - } - } - - return done; -} - -ssize_t xpwrite(int fd, const void *buf, size_t count, off_t offset) -{ - const char *bufp = (const char *)buf; - ssize_t rv; - ssize_t done = 0; - - while (count) { - rv = pwrite(fd, bufp, count, offset); - if (rv == 0) { - die("short write"); - } else if (rv == -1) { - if (errno == EINTR) { - continue; - } else { - die(strerror(errno)); - } - } else { - bufp += rv; - offset += rv; - done += rv; - count -= rv; - } - } - - return done; -} - /* * Version of the read function suitable for libfat */ -- cgit v1.2.3