From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48532 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4Rtg-0003tY-Jt for qemu-devel@nongnu.org; Tue, 29 Mar 2011 01:55:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4Rtf-0008MN-0G for qemu-devel@nongnu.org; Tue, 29 Mar 2011 01:55:19 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:37286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4Rte-0008Lj-FC for qemu-devel@nongnu.org; Tue, 29 Mar 2011 01:55:18 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp08.au.ibm.com (8.14.4/8.13.1) with ESMTP id p2T5o6cU014114 for ; Tue, 29 Mar 2011 16:50:06 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2T5tAKQ2015412 for ; Tue, 29 Mar 2011 16:55:12 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2T5tAlk001646 for ; Tue, 29 Mar 2011 16:55:10 +1100 From: "M. Mohan Kumar" Date: Tue, 29 Mar 2011 11:25:05 +0530 References: <1300418881-20972-1-git-send-email-mohan@in.ibm.com> <1300418881-20972-14-git-send-email-mohan@in.ibm.com> <20110328210642.GA11316@stefanha-thinkpad.localdomain> In-Reply-To: <20110328210642.GA11316@stefanha-thinkpad.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103291125.06164.mohan@in.ibm.com> Subject: [Qemu-devel] Re: [V9 PATCH 13/13] virtio-9p: Chroot environment for other functions List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org Thanks Stefan. I will send next version with incorporating your suggestions. > dpath is leaked in the success case. I suggest writing the function like > this: static int get_dirfd(FsContext *fs_ctx, const char *path) > { > int fd; > char *dpath; > char *last_component; > > /* path can not contain ".." */ > last_component = strrchr(path, '/'); > if (last_component && !strcmp(last_component, "/..")) { > error_report("9p path request contains \"..\": %s\n", path); > errno = EFAULT; > return -1; > } > dpath = qemu_strdup(path); > fd = passthrough_request(fs_ctx, NULL, dirname(dpath), 0, NULL, > T_OPEN); qemu_free(dpath); > if (fd < 0) { > errno = -fd; > fd = -1; > } > return fd; > } Ok, I will rewrite the function as you mentioned. > > > -static int local_utimensat(FsContext *s, const char *path, > > - const struct timespec *buf) > > +static int local_utimensat(FsContext *fs_ctx, const char *path, > > + const struct timespec *buf) > > > > { > > > > - return qemu_utimensat(AT_FDCWD, rpath(s, path), buf, > > AT_SYMLINK_NOFOLLOW); + if (fs_ctx->fs_sm == SM_PASSTHROUGH) { > > + int fd, retval; > > + fd = passthrough_request(fs_ctx, NULL, path, > > + O_RDONLY | O_NONBLOCK | O_NOFOLLOW, NULL, > > T_OPEN); + if (fd < 0) { > > + errno = -fd; > > + return -1; > > + } > > + retval = futimens(fd, buf); > > + close(fd); > > + return retval; > > errno is clobbered here. I will fix it. ---- M. Mohan Kumar