From nobody Tue Feb 10 07:57:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527839873328476.85056770835047; Fri, 1 Jun 2018 00:57:53 -0700 (PDT) Received: from localhost ([::1]:47952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOewZ-0000kJ-Gr for importer@patchew.org; Fri, 01 Jun 2018 03:57:51 -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) 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) 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-Google-Smtp-Source: ADUXVKJY0xVmNPsifp4SYJE93MDdX1NDmYqM/iOvpsoPW4XdBIbXe1s3atI9zlC/PQAnuAIoItEMfg== X-Received: by 2002:a62:7105:: with SMTP id m5-v6mr9628674pfc.167.1527838290475; Fri, 01 Jun 2018 00:31:30 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 127 +++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 47 deletions(-) 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 =20 +IMPL(acct) +{ + if (arg1 =3D=3D 0) { + return get_errno(acct(NULL)); + } else { + char *fn =3D lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_PATH(ret, fn, acct(fn)); + ret =3D get_errno(ret); + unlock_user(fn, arg1, 0); + return ret; + } +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8529,6 +8547,21 @@ IMPL(pause) } #endif =20 +#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 =20 +IMPL(times) +{ + struct tms tms; + abi_long ret =3D get_errno(times(&tms)); + if (arg1) { + struct target_tms *tmsp + =3D lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0= ); + if (!tmsp) { + return -TARGET_EFAULT; + } + tmsp->tms_utime =3D tswapal(host_to_target_clock_t(tms.tms_utime)); + tmsp->tms_stime =3D tswapal(host_to_target_clock_t(tms.tms_stime)); + tmsp->tms_cutime =3D tswapal(host_to_target_clock_t(tms.tms_cutime= )); + tmsp->tms_cstime =3D tswapal(host_to_target_clock_t(tms.tms_cstime= )); + } + if (!is_error(ret)) { + ret =3D host_to_target_clock_t(ret); + } + return ret; +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8672,6 +8726,21 @@ IMPL(umount) } #endif =20 +#ifdef TARGET_NR_umount2 +IMPL(umount2) +{ + char *p =3D lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret =3D 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; =20 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 =3D get_errno(times(&tms)); - if (arg1) { - tmsp =3D lock_user(VERIFY_WRITE, arg1, sizeof(struct targe= t_tms), 0); - if (!tmsp) - return -TARGET_EFAULT; - tmsp->tms_utime =3D tswapal(host_to_target_clock_t(tms.tms= _utime)); - tmsp->tms_stime =3D tswapal(host_to_target_clock_t(tms.tms= _stime)); - tmsp->tms_cutime =3D tswapal(host_to_target_clock_t(tms.tm= s_cutime)); - tmsp->tms_cstime =3D tswapal(host_to_target_clock_t(tms.tm= s_cstime)); - } - if (!is_error(ret)) - ret =3D host_to_target_clock_t(ret); - } - return ret; - case TARGET_NR_acct: - if (arg1 =3D=3D 0) { - ret =3D get_errno(acct(NULL)); - } else { - if (!(fn =3D lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - TRY_INTERP_PATH(ret, fn, acct(fn)); - ret =3D get_errno(ret); - unlock_user(fn, arg1, 0); - } - return ret; -#ifdef TARGET_NR_umount2 - case TARGET_NR_umount2: - if (!(p =3D lock_user_string(arg1))) - return -TARGET_EFAULT; - ret =3D 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[] =3D { #ifdef TARGET_NR_access [TARGET_NR_access] =3D impl_access, #endif + [TARGET_NR_acct] =3D impl_acct, #ifdef TARGET_NR_alarm [TARGET_NR_alarm] =3D impl_alarm, #endif @@ -13003,6 +13026,12 @@ static impl_fn * const syscall_table[] =3D { #endif #ifdef TARGET_NR_pause [TARGET_NR_pause] =3D impl_pause, +#endif +#ifdef TARGET_NR_pipe + [TARGET_NR_pipe] =3D impl_pipe, +#endif +#ifdef TARGET_NR_pipe2 + [TARGET_NR_pipe2] =3D impl_pipe2, #endif [TARGET_NR_read] =3D impl_read, #ifdef TARGET_NR_rename @@ -13027,9 +13056,13 @@ static impl_fn * const syscall_table[] =3D { #ifdef TARGET_NR_time [TARGET_NR_time] =3D impl_time, #endif + [TARGET_NR_times] =3D impl_times, #ifdef TARGET_NR_umount [TARGET_NR_umount] =3D impl_umount, #endif +#ifdef TARGET_NR_umount2 + [TARGET_NR_umount2] =3D impl_umount2, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] =3D impl_unlink, #endif --=20 2.17.0