From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id 4ACCA1EFF73; Thu, 13 Apr 2017 13:53:03 -0400 (EDT) Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by befuddled.reisers.ca (Postfix) with ESMTPS id 4DD0B1F075C for ; Thu, 13 Apr 2017 13:47:34 -0400 (EDT) Received: by mail-wm0-x241.google.com with SMTP id x75so13958079wma.1 for ; Thu, 13 Apr 2017 10:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:user-agent:date:from:to:cc:subject:references :mime-version:content-disposition; bh=79iEzt6nUluSs4PQu9Yc3pzGYSY4E3DRWf4pzG7TwmI=; b=NesgXbu/npSyK3CA4dMZAKw6+9mxUIy1M24yzDoPdnI636UZAG++G8H0I286ODufhW /UoxSekPYVKbE0Y445AUAEqGCUF+aODJjfO1LUI/iVh66uY6pNb2CFm5+jEkDw4HLrus RiluCpEOWNCIRdUC7+8qJ8oQ7wVK0nyBJBTzIyv8x4tBdVteqGkbbyzdl5mEqmHCc1ms o5UukB0RUDnk3A3r2GBrZK6BXq+SeM60ZrJ1RyVuCBFIoe2xxwWDKy4RPDJqEgJj3d+U kO2ecRDbKaQnoMHO6w8yl3szIDTZjEn2CzsufgyQcnlmP9wTetPwft76WwCFROIO7wQs lOeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-disposition; bh=79iEzt6nUluSs4PQu9Yc3pzGYSY4E3DRWf4pzG7TwmI=; b=DIXRogAUsjA/L4uNPcBWif+yv0wwxZg2u+W4MX2d8iZhtU/fBWNY8XkcHLfAplhjI8 5nV1eu4Xmy0PSkAUov3hFxllvN34M+M8XO0T2auSRa+W/sW3Dmd2XUqAE/69Jiii6i+s ILDsyLpVySEZCLxqrx292kzDeyk41ANz/WXHvZr8c3ooXGPHvVaHHw3wtwXVrhk90sP5 8+O5XkDwPE/xs/3gH29rpbBkJiFJlNCtmaQPVOT9t2dwOz8UEFNyir8HxI3Y+xcMHyB0 Qwg5XKxrtgLSRhoWvrb5cMygxu2/uk/+WgoJrfXe5q4Hat8aSlmx3Pah2JXVaCyTcYxy mllQ== X-Gm-Message-State: AN3rC/4zerxWAqL1hPqLRgK4Q6dgOhs6vsxIwDfGxxUlM58Pa+JisE5J IJmJWmxjnBtKHgY9 X-Received: by 10.28.62.139 with SMTP id l133mr24990641wma.130.1492105650586; Thu, 13 Apr 2017 10:47:30 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5e00:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id i144sm11379402wmf.13.2017.04.13.10.47.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Apr 2017 10:47:30 -0700 (PDT) Message-Id: <20170413174729.360160034@gmail.com> User-Agent: quilt/0.65 Date: Thu, 13 Apr 2017 18:41:31 +0100 From: Okash Khawaja To: Samuel Thibault Cc: speakup@linux-speakup.org Subject: [patch 3/7] tty: export tty_open_by_driver References: <20170413174128.794011516@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=03_export_tty_open_by_driver X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2017 17:53:04 -0000 This applies on top of the changes already in staging-next branch which allow kernel access to TTY dev. Signe-doff-by: Okash Khawaja Reviewed-by: Samuel Thibault Index: linux-staging/drivers/tty/tty_io.c =================================================================== --- linux-staging.orig/drivers/tty/tty_io.c +++ linux-staging/drivers/tty/tty_io.c @@ -1369,7 +1369,10 @@ static struct tty_struct *tty_driver_loo struct tty_struct *tty; if (driver->ops->lookup) - tty = driver->ops->lookup(driver, file, idx); + if (!file) + tty = ERR_PTR(-EIO); + else + tty = driver->ops->lookup(driver, file, idx); else tty = driver->ttys[idx]; @@ -2001,7 +2004,7 @@ static struct tty_driver *tty_lookup_dri struct tty_driver *console_driver = console_device(index); if (console_driver) { driver = tty_driver_kref_get(console_driver); - if (driver) { + if (driver && filp) { /* Don't let /dev/console block */ filp->f_flags |= O_NONBLOCK; break; @@ -2034,7 +2037,7 @@ static struct tty_driver *tty_lookup_dri * - concurrent tty driver removal w/ lookup * - concurrent tty removal from driver table */ -static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, +struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, struct file *filp) { struct tty_struct *tty; @@ -2079,6 +2082,7 @@ out: tty_driver_kref_put(driver); return tty; } +EXPORT_SYMBOL(tty_open_by_driver); /** * tty_open - open a tty device Index: linux-staging/include/linux/tty.h =================================================================== --- linux-staging.orig/include/linux/tty.h +++ linux-staging/include/linux/tty.h @@ -401,6 +401,8 @@ extern struct tty_struct *get_current_tt /* tty_io.c */ extern int __init tty_init(void); extern const char *tty_name(const struct tty_struct *tty); +extern struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, + struct file *filp); #else static inline void console_init(void) { }