From patchwork Sun May 19 20:36:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164519 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4792134ili; Sun, 19 May 2019 14:00:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOLZUwz/q96C722z1FZ1P9RoLEfzzRqUzDlHYnRnbJ5T7eqnuUSbrtvNBcWcuLQJOqMgW7 X-Received: by 2002:a50:9025:: with SMTP id b34mr71499864eda.145.1558299641507; Sun, 19 May 2019 14:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299641; cv=none; d=google.com; s=arc-20160816; b=uWPYr7PIjahMK1cjWHZoR9i1k0Zm8CpBNy+JbulEeQNrRLbQmSARs06PkVluez9suH ruTskYrZN1TZ5FUssMHZ70VfR9CL7MEYazkvzJhutjtVpSRAxw6TZLS7ZvDjx3emd1Sv 9b/2IR5EGHRuIRVqJhy3wb0Q1+KjP2M9XDv99FxpNd5k/n1MtL2l0xi7zB5j4Gt3howf tYglgFSfVCQkxUZCTkKB+I7Ys1funOLuIg1KrtEOG2mwrywenl553CWAd7Cv385fcPDq HLa4QlMAb2mgB3FNE3b7f6mywL2bbBwFaMbWrdw4B3aLtLwFFAxEwJ9HrHTQNxpLLjAU ptGQ== 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; bh=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=0HbR3v18BJ4IR4ms2qPD0VFC8LGsVuITdhfHS8izkxHGFDZUjdxXbnSWpmk1WHNLwA Ay5KCYnEtpYIF2MRBBkEg7xq5a+Fi31cpYCNrMmVIY/gUXRfqj1p3WwpUMFSquEAfyN6 h4zO98kxTgBd/ufm0k1piCONU1DCdZ2SSmfOLW9YrZvMP6bGidBPtpZsTv5Zqd7IH0kY fRibRLclrD9MTaEURQd0nikEfQfX1+osRI1RMMOvllcuYRhK6TqjWGjz/e6WUGRkKpdC WD1ep7V5VR/UmIAi2Cb+1pCyCHBVNhyIPNC79Yh5nbZIdsxVzRVFIyocPRhnXwfwGyaj vo+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcrrAraR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id t45si11754027eda.235.2019.05.19.14.00.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcrrAraR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:53443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSvA-00056s-FN for patch@linaro.org; Sun, 19 May 2019 17:00:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZe-0003eR-CE for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004P4-1T for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZZ-0004He-7N for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: by mail-pf1-x441.google.com with SMTP id g3so6171662pfi.4 for ; Sun, 19 May 2019 13:38:19 -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=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=VcrrAraR3P2FH/TyydTN4gf6E4HL1lu8TIAS/7Mfkdzh/z9NZK0sA3XGseQhRyAA49 Ey4Pr9FJa5//qsilaJ0hI2O7uNITkYxutxP3x2SIah5gCZuxQeBsr0ZWXFnd5eJNKrGQ takqHHTh/tdqUWu8L4TAusVtB3bUTNT89F1kOzFbAbSJWkJEv+/6kXlBoW/dLvpQDIz4 K7DUhFUwpgZpzFkOs/wzOchMC4wj+iytwdiEICeY/DiEJSrVDSkxdmnhJ/ebgXlR++wR zcARnZSYAJZNbN4sRfaRwgJGyExFOJGMJpytcTl75zpYahzn3bie6Gzicem/DfiUpgzS /KNw== 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=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=nWfkZYs0OSfe2NJKuorfY/otK9SL56bQprnm8fwPwvmXvffPM8mhpRs2MoZuY882Bz zIZw/AI0EfcXESNGW7NTbaB+LM/sb68dnUHKZY+2kriwgj2Iwcc5VcSCYpJqS0ScEfWB /YtdFH5pMLo7Wxt4y28B58Y/5q1Ss24o/4U1Eb7WH/ghGXdHBEyKocJ3l2HmGpWZWPv+ WkzFb0durPic9Nwtvj7jaw5ZhtfRA4a8kNoj/+Jv7tMTwil/KZTO7hrODNGPWH990nUR uBd4JYde0PK2SHgrYw5WoXILBUb0t/tIZJX7UNXR+Ey+a8l6DeXAN4+8hrapNwtJajmH T/LQ== X-Gm-Message-State: APjAAAUaRoIo1OdXXGZzN0QrEMHiScVx5H0Zqck1ZjCsjYrIJHZpoC1H iSA1k29InSKAq5lOUM06lXsvwFmvl5g= X-Received: by 2002:a63:2124:: with SMTP id h36mr70764891pgh.186.1558298298098; Sun, 19 May 2019 13:38:18 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:50 -0700 Message-Id: <20190519203726.20729-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 38/74] linux-user: Split out sync, syncfs 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" Note that syncfs is universally available. If !CONFIG_SYNCFS, provide our own syscall replacement. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-file.inc.c | 11 +++++++++++ linux-user/syscall.c | 20 ++++++++++++-------- linux-user/strace.list | 6 ------ 4 files changed, 25 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 860754aaca..497fbdba66 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -171,6 +171,8 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif +SYSCALL_DEF(sync); +SYSCALL_DEF(syncfs, ARG_DEC); #ifdef TARGET_NR_time SYSCALL_DEF(time, ARG_PTR); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 5e276d13bc..9f3cf7221a 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -873,6 +873,17 @@ SYSCALL_IMPL(readlinkat) } #endif +SYSCALL_IMPL(sync) +{ + sync(); + return 0; +} + +SYSCALL_IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} + static abi_long do_umount2(abi_ulong target_path, int flags) { char *p = lock_user_string(target_path); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6d30e8ff2f..d612dade23 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -199,6 +199,15 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_gettid __NR_gettid _syscall0(int, sys_gettid) +/* + * These definitions produce an ENOSYS from the host kernel. + * Performing a bogus syscall is easier than boilerplating + * the replacement functions here in C. + */ +#ifndef __NR_syncfs +#define __NR_syncfs -1 +#endif + /* For the 64-bit guest on 32-bit host case we must emulate * getdents using getdents64, because otherwise the host * might hand us back more dirent records than we can fit @@ -254,11 +263,13 @@ _syscall3(int, ioprio_set, int, which, int, who, int, ioprio) #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom) _syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) #endif - #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, unsigned long, idx1, unsigned long, idx2) #endif +#ifndef CONFIG_SYNCFS +_syscall1(int, syncfs, int, fd) +#endif static bitmask_transtbl fcntl_flags_tbl[] = { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, @@ -5380,13 +5391,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_sync: - sync(); - return 0; -#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) - case TARGET_NR_syncfs: - return get_errno(syncfs(arg1)); -#endif case TARGET_NR_kill: return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); #ifdef TARGET_NR_rename diff --git a/linux-user/strace.list b/linux-user/strace.list index 3161546afc..749bdce638 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1260,12 +1260,6 @@ #ifdef TARGET_NR_symlinkat { TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL }, #endif -#ifdef TARGET_NR_sync -{ TARGET_NR_sync, "sync" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_syncfs -{ TARGET_NR_syncfs, "syncfs" , "%s(%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_syscall { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL }, #endif