question on tty open and close

From: Oliver Neukum
Date: Wed Mar 28 2007 - 07:38:47 EST


Hi,

in tty_io.c::tty_open():

if (!retval) {
if (tty->driver->open)
retval = tty->driver->open(tty, filp);
else
retval = -ENODEV;
}
filp->f_flags = saved_flags;

if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
retval = -EBUSY;

if (retval) {
#ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "error %d in opening %s...", retval,
tty->name);
#endif
release_dev(filp);

We find that a failure in open() leads to release_dev() being called.
release_dev() calls close():

if (tty->driver->close)
tty->driver->close(tty, filp);

So we have a file that's closed although open() never succeeded?
What's the reason for that?

Regards
Oliver
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/