Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/tmpfs tmpfs: fix the zero-length symlink target case ...
details: https://anonhg.NetBSD.org/src/rev/916b5c87c152
branches: trunk
changeset: 791040:916b5c87c152
user: rmind <rmind%NetBSD.org@localhost>
date: Fri Nov 01 15:38:45 2013 +0000
description:
tmpfs: fix the zero-length symlink target case as NetBSD supports them.
diffstat:
sys/fs/tmpfs/tmpfs_subr.c | 15 ++++++++++-----
sys/fs/tmpfs/tmpfs_vnops.c | 15 +++++++++------
2 files changed, 19 insertions(+), 11 deletions(-)
diffs (75 lines):
diff -r 469c2c7712d0 -r 916b5c87c152 sys/fs/tmpfs/tmpfs_subr.c
--- a/sys/fs/tmpfs/tmpfs_subr.c Fri Nov 01 15:33:48 2013 +0000
+++ b/sys/fs/tmpfs/tmpfs_subr.c Fri Nov 01 15:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_subr.c,v 1.81 2013/10/31 00:59:17 rmind Exp $ */
+/* $NetBSD: tmpfs_subr.c,v 1.82 2013/11/01 15:38:45 rmind Exp $ */
/*
* Copyright (c) 2005-2011 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.81 2013/10/31 00:59:17 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.82 2013/11/01 15:38:45 rmind Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -167,11 +167,16 @@
case VLNK:
/* Symbolic link. Target specifies the file name. */
KASSERT(target != NULL);
+ nnode->tn_size = strlen(target);
- nnode->tn_size = strlen(target);
- KASSERT(nnode->tn_size > 0);
+ if (nnode->tn_size == 0) {
+ /* Zero-length targets are supported. */
+ nnode->tn_spec.tn_lnk.tn_link = NULL;
+ break;
+ }
+
KASSERT(nnode->tn_size < MAXPATHLEN);
- nnode->tn_size++; /* include the NIL */
+ nnode->tn_size++; /* include the NUL terminator */
nnode->tn_spec.tn_lnk.tn_link =
tmpfs_strname_alloc(tmp, nnode->tn_size);
diff -r 469c2c7712d0 -r 916b5c87c152 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c Fri Nov 01 15:33:48 2013 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c Fri Nov 01 15:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vnops.c,v 1.104 2013/10/31 00:59:17 rmind Exp $ */
+/* $NetBSD: tmpfs_vnops.c,v 1.105 2013/11/01 15:38:45 rmind Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.104 2013/10/31 00:59:17 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.105 2013/11/01 15:38:45 rmind Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -1036,11 +1036,14 @@
KASSERT(VOP_ISLOCKED(vp));
KASSERT(uio->uio_offset == 0);
KASSERT(vp->v_type == VLNK);
- KASSERT(node->tn_size > 0);
- /* Note: readlink(2) returns the path without NIL. */
- error = uiomove(node->tn_spec.tn_lnk.tn_link,
- MIN(node->tn_size - 1, uio->uio_resid), uio);
+ /* Note: readlink(2) returns the path without NUL terminator. */
+ if (node->tn_size > 0) {
+ error = uiomove(node->tn_spec.tn_lnk.tn_link,
+ MIN(node->tn_size - 1, uio->uio_resid), uio);
+ } else {
+ error = 0;
+ }
node->tn_status |= TMPFS_NODE_ACCESSED;
return error;
Home |
Main Index |
Thread Index |
Old Index