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.
This commit is contained in:
parent
99a38adeb5
commit
b76d3b3fa5
@ -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 *pu, puffs_cookie_t opc,
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user