Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libperfuse Fix dot-lookup when readdir does not provide ...



details:   https://anonhg.NetBSD.org/src/rev/f201ea4475b3
branches:  trunk
changeset: 338672:f201ea4475b3
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Jun 03 14:07:05 2015 +0000

description:
Fix dot-lookup when readdir does not provide inodes

Some filesystems do not provide inode numbers through readdir (FUSE mounts
without -o use_ino). We therefore have to lookup each directory entry to
get the missing numbers.

dot and double-dot are exceptions, as we already know the values. Moreover,
the lookup code does not expect to get requests for dot and will abort
perfused(8) when it gets some. In order to fix that, we just check for
dot and double-dot special case and use the known values instead of sending
a lookup.

diffstat:

 lib/libperfuse/ops.c |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (34 lines):

diff -r 6bd5d5b6ed81 -r f201ea4475b3 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Wed Jun 03 14:06:19 2015 +0000
+++ b/lib/libperfuse/ops.c      Wed Jun 03 14:07:05 2015 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.83 2015/02/15 20:21:29 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.84 2015/06/03 14:07:05 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -651,13 +651,17 @@
                        struct puffs_node *pn;
                        struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
 
-                       /* 
-                        * Avoid breaking out of fs 
-                        * by lookup to .. on root
-                        */
-                       if ((strcmp(name, "..") == 0) && 
-                           (pnd->pnd_nodeid == FUSE_ROOT_ID)) {
-                               fd->ino = FUSE_ROOT_ID;
+                       if (strcmp(name, "..") == 0) {
+                               /* 
+                                * Avoid breaking out of fs 
+                                * by lookup to .. on root
+                                */
+                               if (pnd->pnd_nodeid == FUSE_ROOT_ID)
+                                       fd->ino = FUSE_ROOT_ID;
+                               else
+                                       fd->ino = pnd->pnd_parent_nodeid;
+                       } else if (strcmp(name, ".") == 0 ) {
+                               fd->ino = pnd->pnd_nodeid;
                        } else {
                                int error;
 



Home | Main Index | Thread Index | Old Index