From patchwork Fri Jan 18 21:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156074 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3742242jaa; Fri, 18 Jan 2019 13:53:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN43LF4irJ5RkVhRrhDDluLYb3IJzzcz5gfdLBhldgMbms89mQLjK5j+6XJdnlkpuFNfP4++ X-Received: by 2002:adf:b190:: with SMTP id q16mr18158629wra.95.1547848428061; Fri, 18 Jan 2019 13:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547848428; cv=none; d=google.com; s=arc-20160816; b=O3Rs8brea3fnFmIMQ8vm/cj1mp2kNMM5J2Ada9CWgiBIU0013jSzwC99O/X/yAvoqd Dogt6RCfMV1ZXAxihcmyicDQzTxIfFGifppV6MJIYEj+TVD+rbBlCouIC0xh/w3pMwEO cmnELRJN0p06FPFSN4qb4dJoiTI7mqOz6JIIKRrk5Hm9M+81J7v2tbCYgoh/ZaJbY/rz YEqAjnuxaEytSxmQTd/XNbrRRp0yeGXX/SOCzEkMkoV/2tkJVZOzR6So37aZQZ2mIyVf T18561atTSzt0oTCsKdQiD6sWWtnQjMdI/UGNlf4kovNT+ACuf+rjzP69XfBzD2HYoWl f6FA== 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=u8Rc++t84OpvMGiXblGmPrszhVLdnSkDh7cV8BTE/9A=; b=eSWSaJZER9c9/OekXBa+sxoDdQiydleouD1sjy7ozVVFafUjrM+0sf0Xv8VTUvLXCk lmXLAGsiLCrhzfOQKd28TXlCfOaJtvpTA+I2R9GTCSFLK64e6FVgKbvIPaRHuumNNF0a FA47IrhzH7vUo69s/va4AxZ3U5C18SM6+aNxKgVirSPW6w4PBkeQAoBL+dLB9HErbIBx VJp3FDr1YKhizr2ZemcFb6F4qA1y4FZvQwZwklYIXRTFLDZj6tc8PeyS116+bt86GBIp 3mVowk6MsbsEQ1Q8x8R/KeaqS+NcIBk0R38cYgb2kcs8nfOTkP+ydOT6jzGsadxMkxPG vciA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RpdDd2M6; 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 k62si30186610wmk.189.2019.01.18.13.53.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 13:53:48 -0800 (PST) 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=RpdDd2M6; 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]:47686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkc5D-0005hj-2d for patch@linaro.org; Fri, 18 Jan 2019 16:53:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbl8-0005gN-QJ for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbl6-0005Q0-Nq for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:02 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:36046) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbl6-0005NR-Hg for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:00 -0500 Received: by mail-pg1-x543.google.com with SMTP id n2so6650602pgm.3 for ; Fri, 18 Jan 2019 13:32:59 -0800 (PST) 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=u8Rc++t84OpvMGiXblGmPrszhVLdnSkDh7cV8BTE/9A=; b=RpdDd2M6oMxGt9vnVoJy8Tok0hvBw+LUR7oETEzhrB8Ab+fwvm9UlG/7XTDHNBWJZZ I29oHhcW7+N27mk44OJM2SlVCQtRsiYFSD/YbYCiRKd19NameqNx2AVFiAntSKWsyhEa /f8qrwj2Ag3uA4tBF7M75olxuBcE4U3sHSzZI= 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=u8Rc++t84OpvMGiXblGmPrszhVLdnSkDh7cV8BTE/9A=; b=JzB0J+DLbKu3yGGVmH8ZvXC7002Q5P78hftSLsA6+qJl9JtTRKNmzYdjeA5WL3A50x eZhW7HgQJGPly1yJN7XelqyNVgIII35AwvauXsgE9ILjeYpRbrs6//K77jeDmn1Tc4dl qth2z9M40DZ2y9iJvlX3MAp9WYE7vu0xPML+v+hRqFQPVX8+RZILviTW2hJCyJF3o/zj 6IfnOPtw9BwGPfTq00mEQreOJqjO+TGNCN9ScnsLguz5KykqXJ8FZIt5wyUikwNrXc5B H9LFVA6n4fBtu/EIArGNcDQVZTQlxa4Nf0nn6wru7SrnHWIxfind+p9FgN8OMUnChlBd qj0g== X-Gm-Message-State: AJcUukeh6pE17vdII+qYAta/B0pBpmtIXpY2oAVeBLdkrc/AnGpOI/zo AKglIQyZlqYpiBH8+FZ1DeRCfDBuwuU= X-Received: by 2002:a63:9f19:: with SMTP id g25mr19301741pge.327.1547847178178; Fri, 18 Jan 2019 13:32:58 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.32.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:12 +1100 Message-Id: <20190118213122.22865-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-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::543 Subject: [Qemu-devel] [PATCH v6 39/49] 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.2 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 3111abd861..80dec33971 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -867,6 +867,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 351b2a6288..6668e4ada8 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 TARGET_NR_llseek TARGET_NR__llseek #endif +/* + * These definitions produce an ENOSYS from the host kernel. + * Performing a bogus sysacll is lazier than boilerplating + * the replacement functions here in C. + */ +#ifndef __NR_syncfs +#define __NR_syncfs -1 +#endif + #ifdef __NR_gettid _syscall0(int, gettid) #else @@ -264,11 +273,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, }, @@ -5327,13 +5338,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 aaea23d433..56f25c15b7 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