Module Name: src
Committed By: dholland
Date: Tue Nov 30 01:22:50 UTC 2010
Modified Files:
src/sys/rump/librump/rumpvfs: rumpfs.c
Log Message:
Fix etfs pathname handling to not (mis)use namei's scratch space.
etfs objects must now be registered as absolute paths; however, it is now
possible to access them via relative paths and through symlinks, which
previously worked some times and not others depending on exactly what
namei was doing.
discussed on tech-kern and ok'd by pooka.
To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/rump/librump/rumpvfs/rumpfs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/librump/rumpvfs/rumpfs.c
diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.74 src/sys/rump/librump/rumpvfs/rumpfs.c:1.75
--- src/sys/rump/librump/rumpvfs/rumpfs.c:1.74 Mon Nov 22 15:15:35 2010
+++ src/sys/rump/librump/rumpvfs/rumpfs.c Tue Nov 30 01:22:50 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpfs.c,v 1.74 2010/11/22 15:15:35 pooka Exp $ */
+/* $NetBSD: rumpfs.c,v 1.75 2010/11/30 01:22:50 dholland Exp $ */
/*
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.74 2010/11/22 15:15:35 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.75 2010/11/30 01:22:50 dholland Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -324,6 +324,13 @@
devminor_t dmin = -1;
int hft, error;
+ if (key[0] != '/') {
+ return EINVAL;
+ }
+ while (key[0] == '/') {
+ key++;
+ }
+
if (rumpuser_getfileinfo(hostpath, &fsize, &hft, &error))
return error;
@@ -396,7 +403,7 @@
if (ftype == RUMP_ETFS_BLK) {
format_bytes(buf, sizeof(buf), size);
- aprint_verbose("%s: hostpath %s (%s)\n", key, hostpath, buf);
+ aprint_verbose("/%s: hostpath %s (%s)\n", key, hostpath, buf);
}
return 0;
@@ -424,9 +431,18 @@
rump_etfs_remove(const char *key)
{
struct etfs *et;
- size_t keylen = strlen(key);
+ size_t keylen;
int rv;
+ if (key[0] != '/') {
+ return EINVAL;
+ }
+ while (key[0] == '/') {
+ key++;
+ }
+
+ keylen = strlen(key);
+
mutex_enter(&etfs_lock);
LIST_FOREACH(et, &etfs_list, et_entries) {
if (keylen == et->et_keylen && strcmp(et->et_key, key) == 0) {
@@ -641,13 +657,15 @@
if (dvp == rootvnode && cnp->cn_nameiop == LOOKUP) {
bool found;
mutex_enter(&etfs_lock);
- found = etfs_find(cnp->cn_pnbuf, &et, false);
+ found = etfs_find(cnp->cn_nameptr, &et, false);
mutex_exit(&etfs_lock);
if (found) {
- char *offset;
+ const char *offset;
- offset = strstr(cnp->cn_pnbuf, et->et_key);
+ /* pointless as et_key is always the whole string */
+ /*offset = strstr(cnp->cn_nameptr, et->et_key);*/
+ offset = cnp->cn_nameptr;
KASSERT(offset);
rn = et->et_rn;