From patchwork Fri Jan 18 21:31:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156091 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3755819jaa; Fri, 18 Jan 2019 14:10:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4w3AyF4+dsUJhhiYGOdrhHR1W36BX4ImTaVrABMfgzKxGGxIluqz1rEbX3/tZ46sNmaxQn X-Received: by 2002:adf:e407:: with SMTP id g7mr7950810wrm.277.1547849424669; Fri, 18 Jan 2019 14:10:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547849424; cv=none; d=google.com; s=arc-20160816; b=mahyqv2kT1gC7+6McsfFrQ9389jT4wkDue4Qx/edCOL2TmFwu+M44jq0P7kITBJPMJ xKwNTKGQonxfjh6u/j6WYXjc6iMboWR9Mj2+2OSqhLcJ3/vdSV3fF//l5wE7SpGFq7DB Car6g5qDrq79frqxxNSPANy23cKtVKK06t0nKZiHxPeDvXNcmehU3Wv3TYdqK4iQ4Prg ki5VFuEsCTS29raNsFlpJtZNtnW/V+LklgWVyxwq97A5T9MS/FfukJ5ZACbA8BLvrCW0 YOoHooqWkqD9pT/uV2I/gNUrYLpLs1Z/Ij5ugo0/1OxSmlOhLHaVVMcMcvFG6MsQxAdN dXQQ== 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=1cv5rx86Uif3gdCSQE6eFlguRpyPaS7fmT8hkmM0gW4=; b=grpaacrsSYZRj9VTsrH8FNMiHLfcQ3Cqp//0QnGE21v0WdxYunEKHriRtOlVsW1ivo TJFiuVa8qeV/etAJEofYC5rvvQ7czWOV/SG1wCH/DzK/ELwg4VKWHW2lzM/JVbS7HqmG lJ5fYTyRYOCrdC3yOXYTWN8Ut5WuIJJaV4i4R/1JiUaLCZW5+DaZdJ7iFJBBqH3ErEwU cXV6D43cLIHrepqOfI+/005QXeFe1j1uGRHZK7efZEz2/FLdzF25ZDHvYQM43OfQzF6p PkZW6rYKZssdo2B45FY+Pa0wwmMamSwzrM500DDgLUjHmk2ENLT9yPBnIw2M81URXdti bBFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EObQG4nu; 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 w72si28330025wme.155.2019.01.18.14.10.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 14:10:24 -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=EObQG4nu; 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]:47935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcLH-0002cW-EE for patch@linaro.org; Fri, 18 Jan 2019 17:10:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbkh-0005Oo-M3 for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbkg-0004xv-N7 for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:35 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbkg-0004xP-HH for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:34 -0500 Received: by mail-pg1-x544.google.com with SMTP id c25so6649801pgb.4 for ; Fri, 18 Jan 2019 13:32:34 -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=1cv5rx86Uif3gdCSQE6eFlguRpyPaS7fmT8hkmM0gW4=; b=EObQG4nuDsnIvWzbvn0qYPt39Ru9AoQ74VmdTOkzm5kjMUS8/bUjB6VD0hZIMJvSvT gOLYlmT1njo7IQJpc5Ww4ZjKcJxdDtx2xUUR6cwnf6V76trqbURHDvH0Z3cCdbEvN4El i+UVTtmTWX8QenZaQxT9pyAhW2NxQwMI1lIhY= 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=1cv5rx86Uif3gdCSQE6eFlguRpyPaS7fmT8hkmM0gW4=; b=tfZWpYSHj2xaA2fQlTz5go7LL7J/XILjoaIGeGmUhjm+zoBIZqNQlW3AvRl7Bfj1te 9VXwpB/uqllQ6onF527Q6I0vq/sq/ZO8f37DSEPKNfUbDLEdqN/VIuhtHZUUNjtRDX6C 083xZyC/AdASK3OLabNLMxJrQmWtk/HJsrqBNIDhl1TQddcuib6uEQ2uzSA9tHS2PYkF XbxgTKStoZd+J1X4Yeh173zuVuJ2Mb6ZaYUGINsbfg5WJuRuhIZmttHbREhupKgQgY9+ a1eTA1DLg/k2t0iJnOyFk8rXNIQUpV+xJXNWB069MvjidoGuE8YQN6A8KeBoI0XRZWWY 10uQ== X-Gm-Message-State: AJcUukeu6ZnY0H3ZfJtUs/nZ8nKj+5VjQN2URooLKDMU5LdxKutbEKkB LnDheE07m1OvTASgp7vRVlXNMvFXLfI= X-Received: by 2002:a63:e302:: with SMTP id f2mr19576651pgh.320.1547847153286; Fri, 18 Jan 2019 13:32:33 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:01 +1100 Message-Id: <20190118213122.22865-28-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 28/49] 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.2 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 5133998c4f..668e6a4759 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1911,45 +1911,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 7a4751d460..3b5a79fe74 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 cc5360ae43..d46b4df677 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5331,22 +5331,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 3505014501..adf8955278 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