Allow this to work with disks greater than 4 GB and with names not beginning

with "s".
This commit is contained in:
Nathan Whitehorn 2015-02-01 02:02:50 +00:00
parent 07122a2a31
commit cb46e6c2af
3 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,8 @@
/*
*
* $FreeBSD$
*/
#include <machine/asm.h>
ENTRY(host_read)
@ -16,7 +21,10 @@ ENTRY(host_write)
blr
ENTRY(host_seek)
li %r0, 19 # SYS_lseek
mr %r4,%r5
mr %r5,%r6
mr %r6,%r7
li %r0, 140 # SYS_llseek
sc
blr

View File

@ -32,7 +32,7 @@
ssize_t host_read(int fd, void *buf, size_t nbyte);
ssize_t host_write(int fd, const void *buf, size_t nbyte);
ssize_t host_seek(int fd, int offset, int whence);
ssize_t host_seek(int fd, int64_t offset, int whence);
int host_open(char *path, int flags, int mode);
int host_close(int fd);
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int);

View File

@ -40,7 +40,7 @@ static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data);
static void hostdisk_print(int verbose);
struct devsw hostdisk = {
"s",
"/dev",
DEVT_DISK,
hostdisk_init,
hostdisk_strategy,
@ -67,8 +67,10 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
pos = dblk * 512;
if (host_seek(desc->d_unit, pos, 0) < 0)
if (host_seek(desc->d_unit, pos, 0) < 0) {
printf("Seek error\n");
return (EIO);
}
n = host_read(desc->d_unit, buf, size);
if (n < 0)
@ -82,22 +84,19 @@ static int
hostdisk_open(struct open_file *f, ...)
{
struct devdesc *desc;
char *path;
va_list vl;
va_start(vl, f);
desc = va_arg(vl, struct devdesc *);
va_end(vl);
path = malloc(strlen((char *)(desc->d_opendata)) + 6);
strcpy(path, "/dev/");
strcat(path, (char *)(desc->d_opendata));
desc->d_unit = host_open(desc->d_opendata, O_RDONLY, 0);
desc->d_unit = host_open(path, O_RDONLY, 0);
free(path);
if (desc->d_unit <= 0)
if (desc->d_unit <= 0) {
printf("hostdisk_open: couldn't open %s: %d\n",
desc->d_opendata, desc->d_unit);
return (ENOENT);
}
return (0);
}