From patchwork Sun Jun 10 03:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 927216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="C5btyMAI"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 413Ljq0V1Hz9rxs for ; Sun, 10 Jun 2018 13:10:07 +1000 (AEST) Received: from localhost ([::1]:42205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqk0-0007qp-MQ for incoming@patchwork.ozlabs.org; Sat, 09 Jun 2018 23:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd6-0001pp-5n for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd5-0003FA-59 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:56 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd4-0003Eo-T4 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:55 -0400 Received: by mail-pf0-x244.google.com with SMTP id a22-v6so8479202pfo.12 for ; Sat, 09 Jun 2018 20:02:54 -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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=C5btyMAILgN/wc8N5kvZuXl7yF7g3tu5O8tTOfFngt/c9GcKKJFlFubzz4OoA4yOiC PmK8eOuM8XiAiP6gZouq62/Pdc+L2PKA3EPYF+HpF+aW0c2frV+QYMs7cHxNv5+wF6OX GSftNWUrE7jpc5x/Ds10dvvgz0bpkV4VfI4zk= 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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=kvrMMM6/9RkA3qimt9l+SVzoXOvBugl9KUrDc7bVuUW+aud8y1Xqb0WK2EtMVJmJPj GCVB7gUpm4vfovSkRqm3mV3B7QR7Ps9Q9gKXJ5ihs50DZsmJEmYDcY6K36XqM6O86YFo glQgFcFV7Fq702sIaNYaiB9SVFo1HHSiHQAKcqqWX2/Gh7IUv3RMohrEcUSZKtYXzfj4 a7mCAqaHd/mmq7RCMwr7EThrZ2Xn/D/gZiTONDbboSPtl3Kn6a7K2nn29r9XhuIyozNN IeAsPzDHUhh05WVRhqf44FY/HKpedrv5MqsiLs3sPYuiGKEP6vU+gp0xN+1PyvjCofSM 3avQ== X-Gm-Message-State: APt69E0t/T2VdiZ4JWGLNmA3YRKxxDxGkO0unyH+nCxvtuq804ciMi0g lL/6r05tKFxAu2SlfZMvjrJfClw1b3U= X-Google-Smtp-Source: ADUXVKLYTwREWJ+g5VsuJot0Ikt0Zd0D87xAjjovBMuf+vpkiXUegvItUo8GAqSaE15eHVyFH0Gpkw== X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12249395pfh.75.1528599773634; Sat, 09 Jun 2018 20:02:53 -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.02.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:45 -1000 Message-Id: <20180610030220.3777-14-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:c00::244 Subject: [Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_to_handle_at 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" At the same time, merge do_name_to_handle_at into the new function. All targets define this syscall; remove one of the two ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 116 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a4d0f2720f..90341f4254 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7361,59 +7361,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, return -TARGET_ENOSYS; } } -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) -static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname, - abi_long handle, abi_long mount_id, - abi_long flags) -{ - struct file_handle *target_fh; - struct file_handle *fh; - int mid = 0; - abi_long ret; - char *name; - unsigned int size, total_size; - - if (get_user_s32(size, handle)) { - return -TARGET_EFAULT; - } - - name = lock_user_string(pathname); - if (!name) { - return -TARGET_EFAULT; - } - - total_size = sizeof(struct file_handle) + size; - target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0); - if (!target_fh) { - unlock_user(name, pathname, 0); - return -TARGET_EFAULT; - } - - fh = g_malloc0(total_size); - fh->handle_bytes = size; - - ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags)); - unlock_user(name, pathname, 0); - - /* man name_to_handle_at(2): - * Other than the use of the handle_bytes field, the caller should treat - * the file_handle structure as an opaque data type - */ - - memcpy(target_fh, fh, total_size); - target_fh->handle_bytes = tswap32(fh->handle_bytes); - target_fh->handle_type = tswap32(fh->handle_type); - g_free(fh); - unlock_user(target_fh, handle, total_size); - - if (put_user_s32(mid, mount_id)) { - return -TARGET_EFAULT; - } - - return ret; - -} -#endif #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle, @@ -8116,6 +8063,61 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef CONFIG_OPEN_BY_HANDLE +IMPL(name_to_handle_at) +{ + abi_long dirfd = arg1; + abi_long pathname = arg2; + abi_long handle = arg3; + abi_long mount_id = arg4; + abi_long flags = arg5; + struct file_handle *target_fh; + struct file_handle *fh; + int mid = 0; + abi_long ret; + char *name; + unsigned int size, total_size; + + if (get_user_s32(size, handle)) { + return -TARGET_EFAULT; + } + + name = lock_user_string(pathname); + if (!name) { + return -TARGET_EFAULT; + } + + total_size = sizeof(struct file_handle) + size; + target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0); + if (!target_fh) { + unlock_user(name, pathname, 0); + return -TARGET_EFAULT; + } + + fh = g_malloc0(total_size); + fh->handle_bytes = size; + + ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags)); + unlock_user(name, pathname, 0); + + /* man name_to_handle_at(2): + * Other than the use of the handle_bytes field, the caller should treat + * the file_handle structure as an opaque data type + */ + + memcpy(target_fh, fh, total_size); + target_fh->handle_bytes = tswap32(fh->handle_bytes); + target_fh->handle_type = tswap32(fh->handle_type); + g_free(fh); + unlock_user(target_fh, handle, total_size); + + if (put_user_s32(mid, mount_id)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_open IMPL(open) { @@ -8211,11 +8213,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_name_to_handle_at: - ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); - return ret; -#endif #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_open_by_handle_at: ret = do_open_by_handle_at(arg1, arg2, arg3); @@ -12491,6 +12488,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(close); SYSCALL(execve); SYSCALL(exit); +#ifdef CONFIG_OPEN_BY_HANDLE + SYSCALL(name_to_handle_at); +#endif #ifdef TARGET_NR_open SYSCALL(open); #endif