From patchwork Fri Jun 1 07:30:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137484 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619210lji; Fri, 1 Jun 2018 00:52:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfv0YA3rtctBRMn9wjXKd5/Fd7DfATy0g8y75Ge7UxV4PlIrQA35dWtpU2GCCVCJ/byLSh X-Received: by 2002:ac8:1692:: with SMTP id r18-v6mr955341qtj.206.1527839565159; Fri, 01 Jun 2018 00:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839565; cv=none; d=google.com; s=arc-20160816; b=Kwd4CL313qNGhddvScmIOwWGaxsKMZI1UY/XsJeSRJwzXKEI7uOyn4Jszq8LRp422F 8tHCVIT6lZvdINe0wCaxm3UcrDGQBXdh192SUiUpbwkbEJB4+zbe1acDIOXcEbvc4W/h C137VPS1UUaU4Hq4+v6xhi2K7h6pu6wGdI9KCm8poQUMnLDzfd5PvNIpCf694gsXjXM3 0MntiKSLMtwsIviI0xC/8OQMIIQCC6FSpAZ4wStNT9WH1WtDj05Epg/AFlxvRrzYGV8x dIw+AXZQ1mwmQ1DOq9hCQ3g/5wVhN/tDaKUFUHeXJmYF9KAHBXvnmJRvu/UIDvl/Dv6M +JzQ== 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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=A8TUY8PaybuqpYZOQi2YrITRG2mdI1xBOc1QslfgreMeIZqPwHeCRW8bM2YPHAWlyC tagXeAcAkbfae3sMc2Q+7EIcyouNl05cyvSQAOgIF7N7Fyq32hQTGaT/T6gcypmDH8R/ i3C7PqXaYP5pXGDexG4Il82xknSYEqAlK+znSSKsuIrY5cmmLnhgYfuAsdqNx8YUhS2y RXkxyqCM6K5ISnD2YgIZfd1QV15rhrkpsK7vgOa4G4aE3rAB+oGt96+p4Bq7D16RrKBt Y0c3PnseFTyM9ceLz4I2ikbTNiKuis5Qqa4eefLYO6+PAcHZvEZSCqHAom0nA4qTCkgU LKlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dDpBvroR; 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 i5-v6si9752991qkf.134.2018.06.01.00.52.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:52:45 -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=dDpBvroR; 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]:47919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOerc-0004G7-Ix for patch@linaro.org; Fri, 01 Jun 2018 03:52:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX2-0005mO-He for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWy-0000dX-UD for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:28 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:36010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWy-0000cy-Nn for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:24 -0400 Received: by mail-pl0-x244.google.com with SMTP id v24-v6so14818455plo.3 for ; Fri, 01 Jun 2018 00:31:24 -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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=dDpBvroR78DD3f3B7PdsuI+SBheovkYqMDOTOfbOt3zEuOgWucrleXYSxhkor1s/hd UN8vBI29bzKWjMWgyCQI7qTZG6hYufkwYCino1wa4OzMJGLaGR18XIhfdKifyzBXfPQv UU9EUk2OoyaktUakfJKqP2nP8hG471SHvxjS0= 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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=n5xUOdBmUhluOTZLmARlOZu30zv8egJykEeyicq287ZF7JOSznwWEiXCGJfaEbxP7G EXtAyTnn4vpaNNXN13Y6uoQ8kUFi/8rs0W+jT6QyTGaExnrCybgTy7rPJcaUWgbwo6J0 tPX45K5EXSCfcVNQJFtjQX4mvi3OIjirb8EAGYo7VZ5BeHSS6opK/D/vKoSTCHh8FiGw jhmkN5pCT1SaUssce97AAra6I4eaB924Nfa1p3TjHesF/rvMeJ2dywnRyNHNms8kD7iF HQGs4zyCt1auuGLYW/3eapKfBn1YSJYfBBsnxB2Ml7kH6Pb8tj0d+8eYAV2YW5fjLM36 4P9A== X-Gm-Message-State: ALKqPwfU6pNZAn0U38xWIptWrCWBxnc2yQ//4vt9f/+hsY+zqlbB0rKZ 090lndQBjfsoYvS8bXFpViQdMGOwJ9k= X-Received: by 2002:a17:902:2966:: with SMTP id g93-v6mr10331817plb.250.1527838283518; Fri, 01 Jun 2018 00:31:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:38 -0700 Message-Id: <20180601073050.8054-22-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:c01::244 Subject: [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount 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 | 123 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 63 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b568144369..53eac58ec0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8200,6 +8200,47 @@ IMPL(mknodat) } #endif +IMPL(mount) +{ + char *p1 = NULL, *p2, *p3 = NULL; + abi_long ret = -TARGET_EFAULT; + + if (arg1) { + p1 = lock_user_string(arg1); + if (!p1) { + goto exit1; + } + } + p2 = lock_user_string(arg2); + if (!p2) { + goto exit2; + } + if (arg3) { + p3 = lock_user_string(arg3); + if (!p3) { + goto exit3; + } + } + + /* FIXME - arg5 should be locked, but it isn't clear how to do that + * since it's not guaranteed to be a NULL-terminated string. + */ + ret = mount(p1, p2, p3, (unsigned long)arg4, arg5 ? g2h(arg5) : NULL); + ret = get_errno(ret); + + if (arg3) { + unlock_user(p3, arg3, 0); + } + exit3: + unlock_user(p2, arg2, 0); + exit2: + if (arg1) { + unlock_user(p1, arg1, 0); + } + exit1: + return ret; +} + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8373,6 +8414,21 @@ IMPL(time) } #endif +#ifdef TARGET_NR_umount +IMPL(umount) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8483,69 +8539,6 @@ IMPL(everything_else) char *fn; switch(num) { - case TARGET_NR_mount: - { - /* need to look at the data field */ - void *p2, *p3; - - if (arg1) { - p = lock_user_string(arg1); - if (!p) { - return -TARGET_EFAULT; - } - } else { - p = NULL; - } - - p2 = lock_user_string(arg2); - if (!p2) { - if (arg1) { - unlock_user(p, arg1, 0); - } - return -TARGET_EFAULT; - } - - if (arg3) { - p3 = lock_user_string(arg3); - if (!p3) { - if (arg1) { - unlock_user(p, arg1, 0); - } - unlock_user(p2, arg2, 0); - return -TARGET_EFAULT; - } - } else { - p3 = NULL; - } - - /* FIXME - arg5 should be locked, but it isn't clear how to - * do that since it's not guaranteed to be a NULL-terminated - * string. - */ - if (!arg5) { - ret = mount(p, p2, p3, (unsigned long)arg4, NULL); - } else { - ret = mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)); - } - ret = get_errno(ret); - - if (arg1) { - unlock_user(p, arg1, 0); - } - unlock_user(p2, arg2, 0); - if (arg3) { - unlock_user(p3, arg3, 0); - } - } - return ret; -#ifdef TARGET_NR_umount - case TARGET_NR_umount: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(umount(p)); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { @@ -12896,6 +12889,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_mknodat [TARGET_NR_mknodat] = impl_mknodat, #endif + [TARGET_NR_mount] = impl_mount, #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 @@ -12910,6 +12904,9 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif +#ifdef TARGET_NR_umount + [TARGET_NR_umount] = impl_umount, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif