From patchwork Fri Jan 18 21:30:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156068 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3739886jaa; Fri, 18 Jan 2019 13:50:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN5qkdQcUuPmsSdJ2m8FZKsh/BXeFZHy9CkvY0Rf1F6G+5BkI0wTsUvPWOcMY0lKsjgQa53j X-Received: by 2002:adf:ed46:: with SMTP id u6mr18785259wro.262.1547848205352; Fri, 18 Jan 2019 13:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547848205; cv=none; d=google.com; s=arc-20160816; b=suPMdjto3/NI8iHYMSs+CvCuDLiwSt5Gwdi9wytq7tNIb94zFmHS6Ewyvf7+X2lxsO uwzfXiJQ/YjSWXnuOYBi/XHkZptJfHcmUYFLW/O5SolMFLjNeETvF7swBiZTjsbBtlAU fejj4NZdaAK+yVwYMg534wKsaPTSS61XKkkIWcRfUSyLTAH2FFRgiLANg2oXFRuULpvi y6Np8y97d6yaN8BzSgiSwJNozc2HWf8eYaV8fCscYAAX5Fvdute1x6peoSrjJi5QKYtD 5MIQ7BKWqshL0pP5G7yL45hWCcwFXw8eZodlKcXY91iKGoAT1R3FewmXdhddruLoX667 n0gQ== 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=xWyW/AxGb4DGE67el7J8JfHnvATN5W0cXS6IRi20Ck0=; b=tpmeD1IJkGrC40cvEzJF4Sd8NQXe6sgSV9P1rkAU7ngs5f1um/fxj/KBvQ7V4wfC7+ qUngaWgTlIZTDW6gxgvxruhb1yCm5JpazxDKHEFFgk1ALIBiJ4hKFrK3w/b6AJJLZv0S 6elZi/hvyO4LgiC4UPstTIrfaKHmpEl7fFLHOlvdKhKw04sd7D6QHL2/DywRyjIe7Auu f2ssa4N2j9GhY9bHOmp+UNPLpNWJ4lqpo3s/xHrUBSZnt072mILHis/4q85RvzE+Lc1H 60TZbEqiEfscbmlj+m1gNj1z7ohMqwTmVRlils1NbvDFE4RQoFMzNjv54IPJz93+XMhB edyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DRSonpbv; 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 73si12270715wmw.46.2019.01.18.13.50.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 13:50:05 -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=DRSonpbv; 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]:47619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkc1c-0001oZ-5w for patch@linaro.org; Fri, 18 Jan 2019 16:50:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbke-0005Lw-Ag for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbkd-0004sc-C7 for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:32 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44929) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbkb-0004jS-Iw for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:31 -0500 Received: by mail-pg1-x544.google.com with SMTP id t13so6634927pgr.11 for ; Fri, 18 Jan 2019 13:32:20 -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=xWyW/AxGb4DGE67el7J8JfHnvATN5W0cXS6IRi20Ck0=; b=DRSonpbvv/0NJrN6ejyjyVfrnRB2VZvUfiEuMQlcg+gDS9/xuvP5TRcrcsGp73rzPZ DMK/ogirFKE9ZXtrEyNoG+SCn/URh3F385QofPJStD+J8MNxN56jM0vijUSunucmVBpR audx+bX3yZhN7N8ced8s+bTZOMvVXzccMJklY= 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=xWyW/AxGb4DGE67el7J8JfHnvATN5W0cXS6IRi20Ck0=; b=VBeDq3BmFq0GO3u3LJw/O+A2hLHUzVcO7tcAR2V3+TTgefQRwnveelkBEJgiZIiuDQ ch7nzDuNV83PN/PV8rclZRc6em7nMYGpVuI9Hr6GyaxnNcejBQXVuB8dnLgAPqZ0u2I+ wVH3qRNIgzLF+Z1axWF52jTzTdjzJ0dpLyEj7qFahSs8bSgOMgH+/2zy1SGpRWukcZjc RkiEPuTtj3knFGNmyEw3hy3Yk2qBhJwMPtr+NLjn7HjXIk8I9pvALxaqrxqtevTVP+WN SX+su3Zo6J+ZXHlU3wYuDOVDbiXbL5RZ8hIIOqUAwPIOWBkec+qg7+v7Q2d5c9yIrXmg f8dA== X-Gm-Message-State: AJcUukfuYoPQLwJat4XpDPWhz61rQAt3bh6tQt9VyY6yowG/bDeE8/Ww MZf21qZTPlIOjD7QwzlBeS/KTsMDQNI= X-Received: by 2002:a63:2054:: with SMTP id r20mr19184131pgm.328.1547847139504; Fri, 18 Jan 2019 13:32:19 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:30:55 +1100 Message-Id: <20190118213122.22865-22-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::544 Subject: [Qemu-devel] [PATCH v6 22/49] 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.2 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 5cb77223fd..5b78eb137b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1357,35 +1357,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 62e1790e3b..c6ca80955b 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 1e9478611c..f1e8d06996 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5330,38 +5330,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 be0392810c..c369915759 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