From patchwork Sun Jun 10 03:00:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138090 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2579807lji; Sat, 9 Jun 2018 20:13:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLjOA1NoZyBTmrYgTFLBmYexw9qgkIfjignCgVOf1MIPetaKN/raqOnbdR0+vDhd7GGwcCi X-Received: by 2002:ac8:34f1:: with SMTP id x46-v6mr11505078qtb.135.1528600410558; Sat, 09 Jun 2018 20:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600410; cv=none; d=google.com; s=arc-20160816; b=GFriRmVEvO0M751dbyFVTh33E9yae5yNj9q+hy0Z92PZ5SSPdmKSAx2CunhZpzrRFt PzB1d1qYMZv6FWUCgSZ+z5ySiNb903uLEu+I0eK8vxOVfZBw42+LWlD3dhfWgZsoeSBN 4f88CWxcYl1sycWrRVXQ4aqaZ523t3cCWYrpaMWzrpbx/qzh5g3S1YkpMsHsFCHf/0Ei tDQ3+/Z5KLRC3dkj3Tpa1f1h34xl0ZvoHc78VR+UxuWR08ZHqtSee8O1DVR9jmalg2ul ORo8eB23RRsm95QWiJcW5U6Hn21F6HwKpXTzVsHPS/Ytz7ulKiBVG3RFTLbM5l6pmzxQ 1isQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=GZWeSzVeu+/RRjESUks5vM0yXb5/4jRWzaICM7z2twiT7UZM5j7JR/7NPj0Tu5U4vV Lf51shLXX60DmohmQ3MgtUP3dknawLu0a3JueYjTFyXhGv96/eQP9SZwije0ylzHynWd KgXnRwhx77UCnKuHWlEmHeHUa/unEG7b0p5uqYmrynU7/59EHYhKXpmw6gqe+dCPmpC5 cOlMMANlJewZOG/8sChwQscqz82L6cfMGudLTQNG5o67RNOEynW4ygp7/sxyZG1mLxj0 hFuOC5572DbnzcY9/oxZ9YzaRmIzHQH5VcfipllaWPEwNp2fWmnp8omDbs73CeJMs/Qq jEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4EK7bmY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p184-v6si7067271qkb.380.2018.06.09.20.13.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:13:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4EK7bmY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqnJ-0002y3-Un for patch@linaro.org; Sat, 09 Jun 2018 23:13:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdI-000228-7y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdF-0003J1-4d for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:08 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:40842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdE-0003Il-Uj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:05 -0400 Received: by mail-pg0-x244.google.com with SMTP id l2-v6so8127232pgc.7 for ; Sat, 09 Jun 2018 20:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=C4EK7bmYqV+Z3HBBCYUJvqXlBdYQZsutLYX9OPa1RgHSZcdIg71SzItmVsg+i3DE3C qiTrnqQHXC9NvMxggZvhesevyumeGTMt6gzjMODrShzmEd5761ZJM75Nd6lZyvnIalFS ue1tn4PVT5GZH6Dc0dsBSpd4XkUVCUgvlVtes= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=KbCM8d30OURV3VY5AD+23djlsfsh/3oGJ1Y4rzfPghHft8SXNT0yxag0BnPDvmtrhj 3kqL6ZgmFz45nRn6Ydkd4c+BM436Nolk5bCdTjcSObOXJ3sH4w9K7uLtx0CVCZlMrd7M C+ad4Ui5pAXEBRh0REk3ydON5XP98mSTefuyUH3IiCA5ZA/y6A025Ydu/cVLnfz+Vdus gncyAvmJjF1tmL52o8F8vEpdqUswrfSqtw7mf5JdQpTkhFzSgsipLo4kK7I5dbbO+eHB lHphB3Uj5CTxIsB0xGLTp5OlX4kRO/F9QrEfivIV38ftiGYrnYDP/Ty/BQP6y/+fNzUy RecA== X-Gm-Message-State: APt69E2VpJTJwuUA+oPa4584L5L3vM1cbW/V4H4B+jdP5A+wE+mcjSeK iOOXmbTuJTzsMMqlBz8ljfm650axnDo= X-Received: by 2002:a63:721d:: with SMTP id n29-v6mr10165931pgc.194.1528599783655; Sat, 09 Jun 2018 20:03:03 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:50 -1000 Message-Id: <20180610030220.3777-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 018/108] linux-user: Split out chdir, mknod, mknodat, time, chmod X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets define mknodat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 121 ++++++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e1b3c7e827..d32034ce38 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7876,6 +7876,34 @@ IMPL(brk) return do_brk(arg1); } +IMPL(chdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chdir(p)); + unlock_user(p, arg1, 0); + return ret; +} + +#ifdef TARGET_NR_chmod +IMPL(chmod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chmod(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(close) { fd_trans_unregister(arg1); @@ -8082,6 +8110,34 @@ IMPL(linkat) return ret; } +#ifdef TARGET_NR_mknod +IMPL(mknod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknod(p, arg2, arg3)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +IMPL(mknodat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8227,6 +8283,18 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_time +IMPL(time) +{ + time_t host_time; + abi_long ret = get_errno(time(&host_time)); + if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8328,48 +8396,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_chdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chdir(p)); - unlock_user(p, arg1, 0); - return ret; -#ifdef TARGET_NR_time - case TARGET_NR_time: - { - time_t host_time; - ret = get_errno(time(&host_time)); - if (!is_error(ret) - && arg1 - && put_user_sal(host_time, arg1)) - return -TARGET_EFAULT; - } - return ret; -#endif -#ifdef TARGET_NR_mknod - case TARGET_NR_mknod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(mknod(p, arg2, arg3)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_mknodat) - case TARGET_NR_mknodat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(mknodat(arg1, p, arg3, arg4)); - unlock_user(p, arg2, 0); - return ret; -#endif -#ifdef TARGET_NR_chmod - case TARGET_NR_chmod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chmod(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_lseek: return get_errno(lseek(arg1, arg2, arg3)); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) @@ -12508,6 +12534,10 @@ static impl_fn *syscall_table(unsigned num) */ SYSCALL(brk); SYSCALL(close); + SYSCALL(chdir); +#ifdef TARGET_NR_chmod + SYSCALL(chmod); +#endif #ifdef TARGET_NR_creat SYSCALL(creat); #endif @@ -12520,6 +12550,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(link); #endif SYSCALL(linkat); +#ifdef TARGET_NR_mknod + SYSCALL(mknod); +#endif + SYSCALL(mknodat); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12531,6 +12565,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open_by_handle_at); #endif SYSCALL(read); +#ifdef TARGET_NR_time + SYSCALL(time); +#endif #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif