From patchwork Sun May 19 20:36:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164525 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4796666ili; Sun, 19 May 2019 14:06:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsHn6OvtyLlFUg6kT2TmGAqSApkAtSyv5/ifPILuX+d66Soofud11uToZQIjoF+0i/EBE7 X-Received: by 2002:a50:c315:: with SMTP id a21mr70634940edb.158.1558299967291; Sun, 19 May 2019 14:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299967; cv=none; d=google.com; s=arc-20160816; b=ER6nSqYhz85NYeHuCAUFOSVsPOlTJCQ3X0ThboAMywRe8AvLDnBjDj0J/PRg2pXBhl cWdEDJc5CYml6V4Ihd0aW7N1m7LdF6N9HXI/PxHNmYvJyfB5Fb3ir8MlKNgZEbEV+dEc ZxF9bY3Ar5L6J9zbkzJGCMOte+72U4Jrtj82fIMhVqeZpNvm6Qb/kLUp1vzLDd+sCtqB 4aEOia7dZsBHmHXqNUt8b//dFK7WS9yxycEa7Wj1NE+nqlsdlSk48eRw97/vJk6zXeg9 s2xwi1c8Gr6UQZILCstQ9ZDy5yvWSr9SLelMmbeLhpIXfsr4iR48NxMIqPxTJuLedxld edmA== 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=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=GJ1LBdfIWQIOTpBLXECOEZezcnrm2Hk3OxhXb3Lyttkw6T44ShlxY4g6iIV//y3MRm NqiAjbbB3DQ/e3HbhAR8OEeDsehwytk0ohxGg/yjRLG5cjvKbAibP4GmxjZeAgfjv4r5 BNmQT8Tj9wWlJmKMfqwY837M7WaD7NE7zr+EeSElx+eqHAMQq6ZeWZe7nk74mO0wd7Va EV4zL+KiDEPkknmFvKlAR1KeGvXiNw2EmXn1UtkYYM13Rw50i1yxk7++owQ87OGYlCYl Q7Mywt9JkZS95FlA/jrg40fw/5V6js6KfOFWqvazPZevHR0MNbmiIhl/SH/ZZWlSsZIM 2Ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=saXIpHPF; 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 g38si6825396edg.96.2019.05.19.14.06.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:06:07 -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=saXIpHPF; 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]:53530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST0Q-0001pU-6K for patch@linaro.org; Sun, 19 May 2019 17:06:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZL-0003TC-WA for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZK-00042Z-P9 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:07 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZK-00041r-J9 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:06 -0400 Received: by mail-pf1-x444.google.com with SMTP id g9so6148914pfo.11 for ; Sun, 19 May 2019 13:38:06 -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=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=saXIpHPF2AKzen0wYa8bg8Wg7/NPOHshxt0TUVYcXLf1To1FkBuGZ6HTgamFMDGvci PQfF4jY9aPDPL0kHQQmMpl2PVOM7GzNd6zFE9UZbU39JGbvey/AcgVIJhKP9+gMqZiLJ XeR3QA4lXotuv92ui6yEKoYuXScDTKgClGo/V+TzRLUeRXAAte/l6PLTr8koly2Mf5vf 3/3xZmzyZWc4n42ET7VZrW/2tUs25C6ereWlDFq9Bg8c+JMKGfRtt4wm/3EI+0ijuetT ETL632AGiMr0Nadu52EBg87eLH3cfmjH4431/z3/8dQGB9LCQSKVx6AEpIDpWIp05yUI b4+w== 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=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=Xif5altTVZ9E5QcvKpeKpXo9JluiBYe63tLvbYVJtvpBmyZZfMX2oTtyFEGmVrFaRm ITL0mjiygw0CXifXsltZHK9K7GnNaSP4/JJq7CJ4UIJcH1clgh4/Ozhh/mKtjY2AUTwX nq/SsovkWC+0TuvgbsJDfcC0htYIfHb66PL4JaVSS5GwtberqAzgXCEqvW8mImljTmYy M46fgEL6tahyR7aHxaR34Ml4iWwCjjv2DqzrIBdRFtp0dCJM/qmFGUcDXBTSz274ClWv bHagwlTKvfAr2tM8/Df+UUn7NZQN0gTSrsg65Zopmepj5NRsaMJSM5bY0nxXAPWnihrN qw6g== X-Gm-Message-State: APjAAAUDfgM46Y+gBbY0O21Vuby7Zp6T/icyHVjxyLs6OmDHX+Xhwe8e LLl2Xs15z6H0sVr8QRqX6XnRCzUrptE= X-Received: by 2002:a62:38cc:: with SMTP id f195mr76083842pfa.15.1558298285319; Sun, 19 May 2019 13:38:05 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:39 -0700 Message-Id: <20190519203726.20729-28-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::444 Subject: [Qemu-devel] [PATCH v7 27/74] linux-user: Split out mknod, mknodat 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 mknodat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 39 ----------------------------------- linux-user/syscall-file.inc.c | 26 +++++++++++++++++++++++ linux-user/syscall.c | 16 -------------- linux-user/strace.list | 6 ------ 5 files changed, 30 insertions(+), 61 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 9950b73e76..b5951e6911 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -38,6 +38,10 @@ SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); SYSCALL_DEF(link, ARG_STR, ARG_STR); #endif SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG); +#ifdef TARGET_NR_mknod +SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX); +#endif +SYSCALL_DEF(mknodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG, ARG_HEX); 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 b234274034..c70c06d965 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1923,45 +1923,6 @@ print_syslog(const struct syscallname *name, } #endif -#ifdef TARGET_NR_mknod -static void -print_mknod(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); - - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, (hasdev == 0)); - if (hasdev) { - print_raw_param("makedev(%d", major(arg2), 0); - print_raw_param("%d)", minor(arg2), 1); - } - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_mknodat -static void -print_mknodat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); - - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_file_mode(arg2, (hasdev == 0)); - if (hasdev) { - print_raw_param("makedev(%d", major(arg3), 0); - print_raw_param("%d)", minor(arg3), 1); - } - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_mq_open static void print_mq_open(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 76637fe71b..3adb629124 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -82,6 +82,32 @@ SYSCALL_IMPL(linkat) return do_linkat(arg1, arg2, arg3, arg4, arg5); } +static abi_long do_mknodat(int dirfd, abi_ulong target_path, + mode_t mode, dev_t dev) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(dirfd, p, mode, dev)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_mknod +SYSCALL_IMPL(mknod) +{ + return do_mknodat(AT_FDCWD, arg1, arg2, arg3); +} +#endif + +SYSCALL_IMPL(mknodat) +{ + return do_mknodat(arg1, arg2, arg3, arg4); +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ea89734706..18163f558c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,22 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mknod - case TARGET_NR_mknod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(mknod(p, arg2, arg3)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_mknodat) - case TARGET_NR_mknodat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(mknodat(arg1, p, arg3, arg4)); - unlock_user(p, arg2, 0); - return ret; -#endif #ifdef TARGET_NR_chmod case TARGET_NR_chmod: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 95706a696b..f56d9acf76 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -518,12 +518,6 @@ #ifdef TARGET_NR_mkdirat { TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL }, #endif -#ifdef TARGET_NR_mknod -{ TARGET_NR_mknod, "mknod" , NULL, print_mknod, NULL }, -#endif -#ifdef TARGET_NR_mknodat -{ TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif