From patchwork Sun May 19 20:36:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164515 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789952ili; Sun, 19 May 2019 13:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/JCiUsQxZeOnr1zZRkQ3PfAC/s0mAc0ZDohOMUFXIsq2RVs4hvRvv1YNtkfzCdWUKbOah X-Received: by 2002:a50:add7:: with SMTP id b23mr70580574edd.215.1558299455430; Sun, 19 May 2019 13:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299455; cv=none; d=google.com; s=arc-20160816; b=uU6DBHA6wJaBGEfey3+toIVfrGrxK2nXPYg4ihiZzBa40sGreT8ODUQ4BW52MT5oqQ G1NvFgIYAQmYe8LyOSrrHwM9axXoLhKo22TC8N/EhClILhbr/R+EK+ZnXR1m1f+HXgSt WRQfAsYpsFJsZpavKYsdAv68Y2vYT/qso4iQS93XDLwi/4E9mbPwqPQZ9RoBthK+yUyg Z3bUkwzINAAJ49dXku9Gajr9s4k/oe054N+zMaYkzWY8FbiaSVAMBkiT9PS4zFMRcspX HN6cPMfjtJITkEv1HLXuThfQNqpoEx/d+TGRjP9tya7TUQckOgy46Dna1b4QBoNLkBys t3Vw== 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=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=qJfW/rRCwn5mKl2o+4ejJwWXIbw5YV6ZXfW65mExQj+Bso4UrXmMEx0/9cFna8azIe 1Fadqjr4/09hVseQdt25zbTN2auvCL4OveUDGiwfIxQA3hFObwSCZfaK3ajLevlEvKRw szCM1KOYm11g2t4FjM8MNounjBljMAp5auZobEVs+1B3Lnj2umm/0DHxiLQ+S4sTEQBI dSo0aJ//pfNmAXEbDUqdL/eIKKGjNmivRfOwkmk8CiHV/u20YTCV50chMNk4LZOsl5At 1FzdQbCgBsB1LLkS7DqFbwmKHQjyKigK4ZLwplExrHwWbWgX+62APi9Z5QtFiAj3OAd5 GEaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=whhRNYqL; 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 f29si12509058eda.310.2019.05.19.13.57.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:35 -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=whhRNYqL; 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]:53390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSsA-0002X1-8u for patch@linaro.org; Sun, 19 May 2019 16:57:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZD-0003Ie-Q0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZC-0003sB-Fo for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:59 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:46927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZC-0003rG-9L for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:58 -0400 Received: by mail-pl1-x642.google.com with SMTP id r18so5698617pls.13 for ; Sun, 19 May 2019 13:37:58 -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=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=whhRNYqLCqx77nzPXcgF2akJz9cqL77znkgo40u5v7pMuGbyH4MZ7ZpSyyTvW7ffxn Gq8qIHPRfG86I9UdVpQXIEDmYPZXRAuhGUY+yUtlH8bQvvE/0h/XoLumLp12sw61GjtB U8XTDKJ52B7H00PR7p0gnqsuoPjgOulqgODL7d9jdh8LndwCqsiIuOjTNYLpsnmpNaeP 2hMknugMygzAtE8C4dveJMVKuTb812QfOKapbBh45D5+qOqtAZu4qxaI7yq7B3lwbYHk LCVXRE1tg/yPspaRCejZILgy9ORxtU3Djj84JSQDQAwdt3iaSWSwE7DPuk2V0ay2OLb0 hwGw== 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=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=Xc/YG95coRIDWIq5A+VO8kpZOWB9+ETQv9mmrPkF5xkmJ+K3mWrW0Do7wiw3XhxdJy ouSwgCUtBXt8Ar1JA3fzTgkGyRRDK55OJgrNRwBxZ2jqdHxRn2zmKmq1Z/Y6l10HBCSl WEbEXGG4Z4LliQW6G4FkopVItAtwbdx0R9rUsCz3lIuoJRxRZ6b19vRoiKPkizBSaKT5 yjjw4yTUidZbrhuYGXl4hxmJfgFsYpLGR9YIpsxrCQpiwHv3v5ztyNkck6+jbWgR8RmK 0gUmp74cuxnWLBPv9oBITknlACzEutlGXLwmFSBOi4tNnCZxUU1vJ+Fg3gHmSejg20dT mtcg== X-Gm-Message-State: APjAAAXw1sSEFThHilmbi8TrTsAL3z0XA6smh92a/LLpbgSE+9ygeYCf llaWoh/Tf2NZ8xewwVCElSeSPKl6jvE= X-Received: by 2002:a17:902:59c3:: with SMTP id d3mr1083084plj.273.1558298277044; Sun, 19 May 2019 13:37:57 -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.37.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:33 -0700 Message-Id: <20190519203726.20729-22-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::642 Subject: [Qemu-devel] [PATCH v7 21/74] linux-user: Split out link, linkat 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 linkat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 29 ----------------------------- linux-user/syscall-file.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 32 -------------------------------- linux-user/strace.list | 6 ------ 5 files changed, 32 insertions(+), 67 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index de7a99f0c6..41dd887dbc 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -31,6 +31,10 @@ SYSCALL_DEF(fork); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif +#ifdef TARGET_NR_link +SYSCALL_DEF(link, ARG_STR, ARG_STR); +#endif +SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG); SYSCALL_DEF(mlock, ARG_PTR, ARG_DEC); SYSCALL_DEF(mlockall, ARG_HEX); #ifdef TARGET_NR_mmap diff --git a/linux-user/strace.c b/linux-user/strace.c index 640a80f32b..feb8ec7c09 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1369,35 +1369,6 @@ print_futimesat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_link -static void -print_link(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_linkat -static void -print_linkat(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_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_at_dirfd(arg2, 0); - print_string(arg3, 0); - print_flags(at_file_flags, arg4, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR__llseek static void print__llseek(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 9b966ad627..440ff5ed14 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -40,6 +40,34 @@ SYSCALL_IMPL(creat) } #endif +static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, + int newdirfd, abi_ulong target_newpath, + int flags) +{ + char *oldpath = lock_user_string(target_oldpath); + char *newpath = lock_user_string(target_newpath); + abi_long ret = -TARGET_EFAULT; + + if (oldpath && newpath) { + ret = get_errno(linkat(olddirfd, oldpath, newdirfd, newpath, flags)); + } + unlock_user(oldpath, target_oldpath, 0); + unlock_user(newpath, target_newpath, 0); + return ret; +} + +#ifdef TARGET_NR_link +SYSCALL_IMPL(link) +{ + return do_linkat(AT_FDCWD, arg1, AT_FDCWD, arg2, 0); +} +#endif + +SYSCALL_IMPL(linkat) +{ + return do_linkat(arg1, arg2, arg3, arg4, arg5); +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 491e1d7cfb..865129df9e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5383,38 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_link - case TARGET_NR_link: - { - void * p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(link(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_linkat) - case TARGET_NR_linkat: - { - void * p2 = NULL; - if (!arg2 || !arg4) - return -TARGET_EFAULT; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(linkat(arg1, p, arg3, p2, arg5)); - unlock_user(p, arg2, 0); - unlock_user(p2, arg4, 0); - } - return ret; -#endif #ifdef TARGET_NR_unlink case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 41f8f8d0d0..f3c54cec69 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -461,12 +461,6 @@ #ifdef TARGET_NR_lgetxattr { TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_link -{ TARGET_NR_link, "link" , NULL, print_link, NULL }, -#endif -#ifdef TARGET_NR_linkat -{ TARGET_NR_linkat, "linkat" , NULL, print_linkat, NULL }, -#endif #ifdef TARGET_NR_Linux { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif