Source-Changes-HG archive

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

[src/trunk]: src/lib/libperfuse For filesystems mounted without -o use_ino, r...



details:   https://anonhg.NetBSD.org/src/rev/57a02aa02e6b
branches:  trunk
changeset: 792517:57a02aa02e6b
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Jan 06 08:56:34 2014 +0000

description:
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.

diffstat:

 lib/libperfuse/ops.c |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (39 lines):

diff -r 1b2189e5e0ee -r 57a02aa02e6b lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Mon Jan 06 07:56:47 2014 +0000
+++ b/lib/libperfuse/ops.c      Mon Jan 06 08:56:34 2014 +0000
@@ -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 @@
                 */
                if (fd->ino == PERFUSE_UNKNOWN_INO) {
                        struct puffs_node *pn;
-
-                       if (node_lookup_common(pu, opc, NULL, fd->name,
-                                              NULL, &pn) != 0) {
-                               DWARNX("node_lookup_common failed");
+                       struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
+
+                       /* 
+                        * 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);
+                               }
                        }
                }
 



Home | Main Index | Thread Index | Old Index