From patchwork Wed Aug 14 20:54:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 171372 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1321834ily; Wed, 14 Aug 2019 13:57:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlsxzDE8jJMhdJuuAFSNCedxrQqJ2r/pLdHOlBPDgsTYr4lUUhQU3xXiIO2xJmwNREUgOU X-Received: by 2002:a65:6552:: with SMTP id a18mr925778pgw.208.1565816257295; Wed, 14 Aug 2019 13:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565816257; cv=none; d=google.com; s=arc-20160816; b=nuzgWFjjWbPwsRRVFac75FO3A/b3s4R4HzuIL0mStDrUjW2kSBgv3VoCE9B/+Y34RU ATOueb7H26Is7no1YwSSAu434qEElNpN9gj/Plk3dNe2DI+NftabtijfnhlTpxgCS+lB fglwJFKQJCKd0DXzSGytGAxaYvSxc9zE2GT2BdMSJ6ie513gjww4hDsdNlo9okIWOFnt M+SW6I8Py05XYp7rAYlHnjTQf2iF97TObtSjQBfounnWbdINvuR6a+JCTR3zglOIvqp3 BuK4kECGqYlEx6aJedIjCvWF3NKmgHjWf5UDkpWm5d0HKMaEeoek6DNpP7+fjN+4Y+xb kddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6yShj0VVa+1mi1lghCuQZdY8JOdEtUzog1KXleiZtu8=; b=ului9rzKXUOIPm/Bm1lSCz57j5BpjFY2Gm03bBf9n9NXRysfzY61USipp4VEHbQ3ik M9aAvQqXpMeMdE2oKU1VmPXd/3X58mpnYkjV5awGZmzZAy+cTFXl+z4PlfgWf/MjTSux jB9lRHMbnOgn2Jz0LHdtZx1GO2BOEC8jmOZG5dsXE2ztYNyPFBJSpwRgaF13uQlKtBH6 Xo3A6PRsvA/Bc1d04nY4XqU65yX79CgAT6ha10IW1bFhJ0ZIByYE9G/qo8SmS5+CAiho M/1lDcoj4hBAtI8BDaG0/7pcTsM1galpsF0DNedPp3mpwiuvPv+RejncQrx5QaYDH04b W3qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si529449pjb.40.2019.08.14.13.57.36; Wed, 14 Aug 2019 13:57:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729958AbfHNU5f (ORCPT + 28 others); Wed, 14 Aug 2019 16:57:35 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:50785 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHNU5f (ORCPT ); Wed, 14 Aug 2019 16:57:35 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MPowd-1hckJz13UB-00MpFs; Wed, 14 Aug 2019 22:57:32 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: Arnd Bergmann , Hannes Reinecke Subject: [PATCH v5 17/18] pktcdvd: add compat_ioctl handler Date: Wed, 14 Aug 2019 22:54:52 +0200 Message-Id: <20190814205521.122180-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:vtBRrSTbxRM+4N7JG/SqINjMT8OwhCCnfEV9GLfJMlj7zzHmXqL wFcQBgM7/r/60w0dHWdIX39QTgYM4f/6oLGxqnTXmb0CHbl9e834v0p2Rmzje1ZTzLFB0d4 ArUarrUL7+s3fgxa94yevKS1w3wmtdSr7o3Jo/MviF7gzdbq7Vr5Sa0PLjOc3+0XsDb7ayd Im2A9aO8g12wUfvh63IzQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:oXxoA9Saf5U=:wn2CxSLASoltE+VPtsKsmS DbM3bcSOL5toXC7kI5Wz6RafyaM3cAUqLlE3zjj3c2paNf19x+xqkxDbfmVmBPA63QSHuNvlo aNikgXHDUJ8bhRVl3ntnHP/QQQhffoJlfbuIOka54SfVt754KI6HKMfBnl1uLRKT5k4+4ItGZ /itPTJ3SDZA1hRH4ZojXudrHRYkPWnJmzt4GYzIPq3Ewf2uH0vIg2s4swG5LPGrVV4gMiUiXf 3b3TQPCWgpHmS4mBiAigr/vnrj7Ps7Lr3BVqSAR8ioWfzXjnFesSIO3H8YHlIB5VZCYnozlpK rpXwIG8gGgfZejIX2FD5CW+2QCT766pjpVsSiQlCWlsREd7u4WNA+CcS3CX7WaAIKx0z8vSe5 7obgtro6nmMuqzOTcjPLrfLt4NQNPitX7upsF5WWyhUiMBqMnhBb95qBmr61t1yaR30GgYaKa nmKXPddvpCL8Dx+/T2jw2Eh7FDG5rr/H6Sh/ti8cH0/L0PBate4GA8OTM6yV3dwtOdSIMJEmO GcI941L57d5nOl7fZDJe2DxZyjKA6RG9kcEr17w+Ff/hJ6CbTGBAhwHDt9WMZsplcRj7LdJoO yv14a5pkTALtpSrjJd9JhqIn1MVYvyoTPee7UiU5MUtw366JG52QkMRjoDzcC7CBKlnrDDJDX 47JwnZHHclHBGahHLCJehDayQgvWpgjncjEbJpYMi5AVfW8LQrzJZ1Ue1XnaOM4sMLkd2HJJb zRdDmZjFRSEBmUUiGjtz5uyZGpGQ34zVToeIOg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pkt_ioctl() implements the generic SCSI_IOCTL_SEND_COMMAND and some cdrom ioctls by forwarding to the underlying block device. For compat_ioctl handling, this always takes a roundtrip through fs/compat_ioctl.c that we should try to avoid, at least for the compatible commands. CDROM_SEND_PACKET is an exception here, it requires special translation in compat_blkdev_driver_ioctl(). CDROM_LAST_WRITTEN has no compat handling at the moment. Signed-off-by: Arnd Bergmann --- drivers/block/pktcdvd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.20.0 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 024060165afa..b5950b7851b0 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2664,6 +2664,28 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, return ret; } +#ifdef CONFIG_COMPAT +static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + /* compatible */ + case CDROMEJECT: + case CDROMMULTISESSION: + case CDROMREADTOCENTRY: + case SCSI_IOCTL_SEND_COMMAND: + return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg)); + + + /* FIXME: no handler so far */ + case CDROM_LAST_WRITTEN: + /* handled in compat_blkdev_driver_ioctl */ + case CDROM_SEND_PACKET: + default: + return -ENOIOCTLCMD; + } +} +#endif + static unsigned int pkt_check_events(struct gendisk *disk, unsigned int clearing) { @@ -2685,6 +2707,9 @@ static const struct block_device_operations pktcdvd_ops = { .open = pkt_open, .release = pkt_close, .ioctl = pkt_ioctl, +#ifdef CONFIG_COMPAT + .ioctl = pkt_compat_ioctl, +#endif .check_events = pkt_check_events, };