From patchwork Fri Jun 1 07:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137491 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp623316lji; Fri, 1 Jun 2018 00:58:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPGgwXFSikizQSz9P6v0b1Vmgz0GBLhJE2IicSKy+eUjDc1kt9RA8xjJGl1sHYgsl6py5l X-Received: by 2002:a37:cf0a:: with SMTP id e10-v6mr9602027qkj.37.1527839920258; Fri, 01 Jun 2018 00:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839920; cv=none; d=google.com; s=arc-20160816; b=xHam/bVJ2YAlfOYmRtL56Dhl5MWbtqfAJrkJSv18k6NdZ/H7ufynJfq+KZgErw0PVb cH1o27HDlexdMKGRrXfrD8xb0v9hdwdMi4BuGMWcJPty1OPWTl3AUWxGfiIQAmmLEVz/ BnG0R0v4OLf9Ciwqqr1jqHg3VSyNywzA1Sz6l4yYtUQHzLwPERIFWLMCwQyYd53KdrUN n7qT7eGZ9YLZwMt3JFPrEIlYTsrBUzmFsJhfPVVvgSr8IKXxV4yDQ08digETRRUipYKN y356X/VmLD2XLDRiSOhBt1w5oeOWQy8CYxNPKFbnUcpYOrOLniYJ06iD6maZmH9iAh8L YGnQ== 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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=bxIEjjbh/O0RUrXH21ap1hcsUCvqhLQ9iujdrlBezsBvdfkk0d/s4y6B5bzGPKWgfY KcLmrD7rlMh6YkuWIV9YG7N9nqcm/T0cCbJ4GVBBFxj1bGoI2rreMivHPLUszQYnadws 6UCe6nWLVHyi8fnd2B9p5BBVtGD2VD2jnBOllqF02gXAa//1cHBGeeqjjwip6kQOpape Fq6/F/tunsIXgJfVRwyBkvRCDDS3WUtbtKYO2yfr+LFMdmCpfCn7c9wmh/DqlsyyOOXQ tEVx4ogQ29vUzZNnzyPYUWKfLMiw82KmYmxcSSo855/u1Saa+tTP2ucBwtBDEk8BIHPn Mwng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Egh3/7ko; 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 v129-v6si515926qka.94.2018.06.01.00.58.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:58:40 -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=Egh3/7ko; 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]:47967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOexL-0001rg-JA for patch@linaro.org; Fri, 01 Jun 2018 03:58:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX7-0005pr-3W for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX6-0000lk-0N for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:33 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:39793) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX5-0000kx-P3 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:31 -0400 Received: by mail-pf0-x229.google.com with SMTP id r11-v6so4527377pfl.6 for ; Fri, 01 Jun 2018 00:31:31 -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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=Egh3/7kon8yiVu6LiIu1j/4o5BAu3FPTlhzQw8bsEVNDuxotkj8OX8A8eAZeCkuk5D rI7gZylV50FsAZIBaKYExZ9mUgBdie1Nh6Z556TY/EeQmTva9Wul4M3AXT0yVV3zpAMA yL4T2xY867Ba5k0yzcEXJdyu+h43dLDM1YYmk= 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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=jb90JRRmgqaqGmuNtW6qmdX58b5ZRzC6PrZfxpz28LzXunKHYSbTGAYRh0jaB/pPog VDNSti/AWJe/SW+JTZffCxfeIMmEmHual6wcjBCSHDOT8pVOdF8DsApKtgX6Ukow/Qph WhO7bnh5Rc3KDDMZgt2J46L7wod2QjVOYw2e4+7coVwGmGiq6T9MAlMBwWjhutzHpiPc MHggyfJUUHsPdKIrQF9EfVqtAAbPVSHDOqqh2ovs/9BbvplYwnxidyY+mpTfe7Nki5en PWFo3d4c0qnV3jGFyBVxBP5tjz/IeIln2gTWZLmSWVZ8/hJI2WkY105afuAkgvZAiqRN 15aA== X-Gm-Message-State: ALKqPwcrzjk4LAJQ4YvkyACrznJytKnhAiAUtL69zNIximtxRT9ddxg3 LrHoUNZ6Uye1/KMBE2hThaPGfnpHsBE= X-Received: by 2002:a62:7105:: with SMTP id m5-v6mr9628674pfc.167.1527838290475; Fri, 01 Jun 2018 00:31:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:43 -0700 Message-Id: <20180601073050.8054-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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:c00::229 Subject: [Qemu-devel] [PATCH 26/33] linux-user: Split out acct, pipe, pipe2, times, umount2 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 127 +++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 47 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36092d753d..bde1f9872f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7912,6 +7912,24 @@ IMPL(access) } #endif +IMPL(acct) +{ + if (arg1 == 0) { + return get_errno(acct(NULL)); + } else { + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_PATH(ret, fn, acct(fn)); + ret = get_errno(ret); + unlock_user(fn, arg1, 0); + return ret; + } +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8529,6 +8547,21 @@ IMPL(pause) } #endif +#ifdef TARGET_NR_pipe +IMPL(pipe) +{ + return do_pipe(cpu_env, arg1, 0, 0); +} +#endif + +#ifdef TARGET_NR_pipe2 +IMPL(pipe2) +{ + return do_pipe(cpu_env, arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); +} +#endif + IMPL(read) { abi_long ret; @@ -8657,6 +8690,27 @@ IMPL(time) } #endif +IMPL(times) +{ + struct tms tms; + abi_long ret = get_errno(times(&tms)); + if (arg1) { + struct target_tms *tmsp + = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); + if (!tmsp) { + return -TARGET_EFAULT; + } + tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); + tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); + tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); + tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); + } + if (!is_error(ret)) { + ret = host_to_target_clock_t(ret); + } + return ret; +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8672,6 +8726,21 @@ IMPL(umount) } #endif +#ifdef TARGET_NR_umount2 +IMPL(umount2) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount2(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8831,53 +8900,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_pipe - case TARGET_NR_pipe: - return do_pipe(cpu_env, arg1, 0, 0); -#endif -#ifdef TARGET_NR_pipe2 - case TARGET_NR_pipe2: - return do_pipe(cpu_env, arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); -#endif - case TARGET_NR_times: - { - struct target_tms *tmsp; - struct tms tms; - ret = get_errno(times(&tms)); - if (arg1) { - tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); - if (!tmsp) - return -TARGET_EFAULT; - tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); - tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); - tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); - tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); - } - if (!is_error(ret)) - ret = host_to_target_clock_t(ret); - } - return ret; - case TARGET_NR_acct: - if (arg1 == 0) { - ret = get_errno(acct(NULL)); - } else { - if (!(fn = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - TRY_INTERP_PATH(ret, fn, acct(fn)); - ret = get_errno(ret); - unlock_user(fn, arg1, 0); - } - return ret; -#ifdef TARGET_NR_umount2 - case TARGET_NR_umount2: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(umount2(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl @@ -12937,6 +12959,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_access [TARGET_NR_access] = impl_access, #endif + [TARGET_NR_acct] = impl_acct, #ifdef TARGET_NR_alarm [TARGET_NR_alarm] = impl_alarm, #endif @@ -13003,6 +13026,12 @@ static impl_fn * const syscall_table[] = { #endif #ifdef TARGET_NR_pause [TARGET_NR_pause] = impl_pause, +#endif +#ifdef TARGET_NR_pipe + [TARGET_NR_pipe] = impl_pipe, +#endif +#ifdef TARGET_NR_pipe2 + [TARGET_NR_pipe2] = impl_pipe2, #endif [TARGET_NR_read] = impl_read, #ifdef TARGET_NR_rename @@ -13027,9 +13056,13 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif + [TARGET_NR_times] = impl_times, #ifdef TARGET_NR_umount [TARGET_NR_umount] = impl_umount, #endif +#ifdef TARGET_NR_umount2 + [TARGET_NR_umount2] = impl_umount2, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif