From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuSHJ-00062N-5l for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:09:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuSHF-0005yi-ES for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:09:20 -0400 Received: from [199.232.76.173] (port=41456 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuSHF-0005yf-Ae for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:09:17 -0400 Received: from naru.obs2.net ([84.20.150.76]:45587) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuSHE-0002UD-U3 for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:09:17 -0400 Date: Thu, 16 Apr 2009 17:09:12 +0300 From: Riku Voipio Subject: Re: [Qemu-devel] linux-user: fix getcwd syscall Message-ID: <20090416140912.GG28127@kos.to> References: <87ab6ghhrc.fsf@lechat.rtp-net.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ab6ghhrc.fsf@lechat.rtp-net.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Arnaud Patard Cc: qemu-devel@nongnu.org Hi, You are right. This is what I get for only checking the manpage. Acked-By: Riku Voipio On Thu, Apr 16, 2009 at 03:04:23PM +0200, Arnaud Patard wrote: > > The patch called "prefer glibc over direct syscalls" (commit 7118) has > replaced the getcwd syscall with a call to the glibc. With this change, > the syscall is returning -1 in error case and 0 otherwise. > This is problematic as the sys_getcwd syscall should return the number > of bytes written to the buffer including the '\0'. > > Signed-off-by: Arnaud Patard > --- > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 74b41a8..f5875aa 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -293,7 +293,7 @@ static int sys_getcwd1(char *buf, size_t size) > /* getcwd() sets errno */ > return (-1); > } > - return (0); > + return strlen(buf)+1; > } > > #ifdef CONFIG_ATFILE -- "rm -rf" only sounds scary if you don't have backups