From patchwork Sun May 19 20:37:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164555 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4811774ili; Sun, 19 May 2019 14:27:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsdZ7UrZNJe0+VrPffqdr4I7rY3tU+EQrPHJ6nAZIzFDg7e3wa/PkWG1LzhoG+8nHRnsOB X-Received: by 2002:a50:d791:: with SMTP id w17mr71090078edi.223.1558301247875; Sun, 19 May 2019 14:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301247; cv=none; d=google.com; s=arc-20160816; b=sFzpJ1wFPIqevKXIL2/oaSfyHWfA/6Hk/EfJ0j4O+MKjumxL2QOxSUTfjFVoYAXGEu P59KQoYVuiKjksbNFJOLUBxSjCHL0guMOBA9u8Iu7bFGesO5NxkV9IRQJyfq19iK7ICp LRoOt9GiO33gEYOaMwh5SJmuoPadTID1zfWErtwxgL2FyV5LqmBmyoIXHbdZzx8L/HHC ssqZCCi6nigeakWq40dw06bCOvPP99oJuKnPdzLupoHPDCiUMUgeyTzoSjgR9kifq/8x S5+3i+q5cfj3IhcjZt/ci4WJuVx/zTibBXr9BKzS9nXXRevxRWTLI8wY+JY6ORc3veT5 /pEQ== 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=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=01WACL172u/Mk5FusQIyfWmmMO+kaDPMTctxRH5RxTrPUQzwPFnan+lEffUaqsNCCx 1a+u4/rgZ125QEr7GWnZ2pE+jD893j5q3c719ctWGqavnzc4Dum1pvgmMQO/EjcvSIQr Y4wUZhHWwd+dO1MufG4uKMgS4wzYSBiKIB4gyFTmMM9R2mzKQCBKRlbywrDSGFt11cWL ZpASZdTmbvEvDloGxOBREBp8nIT+Q4SabskW4YKqDRXhWQMXqrDM8Dw/uCbpHeRPm8oB iqTjurpjpCZGRflRwL37poUaR+lHPV1YR2ECGHlQTUewPaA1guy/1+KgyjdFbL9SNHBl gUtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zyt1ejbO; 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 g40si5206066eda.344.2019.05.19.14.27.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:27:27 -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=Zyt1ejbO; 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]:53848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTL4-0004Xc-Lm for patch@linaro.org; Sun, 19 May 2019 17:27:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaA-000470-3A for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa8-00054w-US for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:58 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa8-00054H-OA for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:56 -0400 Received: by mail-pf1-x441.google.com with SMTP id g3so6171976pfi.4 for ; Sun, 19 May 2019 13:38:56 -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=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=Zyt1ejbOQKCVf+XkZU0o42hrxBobvNvTQ5mQdNaqW8Z7iXyO8kgx8f55V6lr4b9tp8 dFcwC+paPo2Agj1uHZ6Bwdp+X21fNY9b5fSZKIGI3prnirUeVqwZFqx2L9BHux6OhyKs r5/S1/gMGxYO9PMTRgCLahsMbOtFD0Kl3OduRsVU3rARg+dKPboZrvPS3sxQJsJU9NfT R2s4P0um+Z1SE8vKLOQf0ynfTpo4HtvPjPBXfHxg+q2dgGV5iIBBbqwbmr4U1Riiv6tF gQMnwJo5ajOpVUFqoBvkWjp/Smmjd8w5bDWafbCll4HOmuH0n9Lo+kv6zUJKu7/Euw/T orbQ== 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=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=eIah9cSOUCQaF8m29ZyH7kB8n1dtoKwFe8V4ffS7BDP498vkPZG8OdwvCgnSKCg8WM 2rQxaqPvyJzQaGVrPnwm9O6UkIZSelBPStgTVZ1w95DORRBHuyr31QnNwLwzNwefpF0A 1FVDg6r4ixnGI4KRAaw4pmJ1UIcPsH/ITnGWTZufNv+rj1zehJC2RB+5m1I1E6p/tk/F DGM21esxUmcZVzHKQatxDIy4oFG6UJaxNXo3epCCXZg4mjN7gdDnJQMD3VlX7EOd+5Xg r9nq9erUpr5T8HzgctvOLvvprzmtTcCUIEcA60sfYqoZ4WWbNXg9N/xfn1h7Bd/O6QjM F6lQ== X-Gm-Message-State: APjAAAVraEhEjyT4vXUrz8/SSuSRP04hUbPW3QbCgBNUDHoejDeQTFpn HAdrcruKB5LPfaS2yqhUO/IRvkpGZdY= X-Received: by 2002:a63:6ac1:: with SMTP id f184mr72586068pgc.25.1558298335548; Sun, 19 May 2019 13:38:55 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:22 -0700 Message-Id: <20190519203726.20729-71-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 70/74] linux-user: Split out symlink, symlinkat 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-defs.h | 4 ++++ linux-user/strace.c | 27 --------------------------- linux-user/syscall-file.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 30 ------------------------------ linux-user/strace.list | 6 ------ 5 files changed, 32 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index c179f69d9f..5625c268c3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -279,6 +279,10 @@ SYSCALL_DEF(ssetmask, ARG_HEX); #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif +#ifdef TARGET_NR_symlink +SYSCALL_DEF(symlink, ARG_STR, ARG_STR); +#endif +SYSCALL_DEF(symlinkat, ARG_STR, ARG_ATDIRFD, ARG_STR); SYSCALL_DEF(sync); SYSCALL_DEF(syncfs, ARG_DEC); #ifdef TARGET_NR_time diff --git a/linux-user/strace.c b/linux-user/strace.c index 669eca7fa6..97755458d3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1563,33 +1563,6 @@ print_statfs64(const struct syscallname *name, } #endif -#ifdef TARGET_NR_symlink -static void -print_symlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_string(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_symlinkat -static void -print_symlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_at_dirfd(arg1, 0); - print_string(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utimensat static void print_utimensat(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 0a25d39d28..e3749f0fb4 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -1254,6 +1254,34 @@ SYSCALL_IMPL(select) } #endif +static abi_long do_symlinkat(abi_ulong guest_target, int dirfd, + abi_ulong guest_path) +{ + char *target = lock_user_string(guest_target); + char *path = lock_user_string(guest_path); + abi_long ret = -TARGET_EFAULT; + + if (target && path) { + ret = get_errno(symlinkat(target, dirfd, path)); + } + unlock_user(path, guest_path, 0); + unlock_user(target, guest_target, 0); + + return ret; +} + +#ifdef TARGET_NR_symlink +SYSCALL_IMPL(symlink) +{ + return do_symlinkat(arg1, AT_FDCWD, arg2); +} +#endif + +SYSCALL_IMPL(symlinkat) +{ + return do_symlinkat(arg1, arg2, arg3); +} + SYSCALL_IMPL(sync) { sync(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6355fd62d8..fccf9ee184 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4158,36 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_symlink - case TARGET_NR_symlink: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(symlink(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_symlinkat) - case TARGET_NR_symlinkat: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg3); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(symlinkat(p, arg2, p2)); - unlock_user(p2, arg3, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 1bb9224b5e..d9db80335d 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1122,12 +1122,6 @@ #ifdef TARGET_NR_swapon { TARGET_NR_swapon, "swapon" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_symlink -{ TARGET_NR_symlink, "symlink" , NULL, print_symlink, NULL }, -#endif -#ifdef TARGET_NR_symlinkat -{ TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL }, -#endif #ifdef TARGET_NR_syscall { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL }, #endif