All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org, alan@lxorguk.ukuu.org.uk,
	hpa@zytor.com, gregkh@linuxfoundation.org, xemul@parallels.com
Subject: Re: [patch 2/2] tty: Add get- ioctls to fetch tty status v2
Date: Thu, 27 Sep 2012 21:58:30 +0400	[thread overview]
Message-ID: <20120927175830.GT6618@moon> (raw)
In-Reply-To: <506491C1.7060807@suse.cz>

On Thu, Sep 27, 2012 at 07:49:53PM +0200, Jiri Slaby wrote:
> On 09/27/2012 07:00 PM, Cyrill Gorcunov wrote:
> > @@ -199,6 +207,25 @@ static int pty_set_pktmode(struct tty_st
> >  	return 0;
> >  }
> >  
> > +/* Get the packet mode of a pty */
> > +static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
> > +{
> > +	unsigned long flags;
> > +	int pktmode;
> > +
> > +	if (tty->driver->subtype != PTY_TYPE_MASTER)
> > +		return -ENOTTY;
> 
> The same as for 1/2^UFixed in v3 ;).

Already sent update, thanks :-)

> 
> > +	spin_lock_irqsave(&tty->ctrl_lock, flags);
> 
> I believe the lock is not the right one. It protects ctrl_status in
> TIOCPKT, not the packet. And it very seems that packet is unprotected at
> all over the code => the lock does not improve anything and is redundant.

Indeed, thanks Jiri!

> 
> > +	pktmode = tty->packet;
> > +	spin_unlock_irqrestore(&tty->ctrl_lock, flags);
> > +
> > +	if (put_user(pktmode, arg))
> > +		return -EFAULT;
> > +
> > +	return 0;
> 
> This can be just
>   return put_user(pktmode, arg);
> Right?

As far as I see, yeah, put_user_[n] does return -efault
as well.

> 
> > +}
> > +
> ...
> > --- tty.git.orig/include/asm-generic/ioctls.h
> > +++ tty.git/include/asm-generic/ioctls.h
> > @@ -74,6 +74,9 @@
> >  #define TCSETXW		0x5435
> >  #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
> >  #define TIOCVHANGUP	0x5437
> > +#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
> > +#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
> > +#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
> 
> This is not enough. Some arches do not include this file in their
> ioctls.h. You need to update them all.

Crap, for some reason cscope has not indexed them but git grep helped.
I'll update. Thanks, Jiri!

	Cyrill

  reply	other threads:[~2012-09-27 17:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 16:59 [patch 0/2] Add get- ioctls to fetch some bits from tty/pty status Cyrill Gorcunov
2012-09-27 16:59 ` [patch 1/2] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
2012-09-27 17:33   ` Jiri Slaby
2012-09-27 17:37     ` Cyrill Gorcunov
2012-09-27 18:14       ` Greg KH
2012-09-27 18:18         ` Cyrill Gorcunov
2012-09-27 17:40     ` Cyrill Gorcunov
2012-09-27 17:00 ` [patch 2/2] tty: Add get- ioctls to fetch tty status v2 Cyrill Gorcunov
2012-09-27 17:42   ` Cyrill Gorcunov
2012-09-27 17:49   ` Jiri Slaby
2012-09-27 17:58     ` Cyrill Gorcunov [this message]
2012-09-27 18:01       ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120927175830.GT6618@moon \
    --to=gorcunov@openvz.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.