Module Name:    src
Committed By:   hannken
Date:           Sun Aug  7 05:56:32 UTC 2011

Modified Files:
        src/sys/rump/librump/rumpvfs: rumpfs.c

Log Message:
Allow removal of a directory containing only whiteouts and free them first.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 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.97 src/sys/rump/librump/rumpvfs/rumpfs.c:1.98
--- src/sys/rump/librump/rumpvfs/rumpfs.c:1.97	Fri Aug  5 08:13:59 2011
+++ src/sys/rump/librump/rumpvfs/rumpfs.c	Sun Aug  7 05:56:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfs.c,v 1.97 2011/08/05 08:13:59 hannken Exp $	*/
+/*	$NetBSD: rumpfs.c,v 1.98 2011/08/07 05:56:32 hannken Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.97 2011/08/05 08:13:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.98 2011/08/07 05:56:32 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -927,11 +927,20 @@
 	struct componentname *cnp = ap->a_cnp;
 	struct rumpfs_node *rnd = dvp->v_data;
 	struct rumpfs_node *rn = vp->v_data;
+	struct rumpfs_dent *rd;
 	int rv = 0;
 
-	if (!LIST_EMPTY(&rn->rn_dir)) {
-		rv = ENOTEMPTY;
-		goto out;
+	LIST_FOREACH(rd, &rn->rn_dir, rd_entries) {
+		if (rd->rd_node != RUMPFS_WHITEOUT) {
+			rv = ENOTEMPTY;
+			goto out;
+		}
+	}
+	while ((rd = LIST_FIRST(&rn->rn_dir)) != NULL) {
+		KASSERT(rd->rd_node == RUMPFS_WHITEOUT);
+		LIST_REMOVE(rd, rd_entries);
+		kmem_free(rd->rd_name, rd->rd_namelen+1);
+		kmem_free(rd, sizeof(*rd));
 	}
 
 	freedir(rnd, cnp);

Reply via email to