From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LwKY0-0002Zp-Tu for qemu-devel@nongnu.org; Tue, 21 Apr 2009 14:18:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LwKXz-0002ZI-Hl for qemu-devel@nongnu.org; Tue, 21 Apr 2009 14:18:19 -0400 Received: from [199.232.76.173] (port=41218 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LwKXz-0002ZF-Cj for qemu-devel@nongnu.org; Tue, 21 Apr 2009 14:18:19 -0400 Received: from naru.obs2.net ([84.20.150.76]:38601) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LwKXy-0005US-Lr for qemu-devel@nongnu.org; Tue, 21 Apr 2009 14:18:19 -0400 Date: Tue, 21 Apr 2009 21:18:16 +0300 From: Riku Voipio Subject: Re: [Qemu-devel] [PATCH] Fix utimensat (aka unbreak cp -a) Message-ID: <20090421181816.GC17579@kos.to> References: <878wlufm8s.fsf@lechat.rtp-net.org> <20090421123455.GA15170@kos.to> <49EDEFD4.9000707@opensuse.org> <49EDF679.70605@opensuse.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49EDF679.70605@opensuse.org> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Martin Mohring Cc: laurent.desnogues@gmail.com, qemu-devel@nongnu.org, Arnaud Patard On Tue, Apr 21, 2009 at 06:38:17PM +0200, Martin Mohring wrote: > > results in the invalid argutment error. I ll currently check which > > syscalls are involved here. > > the time of 1.1.1970 looks to me like a wrongly passed argument (of ==0). no, NULL is what is supposed to be passed. try stracing a normal host /bin/touch. > 27374 open("/var/log/wtmp",0x20941,0666) = 3 > 27374 dup2(3,0,3,0,0,1109324328) = 0 > 27374 close(3) = 0 > 27374 utimensat(0,"(null)",(nil),0) = 0 > 27374 close(0) = 0 > 27374 open("/var/run/utmp",0x20941,0666) = 0 > 27374 utimensat(0,"(null)",(nil),0) = -1 errno=22 (Invalid argument) It is unclear what svn revision you are using qemu, and/or if you are using any of the patches in this thread. The patch I sent earlier, should fix the invalid arg issue. As for the 1970 issue, try this patch. commit 7f7e93aabde6b8f0e4a1a05537145efa9ed0156b Author: Riku Voipio Date: Tue Apr 21 20:37:01 2009 +0300 linux-user: fix utimensat with NULL timespec Don't try to copy timespec from user if it is NULL. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e19e289..0049840 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6674,17 +6674,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) case TARGET_NR_utimensat: { - struct timespec ts[2]; - target_to_host_timespec(ts, arg3); - target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec)); + struct timespec *tsp, ts[2]; + if (!arg3) { + tsp = NULL; + } else { + target_to_host_timespec(ts, arg3); + target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec)); + tsp = ts; + } if (!arg2) - ret = get_errno(sys_utimensat(arg1, NULL, ts, arg4)); + ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); else { if (!(p = lock_user_string(arg2))) { ret = -TARGET_EFAULT; goto fail; } - ret = get_errno(sys_utimensat(arg1, path(p), ts, arg4)); + ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); unlock_user(p, arg2, 0); } }