Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mtools: Remove local xpread/xpwrite, use ones from syslxcom
Signed-off-by: Nicolas Cornu <ncornu@aldebaran.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
  • Loading branch information
Nicolas Cornu authored and Paulo Alcantara committed Nov 10, 2015
1 parent e2ba978 commit b825102
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
1 change: 1 addition & 0 deletions mtools/Makefile
Expand Up @@ -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 \
Expand Down
59 changes: 1 addition & 58 deletions mtools/syslinux.c
Expand Up @@ -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)
Expand All @@ -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
*/
Expand Down

0 comments on commit b825102

Please sign in to comment.