From patchwork Sun Jun 10 03:00:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138105 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2585947lji; Sat, 9 Jun 2018 20:24:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLx8OwhZ7BG3uSEDeR2PFtfqu+1ssKGvLJybKyfDtiJTuf/ydX8LPG2N0xWdxfITpq/YOB0 X-Received: by 2002:a37:660f:: with SMTP id a15-v6mr10515283qkc.440.1528601093035; Sat, 09 Jun 2018 20:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601093; cv=none; d=google.com; s=arc-20160816; b=PzZuI/P8PgilQWa1OARtH0/P2oXScliR+Ml1yG9QjBCkwB6ht1r+TsLH5WpRTXtBJ9 RVQgWdsYSF73xDUK6NqfF52ocxJSmjCdUv038mOhZ9RMFZKWQmhrFQx2XwJnC3tjtiml SMev/uGJ92jwosn8pOLYkQUdc1Epylu8CV//i0hgESKM04s3DMaNU7ug6rQ+XCAw5QpA LGn2sfMdYoRvA5e0q9w+IuCSTgCcJzsJeRIUFCHNVNqJ2Jn0V1nmA8bqDL3eji+ToXc0 Y/rng785SYJUEetttyPOt3gKJwaFWLtRsgnjpRscBt+DGpdaM5YA6LW77Nbev3MHX4+V yMfA== 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=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=N1xn+r2Or2PWoI/YE30zZL3AadaQVk3WueXdwe+SfHIwCSPEYH4Se5Dob8P3N/gQeV DjoLjuPErt8Gh3Sz3lDRUNCQ+gqEu78tWzGHrRE02rRYalL+T7h/bqy8oIt47ctk2S+f 0vNmVTQF8k0z6MkUWiFqN7tPW1KmzsMjFPDthtemTZRF0qEah54pP3YyK8vuJ7PpwJtE JMgc/W8RQHcAfpS5o0QYGbNnyxc4P3Yr9flwbSw/uKZA5heBl/AmFTLUoOqUFt920QyP qWiN2mEUg9LTgmvH9YnE1qLe5AfFYhpMaMR81FHMYSMqkoFABwK7p7S8BnqCfjnU+Thc jRYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYTelkIq; 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 y1-v6si385654qkl.43.2018.06.09.20.24.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:24:53 -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=eYTelkIq; 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]:42292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqyK-0003fF-Dv for patch@linaro.org; Sat, 09 Jun 2018 23:24:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdK-00023D-4f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdJ-0003KL-46 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:10 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdI-0003K5-Tz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:09 -0400 Received: by mail-pg0-x243.google.com with SMTP id 15-v6so8138338pge.2 for ; Sat, 09 Jun 2018 20:03:08 -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=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=eYTelkIqDt89++6aqkJhQbMPSx1o1bplWNFqpDVfLsWJJ5TJrXo3Z/giaLAUMvReu0 7xTafQZaPB4C1xJUQHXYs2gcNxRnrgX/g4rQzuqP4uZvlkFkMVxt0bFeXiiltG7zQi4z k7xJQu3SsBXWaup3sT5SEulPxLFXznX8lnJ24= 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=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=HrFsBNkvDQ3XrRvgXXRHYCI3WJmyy2Cyzc+sB2FuzIOoHGaVbjx5JjNKvNgn77Uo3f 5qAva91vbxKYSqLTpQsGP3cRWQG6WKS4AJbm8+8FSfNgI6vaHT2eDLOKrabmKnNU+gun zl+6YI3pbtRzPjQes2+GvCoLeTq198lvUgSxIfLqEhsNCR9pBMbQ5VzmIHkB9cHkIo91 pjhVnW5RxKB1HakxH9hW4qtkzBWwfy0y/4/BQgECP38ZIOs4sXIWT3GL9t/aPZQI8jGe GJg7YtZdZFIoHuRt084J0rSiNT83LqtTt/OacL66tXbQ4e/ru+gchFmehRkORX0BWKt7 94lQ== X-Gm-Message-State: APt69E2+KXt+5hJEY74+FkJiEWl1Z5QQaKiUyzkbshMAW02RQpxPGG9F StmZR/y0TQM1PLbgHKnkTtPpkyOo1y0= X-Received: by 2002:a65:630b:: with SMTP id g11-v6mr10221549pgv.303.1528599787663; Sat, 09 Jun 2018 20:03:07 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:52 -1000 Message-Id: <20180610030220.3777-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-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:c05::243 Subject: [Qemu-devel] [PATCH v2 020/108] 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 | 118 ++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3d3983a504..844e771488 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8158,6 +8158,42 @@ IMPL(mknodat) return ret; } +IMPL(mount) +{ + char *p1 = NULL, *p2, *p3 = NULL; + abi_long ret = -TARGET_EFAULT; + + if (arg1) { + p1 = lock_user_string(arg1); + if (!p1) { + return ret; + } + } + 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); + + unlock_user(p3, arg3, 0); + exit3: + unlock_user(p2, arg2, 0); + exit2: + unlock_user(p1, arg1, 0); + return ret; +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8315,6 +8351,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) { @@ -8416,69 +8467,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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: { @@ -12569,6 +12557,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mknod); #endif SYSCALL(mknodat); + SYSCALL(mount); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12583,6 +12572,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_time SYSCALL(time); #endif +#ifdef TARGET_NR_umount + SYSCALL(umount); +#endif #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif