Module Name:    src
Committed By:   manu
Date:           Mon Jan  6 08:56:34 UTC 2014

Modified Files:
        src/lib/libperfuse: ops.c

Log Message:
For filesystems mounted without -o use_ino, readdir is not
able to fetch inode number. We perfom an addtional lookup
on each file to get it.

In that case, do not lookup .. from root, as it breaks
out of the filesystem and hits NULL pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.62 src/lib/libperfuse/ops.c:1.63
--- src/lib/libperfuse/ops.c:1.62	Fri Jul 19 07:32:35 2013
+++ src/lib/libperfuse/ops.c	Mon Jan  6 08:56:34 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.62 2013/07/19 07:32:35 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.63 2014/01/06 08:56:34 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -644,13 +644,23 @@ fuse_to_dirent(struct puffs_usermount *p
 		 */
 		if (fd->ino == PERFUSE_UNKNOWN_INO) {
 			struct puffs_node *pn;
+			struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
 
-			if (node_lookup_common(pu, opc, NULL, fd->name,
-					       NULL, &pn) != 0) {
-				DWARNX("node_lookup_common failed");
+			/* 
+			 * Avoid breaking out of fs 
+			 * by lookup to .. on root
+			 */
+			if ((strcmp(fd->name, "..") == 0) && 
+			    (pnd->pnd_nodeid == FUSE_ROOT_ID)) {
+				fd->ino = FUSE_ROOT_ID;
 			} else {
-				fd->ino = pn->pn_va.va_fileid;
-				(void)perfuse_node_reclaim(pu, pn);
+				if (node_lookup_common(pu, opc, NULL, fd->name,
+						       NULL, &pn) != 0) {
+					DWARNX("node_lookup_common failed");
+				} else {
+					fd->ino = pn->pn_va.va_fileid;
+					(void)perfuse_node_reclaim(pu, pn);
+				}
 			}
 		}
 

Reply via email to