From patchwork Sat Jun 18 17:49:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 893572 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5IHnO71020654 for ; Sat, 18 Jun 2011 17:49:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751818Ab1FRRtV (ORCPT ); Sat, 18 Jun 2011 13:49:21 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:33210 "EHLO e23smtp04.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507Ab1FRRtU (ORCPT ); Sat, 18 Jun 2011 13:49:20 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp04.au.ibm.com (8.14.4/8.13.1) with ESMTP id p5IHh9F6027725 for ; Sun, 19 Jun 2011 03:43:09 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5IHmKed1126572 for ; Sun, 19 Jun 2011 03:48:20 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5IHnFjo028477 for ; Sun, 19 Jun 2011 03:49:16 +1000 Received: from skywalker.in.ibm.com ([9.77.201.141]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p5IHnArg028441; Sun, 19 Jun 2011 03:49:14 +1000 From: "Aneesh Kumar K.V" To: penberg@kernel.org Cc: kvm@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH 3/5] tools/kvm/9p: Don't follow symlink on server Date: Sat, 18 Jun 2011 23:19:06 +0530 Message-Id: <1308419348-31934-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308419348-31934-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1308419348-31934-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 18 Jun 2011 17:49:24 +0000 (UTC) Use lstat instead of stat Signed-off-by: Aneesh Kumar K.V --- tools/kvm/virtio/9p.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index 209760b..3172c1a 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -227,7 +227,7 @@ static bool virtio_p9_open(struct p9_dev *p9dev, struct p9_msg *msg, struct p9_fid *new_fid = &p9dev->fids[topen->fid]; struct stat st; - if (stat(new_fid->abs_path, &st) < 0) + if (lstat(new_fid->abs_path, &st) < 0) return false; st2qid(&st, &ropen->qid); @@ -274,7 +274,7 @@ static bool virtio_p9_create(struct p9_dev *p9dev, struct p9_msg *msg, fid->fd = open(fid->abs_path, omode2uflags(mode) | O_CREAT, 0777); } - if (stat(fid->abs_path, &st) < 0) + if (lstat(fid->abs_path, &st) < 0) return false; st2qid(&st, &rcreate->qid); @@ -308,7 +308,7 @@ static bool virtio_p9_walk(struct p9_dev *p9dev, struct p9_msg *msg, /* Format the new path we're 'walk'ing into */ sprintf(tmp, "%s/%.*s", fid->path, str->len, (char *)&str->str); - if (stat(rel_to_abs(p9dev, tmp, full_path), &st) < 0) + if (lstat(rel_to_abs(p9dev, tmp, full_path), &st) < 0) break; st2qid(&st, &rwalk->wqids[i]); @@ -344,7 +344,7 @@ static bool virtio_p9_attach(struct p9_dev *p9dev, struct p9_msg *msg, for (i = 0; i < VIRTIO_P9_MAX_FID; i++) p9dev->fids[i].fid = P9_NOFID; - if (stat(p9dev->root_dir, &st) < 0) + if (lstat(p9dev->root_dir, &st) < 0) return false; st2qid(&st, &rattach->qid); @@ -421,7 +421,7 @@ static bool virtio_p9_read(struct p9_dev *p9dev, struct p9_msg *msg, while (cur) { u32 read; - stat(rel_to_abs(p9dev, cur->d_name, full_path), &st); + lstat(rel_to_abs(p9dev, cur->d_name, full_path), &st); read = virtio_p9_fill_stat(p9dev, cur->d_name, &st, rstat); rread->count += read; @@ -453,7 +453,7 @@ static bool virtio_p9_stat(struct p9_dev *p9dev, struct p9_msg *msg, struct p9_fid *fid = &p9dev->fids[tstat->fid]; u32 ret; - if (stat(fid->abs_path, &st) < 0) + if (lstat(fid->abs_path, &st) < 0) return false; ret = virtio_p9_fill_stat(p9dev, fid->path, &st, rstat);