Module Name:    src
Committed By:   hannken
Date:           Fri Apr  1 17:40:54 UTC 2011

Modified Files:
        src/sys/fs/tmpfs: tmpfs_subr.c
        src/tests/fs/vfs: t_vnops.c

Log Message:
Make zero length symlinks work on tmpfs.

Fixes PR #43843 (tmpfs dies with kassert panic for 0 length symlink target)


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/fs/tmpfs/tmpfs_subr.c
cvs rdiff -u -r1.22 -r1.23 src/tests/fs/vfs/t_vnops.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/fs/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.62 src/sys/fs/tmpfs/tmpfs_subr.c:1.63
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.62	Thu Jan 13 13:35:12 2011
+++ src/sys/fs/tmpfs/tmpfs_subr.c	Fri Apr  1 17:40:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_subr.c,v 1.62 2011/01/13 13:35:12 pooka Exp $	*/
+/*	$NetBSD: tmpfs_subr.c,v 1.63 2011/04/01 17:40:54 hannken Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.62 2011/01/13 13:35:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.63 2011/04/01 17:40:54 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -163,6 +163,10 @@
 	case VLNK:
 		KASSERT(strlen(target) < MAXPATHLEN);
 		nnode->tn_size = strlen(target);
+		if (nnode->tn_size == 0) {
+			nnode->tn_spec.tn_lnk.tn_link = NULL;
+			break;
+		}
 		nnode->tn_spec.tn_lnk.tn_link =
 		    tmpfs_strname_alloc(tmp, nnode->tn_size);
 		if (nnode->tn_spec.tn_lnk.tn_link == NULL) {
@@ -224,8 +228,9 @@
 
 	switch (node->tn_type) {
 	case VLNK:
-		tmpfs_strname_free(tmp, node->tn_spec.tn_lnk.tn_link,
-		    node->tn_size);
+		if (node->tn_size > 0)
+			tmpfs_strname_free(tmp, node->tn_spec.tn_lnk.tn_link,
+			    node->tn_size);
 		break;
 	case VREG:
 		/*

Index: src/tests/fs/vfs/t_vnops.c
diff -u src/tests/fs/vfs/t_vnops.c:1.22 src/tests/fs/vfs/t_vnops.c:1.23
--- src/tests/fs/vfs/t_vnops.c:1.22	Sat Mar 19 20:05:21 2011
+++ src/tests/fs/vfs/t_vnops.c	Fri Apr  1 17:40:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vnops.c,v 1.22 2011/03/19 20:05:21 hannken Exp $	*/
+/*	$NetBSD: t_vnops.c,v 1.23 2011/04/01 17:40:54 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -527,10 +527,6 @@
 
 	RL(rump_sys_chdir(mp));
 
-	if (FSTYPE_TMPFS(tc)) {
-		atf_tc_expect_signal(SIGABRT, "PR kern/43843");
-	}
-
 	RL(rump_sys_symlink("", "afile"));
 	RL(rump_sys_chdir("/"));
 }

Reply via email to