Allow this to work with disks greater than 4 GB and with names not beginning
with "s".
This commit is contained in:
parent
07122a2a31
commit
cb46e6c2af
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
#include <machine/asm.h>
|
#include <machine/asm.h>
|
||||||
|
|
||||||
ENTRY(host_read)
|
ENTRY(host_read)
|
||||||
@ -16,7 +21,10 @@ ENTRY(host_write)
|
|||||||
blr
|
blr
|
||||||
|
|
||||||
ENTRY(host_seek)
|
ENTRY(host_seek)
|
||||||
li %r0, 19 # SYS_lseek
|
mr %r4,%r5
|
||||||
|
mr %r5,%r6
|
||||||
|
mr %r6,%r7
|
||||||
|
li %r0, 140 # SYS_llseek
|
||||||
sc
|
sc
|
||||||
blr
|
blr
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
ssize_t host_read(int fd, void *buf, size_t nbyte);
|
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_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_open(char *path, int flags, int mode);
|
||||||
int host_close(int fd);
|
int host_close(int fd);
|
||||||
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int);
|
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int);
|
||||||
|
@ -40,7 +40,7 @@ static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data);
|
|||||||
static void hostdisk_print(int verbose);
|
static void hostdisk_print(int verbose);
|
||||||
|
|
||||||
struct devsw hostdisk = {
|
struct devsw hostdisk = {
|
||||||
"s",
|
"/dev",
|
||||||
DEVT_DISK,
|
DEVT_DISK,
|
||||||
hostdisk_init,
|
hostdisk_init,
|
||||||
hostdisk_strategy,
|
hostdisk_strategy,
|
||||||
@ -67,8 +67,10 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
|
|||||||
|
|
||||||
pos = dblk * 512;
|
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);
|
return (EIO);
|
||||||
|
}
|
||||||
n = host_read(desc->d_unit, buf, size);
|
n = host_read(desc->d_unit, buf, size);
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
@ -82,22 +84,19 @@ static int
|
|||||||
hostdisk_open(struct open_file *f, ...)
|
hostdisk_open(struct open_file *f, ...)
|
||||||
{
|
{
|
||||||
struct devdesc *desc;
|
struct devdesc *desc;
|
||||||
char *path;
|
|
||||||
va_list vl;
|
va_list vl;
|
||||||
|
|
||||||
va_start(vl, f);
|
va_start(vl, f);
|
||||||
desc = va_arg(vl, struct devdesc *);
|
desc = va_arg(vl, struct devdesc *);
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
|
|
||||||
path = malloc(strlen((char *)(desc->d_opendata)) + 6);
|
desc->d_unit = host_open(desc->d_opendata, O_RDONLY, 0);
|
||||||
strcpy(path, "/dev/");
|
|
||||||
strcat(path, (char *)(desc->d_opendata));
|
|
||||||
|
|
||||||
desc->d_unit = host_open(path, O_RDONLY, 0);
|
if (desc->d_unit <= 0) {
|
||||||
free(path);
|
printf("hostdisk_open: couldn't open %s: %d\n",
|
||||||
|
desc->d_opendata, desc->d_unit);
|
||||||
if (desc->d_unit <= 0)
|
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user