]> git.ipfire.org Git - thirdparty/qemu.git/commit
9pfs: handle walk of ".." in the root directory
authorGreg Kurz <groug@kaod.org>
Tue, 30 Aug 2016 15:02:27 +0000 (17:02 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 8 Sep 2016 20:47:04 +0000 (15:47 -0500)
commit85d0a53c583656e5e37a8317f9119933c796847f
treec005c89bcf51d36e1d2f8562dff3539aa5144219
parentb5191b2df7dc92a7a4f7fb4d18c37cf8aae38894
9pfs: handle walk of ".." in the root directory

The 9P spec at http://man.cat-v.org/plan_9/5/intro says:

All directories must support walks to the directory .. (dot-dot) meaning
parent directory, although by convention directories contain no explicit
entry for .. or . (dot).  The parent of the root directory of a server's
tree is itself.

This means that a client cannot walk further than the root directory
exported by the server. In other words, if the client wants to walk
"/.." or "/foo/../..", the server should answer like the request was
to walk "/".

This patch just does that:
- we cache the QID of the root directory at attach time
- during the walk we compare the QID of each path component with the root
  QID to detect if we're in a "/.." situation
- if so, we skip the current component and go to the next one

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 56f101ecce0eafd09e2daf1c4eeb1377d6959261)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/9p.c
hw/9pfs/9p.h