From patchwork Fri Jun 1 07:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137482 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp617275lji; Fri, 1 Jun 2018 00:50:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlD7to23PCUcJm4xif5EaM5znH3UuJRDw+fHiie9H2IkYY9g1sOPOTHPDHzEBdMOKXyH1h X-Received: by 2002:ac8:903:: with SMTP id t3-v6mr9798999qth.13.1527839401887; Fri, 01 Jun 2018 00:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839401; cv=none; d=google.com; s=arc-20160816; b=b61u6II6FEg/RXCoO8km5hS20foh6B23WbAGdaVHULl/dvhl2Jhmdai4CA7WgSgjRx xmZtlo82aIaZsnVLUklLwA3uMW+VQdzTeBN6e1oAgVKjlgRYRUwFYgdM+A+t3/fQL8MA TV2Ax9lLX6fNd3ufHf3CpbTJvBAh917Eu6Z6mailAbCkoaSam+08uZADDPTNyeJLxtqy N4EG92/KpkFB+zsBB8afClKgJrr/XoI3Q/Q/oMIeW92Jh8FQOSlIB8Uv1O3/uBw+SOFC jvPzv8fO+PQQ2VL+nStdp6KWPXaUQb8+5UvybB9rD3cHOQlq7rZIJHzObQVYghFXB76g bb8w== 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:arc-authentication-results; bh=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=Ijrnh7z+a+uoVRHj9Cit/PMj1H2wWIZOcmKr3lW6dXZpjym2AlE98PEt7+HB/JUHak aDNuUgaavTAriFpNeDAHEa5l35eBAtVp0L+iB+qGKF7zGwiTXXKo5JQna2k20QTFmYTi a9mnOnH7Ti5C4KK1UrxRqWCUppOvYgA1ugLY3USJ4MuCI4efL1Uo/ce1s87PyslDozao 9JdRljZxGAAnoL0wGUrMGTfMD20Crds5tDINV3t6T8Qlr3g33RUROtWI87QSHH+UqI1t MUOBK/e7mf+Vwknp3rU88mbHXBoDafyYqmhmO5+E8ep2Jb8WtR31X00O+cH1QKiJTkP/ ofxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YohMcLNG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w1-v6si1476735qtg.224.2018.06.01.00.50.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:50:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YohMcLNG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:47903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeoz-000262-AH for patch@linaro.org; Fri, 01 Jun 2018 03:50:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWv-0005dJ-IO for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWu-0000ZA-Ku for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:21 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWu-0000Ya-DS for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:20 -0400 Received: by mail-pf0-x243.google.com with SMTP id x9-v6so12086226pfm.2 for ; Fri, 01 Jun 2018 00:31:20 -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=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=YohMcLNGy+o3QjE9srFUHHl2DDWKTy/BDh14Vnmq912V1SALc24oeVEcJ1piT+HBVB xPtv04ls+oIB3D2vaUPuPBrfZV7JGBx0NIJSLruKRGctQ053NZ0bkrIGj+TbZJE2Fbzz yR+mJFaQTjG9zkZSbGaxfM6mCTyyr2J2aWam8= 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=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=GNv/leeeiHKz7hZ/Xim/Yxogu0e2NjxTy1Dsql4/u8OYiKS39E7L0UYi+NjMNJLUeQ eq9ZGv+v7bwFJocMcLXDMkcFPZY/xmbYFqhGwjAmBajpYA529pz1IZIrbppuXoTqG7Pe vGJn01JjzLZQrGwbU7lZb8AdegCbK0uQ/vIc8m8Ivc7ZydxwBaMN4/5Ra1R2+LCuO1Y+ izWLkpFgr4+JSWDnmrURtcOsVBFnwIuYtHXl3mJFrEPZxO77eRfwxwTikzCxjOz19BfD RhmVG/7t8ja8D7RC0StJ8lN97R7JNcRmuaZHCh3m0fYuQRSIgomKJVB4wEsqr7gNJD/h btvQ== X-Gm-Message-State: ALKqPwe65srvy+hCD5E29k8JnmjSK1XIOtdCNCxHwAq37eQA+ZsGlGM9 ff5SZFKRhawOPCmIkTqDg2FZCtYTxBI= X-Received: by 2002:a63:b257:: with SMTP id t23-v6mr5037123pgo.431.1527838279140; Fri, 01 Jun 2018 00:31:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:35 -0700 Message-Id: <20180601073050.8054-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod 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.c | 132 ++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 45 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bbe9d6d9fb..88e0da31ba 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7899,6 +7899,34 @@ IMPL(brk) return do_brk(arg1); } +IMPL(chdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chdir(p)); + unlock_user(p, arg1, 0); + return ret; +} + +#ifdef TARGET_NR_chmod +IMPL(chmod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chmod(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(close) { if (is_hostfd(arg1)) { @@ -8115,6 +8143,40 @@ IMPL(linkat) } #endif +#ifdef TARGET_NR_mknod +IMPL(mknod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknod(p, arg2, arg3)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_mknodat +IMPL(mknodat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8276,6 +8338,18 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_time +IMPL(time) +{ + time_t host_time; + abi_long ret = get_errno(time(&host_time)); + if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8386,51 +8460,6 @@ IMPL(everything_else) char *fn; switch(num) { - case TARGET_NR_chdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chdir(p)); - unlock_user(p, arg1, 0); - return ret; -#ifdef TARGET_NR_time - case TARGET_NR_time: - { - time_t host_time; - ret = get_errno(time(&host_time)); - if (!is_error(ret) - && arg1 - && put_user_sal(host_time, arg1)) - return -TARGET_EFAULT; - } - return ret; -#endif -#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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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))) - return -TARGET_EFAULT; - ret = get_errno(chmod(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_break case TARGET_NR_break: return do_unimplemented(num); @@ -12968,6 +12997,10 @@ IMPL(everything_else) static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, + [TARGET_NR_chdir] = impl_chdir, +#ifdef TARGET_NR_chmod + [TARGET_NR_chmod] = impl_chmod, +#endif #ifdef TARGET_NR_creat [TARGET_NR_creat] = impl_creat, #endif @@ -12982,6 +13015,12 @@ static impl_fn * const syscall_table[] = { #if defined(TARGET_NR_linkat) [TARGET_NR_linkat] = impl_linkat, #endif +#ifdef TARGET_NR_mknod + [TARGET_NR_mknod] = impl_mknod, +#endif +#ifdef TARGET_NR_mknodat + [TARGET_NR_mknodat] = impl_mknodat, +#endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif @@ -12993,6 +13032,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_time + [TARGET_NR_time] = impl_time, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif