Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpvfs Include host offset in regular etfs...
details: https://anonhg.NetBSD.org/src/rev/d28d6153f50a
branches: trunk
changeset: 748059:d28d6153f50a
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Oct 11 18:12:51 2009 +0000
description:
Include host offset in regular etfs read/write operations (I can't
imagine it being particularly useful, but let's call file this
under POLA).
diffstat:
sys/rump/librump/rumpvfs/rumpfs.c | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diffs (137 lines):
diff -r 23ba79c834b5 -r d28d6153f50a sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Sun Oct 11 17:54:22 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Sun Oct 11 18:12:51 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpfs.c,v 1.26 2009/10/11 17:54:22 pooka Exp $ */
+/* $NetBSD: rumpfs.c,v 1.27 2009/10/11 18:12:51 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.26 2009/10/11 17:54:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.27 2009/10/11 18:12:51 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -129,6 +129,7 @@
char *hostpath; /* VREG */
int readfd;
int writefd;
+ uint64_t offset;
} reg;
LIST_HEAD(, rumpfs_dent) dir; /* VDIR */
} rn_u;
@@ -136,9 +137,10 @@
#define rn_hostpath rn_u.reg.hostpath
#define rn_readfd rn_u.reg.readfd
#define rn_writefd rn_u.reg.writefd
+#define rn_offset rn_u.reg.offset
#define rn_dir rn_u.dir
-static struct rumpfs_node *makeprivate(enum vtype, dev_t, off_t, const char *);
+static struct rumpfs_node *makeprivate(enum vtype, dev_t, off_t);
/*
* Extra Terrestrial stuff. We map a given key (pathname) to a file on
@@ -206,7 +208,7 @@
enum rump_etfs_type ftype, uint64_t begin, uint64_t size)
{
struct etfs *et;
- struct rumpfs_node *rn_dummy;
+ struct rumpfs_node *rn_dummy, *rn;
uint64_t fsize;
dev_t rdev = NODEV;
devminor_t dmin;
@@ -234,7 +236,14 @@
et = kmem_alloc(sizeof(*et), KM_SLEEP);
strcpy(et->et_key, key);
et->et_keylen = strlen(et->et_key);
- et->et_rn = makeprivate(ettype_to_vtype(ftype), rdev, size, hostpath);
+ et->et_rn = rn = makeprivate(ettype_to_vtype(ftype), rdev, size);
+ if (ftype == RUMP_ETFS_REG) {
+ size_t len = strlen(hostpath)+1;
+
+ rn->rn_hostpath = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
+ memcpy(rn->rn_hostpath, hostpath, len);
+ rn->rn_offset = begin;
+ }
mutex_enter(&etfs_lock);
if (etfs_find(key, &rn_dummy)) {
@@ -306,7 +315,7 @@
static kmutex_t reclock;
static struct rumpfs_node *
-makeprivate(enum vtype vt, dev_t rdev, off_t size, const char *hostpath)
+makeprivate(enum vtype vt, dev_t rdev, off_t size)
{
struct rumpfs_node *rn;
struct vattr *va;
@@ -321,8 +330,6 @@
case VREG:
rn->rn_readfd = -1;
rn->rn_writefd = -1;
- rn->rn_hostpath = malloc(strlen(hostpath)+1, M_TEMP, M_WAITOK);
- strcpy(rn->rn_hostpath, hostpath);
break;
default:
break;
@@ -509,7 +516,7 @@
struct rumpfs_dent *rdent;
int rv = 0;
- rn = makeprivate(VDIR, NODEV, DEV_BSIZE, NULL);
+ rn = makeprivate(VDIR, NODEV, DEV_BSIZE);
mutex_enter(&reclock);
rv = makevnode(rn, vpp);
mutex_exit(&reclock);
@@ -545,7 +552,7 @@
struct rumpfs_dent *rdent;
int rv;
- rn = makeprivate(va->va_type, va->va_rdev, DEV_BSIZE, NULL);
+ rn = makeprivate(va->va_type, va->va_rdev, DEV_BSIZE);
mutex_enter(&reclock);
rv = makevnode(rn, vpp);
mutex_exit(&reclock);
@@ -586,7 +593,7 @@
rv = EOPNOTSUPP;
goto out;
}
- rn = makeprivate(VSOCK, NODEV, DEV_BSIZE, NULL);
+ rn = makeprivate(VSOCK, NODEV, DEV_BSIZE);
mutex_enter(&reclock);
rv = makevnode(rn, vpp);
mutex_exit(&reclock);
@@ -655,7 +662,8 @@
bufsize = uio->uio_resid;
buf = kmem_alloc(bufsize, KM_SLEEP);
- if (rumpuser_read(rn->rn_readfd, buf, bufsize, &error) == -1)
+ if (rumpuser_pread(rn->rn_readfd, buf, bufsize,
+ uio->uio_offset + rn->rn_offset, &error) == -1)
goto out;
error = uiomove(buf, bufsize, uio);
@@ -686,7 +694,8 @@
if (error)
goto out;
KASSERT(uio->uio_resid == 0);
- rumpuser_write(rn->rn_writefd, buf, bufsize, &error);
+ rumpuser_pwrite(rn->rn_writefd, buf, bufsize,
+ uio->uio_offset + rn->rn_offset, &error);
out:
kmem_free(buf, bufsize);
@@ -779,7 +788,7 @@
TAILQ_INIT(&rump_mnt.mnt_vnodelist);
vfs_opv_init(rump_opv_descs);
- rn = makeprivate(VDIR, NODEV, DEV_BSIZE, NULL);
+ rn = makeprivate(VDIR, NODEV, DEV_BSIZE);
mutex_enter(&reclock);
rv = makevnode(rn, &rootvnode);
mutex_exit(&reclock);
Home |
Main Index |
Thread Index |
Old Index