/****************************************************************************/
#include "qemu/osdep.h"
-#include <sys/mman.h>
#include "qemu.h"
#include "flat.h"
-#include <target_flat.h>
+#include "target_flat.h"
//#define DEBUG
int ret;
buf = lock_user(VERIFY_WRITE, ptr, len, 0);
+ if (!buf) {
+ return -EFAULT;
+ }
ret = pread(fd, buf, len, offset);
+ if (ret < 0) {
+ ret = -errno;
+ }
unlock_user(buf, ptr, len);
return ret;
}