From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH 7/7] kvmtool: 9p: refactor rel_to_abs() Date: Thu, 17 Nov 2016 12:20:08 +0000 Message-ID: <20161117122008.GF22855@arm.com> References: <1476806585-9954-1-git-send-email-gcampana+kvm@quarkslab.com> <20161108023836.GX20591@arm.com> <9c821c8f-46a7-052c-0c0c-7c84cc19a8f6@quarkslab.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, andre.przywara@arm.com To: "G. Campana" Return-path: Received: from foss.arm.com ([217.140.101.70]:56324 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933526AbcKQRHU (ORCPT ); Thu, 17 Nov 2016 12:07:20 -0500 Content-Disposition: inline In-Reply-To: <9c821c8f-46a7-052c-0c0c-7c84cc19a8f6@quarkslab.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Nov 10, 2016 at 04:18:54PM +0100, G. Campana wrote: > On 08/11/2016 03:38, Will Deacon wrote: > > On Tue, Oct 18, 2016 at 06:03:05PM +0200, G. Campana wrote: > >> @@ -614,7 +618,6 @@ static void virtio_p9_readdir(struct p9_dev *p9dev, > >> struct stat st; > >> struct p9_fid *fid; > >> struct dirent *dent; > >> - char full_path[PATH_MAX]; > >> u64 offset, old_offset; > >> > >> rcount = 0; > >> @@ -645,11 +648,8 @@ static void virtio_p9_readdir(struct p9_dev *p9dev, > >> break; > >> } > >> old_offset = dent->d_off; > >> - if (rel_to_abs(p9dev, dent->d_name, full_path, sizeof(full_path)) != 0) { > >> - errno = ENAMETOOLONG; > >> - goto err_out; > >> - } > >> - lstat(full_path, &st); > >> + if (stat_rel(p9dev, dent->d_name, &st) != 0) > >> + memset(&st, -1, sizeof(st)); > > > > Why the memset, and not goto err_out? > > > Because the user may not be allowed to stat some entries in a directory > and it shouldn't make readdir() fail. Ok, but is memsetting to -1 really the right thing to do? This gets "converted" into a p9_qid_t, which will then look pretty strange (path and version will be set to 0xff, type will be set to P9_QTDIR). Does 9p not have a better way to communicate that the stat failed? Will