Commit 612d5b99 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] make devpts filesystem mandatory even for CONFIG_DEVFS

This patch rips out handling of UNIX98 ptys from devfs.  We already
have a special small filesystem to handle it (devpts) that's always
compiled in anyway.  This allows to get rid of all DEVFS_FL* flags and
some gunk in devfs.
parent 8f8d237e
...@@ -305,7 +305,6 @@ static void pty_flush_buffer(struct tty_struct *tty) ...@@ -305,7 +305,6 @@ static void pty_flush_buffer(struct tty_struct *tty)
} }
} }
extern void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor);
static int pty_open(struct tty_struct *tty, struct file * filp) static int pty_open(struct tty_struct *tty, struct file * filp)
{ {
int retval; int retval;
...@@ -333,13 +332,6 @@ static int pty_open(struct tty_struct *tty, struct file * filp) ...@@ -333,13 +332,6 @@ static int pty_open(struct tty_struct *tty, struct file * filp)
wake_up_interruptible(&pty->open_wait); wake_up_interruptible(&pty->open_wait);
set_bit(TTY_THROTTLED, &tty->flags); set_bit(TTY_THROTTLED, &tty->flags);
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
/* Register a slave for the master */
if (tty->driver.major == PTY_MASTER_MAJOR)
tty_register_devfs(&tty->link->driver,
DEVFS_FL_CURRENT_OWNER | DEVFS_FL_WAIT,
tty->link->driver.minor_start +
minor(tty->device)-tty->driver.minor_start);
retval = 0; retval = 0;
out: out:
return retval; return retval;
......
...@@ -1355,46 +1355,38 @@ static int tty_open(struct inode * inode, struct file * filp) ...@@ -1355,46 +1355,38 @@ static int tty_open(struct inode * inode, struct file * filp)
if (IS_PTMX_DEV(device)) { if (IS_PTMX_DEV(device)) {
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
/* find a free pty. */ /* find a free pty. */
int major, minor; int major, minor;
struct tty_driver *driver; struct tty_driver *driver;
/* find a device that is not in use. */ /* find a device that is not in use. */
retval = -1; retval = -1;
for ( major = 0 ; major < UNIX98_NR_MAJORS ; major++ ) { for (major = 0 ; major < UNIX98_NR_MAJORS ; major++) {
driver = &ptm_driver[major]; driver = &ptm_driver[major];
for (minor = driver->minor_start ; for (minor = driver->minor_start;
minor < driver->minor_start + driver->num ; minor < driver->minor_start + driver->num;
minor++) { minor++) {
device = mk_kdev(driver->major, minor); device = mk_kdev(driver->major, minor);
if (!init_dev(device, &tty)) goto ptmx_found; /* ok! */ if (!init_dev(device, &tty))
goto ptmx_found; /* ok! */
} }
} }
return -EIO; /* no free ptys */ return -EIO; /* no free ptys */
ptmx_found: ptmx_found:
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
minor -= driver->minor_start; minor -= driver->minor_start;
devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start)); devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start));
tty_register_device(&pts_driver[major],
pts_driver[major].minor_start + minor);
noctty = 1; noctty = 1;
goto init_dev_done; #else
#else /* CONFIG_UNIX_98_PTYS */
return -ENODEV; return -ENODEV;
#endif /* CONFIG_UNIX_98_PTYS */ #endif /* CONFIG_UNIX_98_PTYS */
} } else {
retval = init_dev(device, &tty); retval = init_dev(device, &tty);
if (retval) if (retval)
return retval; return retval;
}
#ifdef CONFIG_UNIX98_PTYS
init_dev_done:
#endif
filp->private_data = tty; filp->private_data = tty;
file_move(filp, &tty->tty_files); file_move(filp, &tty->tty_files);
check_tty_count(tty, "tty_open"); check_tty_count(tty, "tty_open");
...@@ -2052,51 +2044,48 @@ static void tty_default_put_char(struct tty_struct *tty, unsigned char ch) ...@@ -2052,51 +2044,48 @@ static void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
tty->driver.write(tty, 0, &ch, 1); tty->driver.write(tty, 0, &ch, 1);
} }
void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor)
{
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
static void tty_register_devfs(struct tty_driver *driver, unsigned minor)
{
umode_t mode = S_IFCHR | S_IRUSR | S_IWUSR; umode_t mode = S_IFCHR | S_IRUSR | S_IWUSR;
kdev_t device = mk_kdev(driver->major, minor); kdev_t dev = mk_kdev(driver->major, minor);
int idx = minor - driver->minor_start; int idx = minor - driver->minor_start;
char buf[32]; char buf[32];
if (IS_TTY_DEV(device) || IS_PTMX_DEV(device)) if ((minor < driver->minor_start) ||
mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; (minor >= driver->minor_start + driver->num)) {
else {
if (driver->major == PTY_MASTER_MAJOR)
mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
}
if ( (minor < driver->minor_start) ||
(minor >= driver->minor_start + driver->num) ) {
printk(KERN_ERR "Attempt to register invalid minor number " printk(KERN_ERR "Attempt to register invalid minor number "
"with devfs (%d:%d).\n", (int)driver->major,(int)minor); "with devfs (%d:%d).\n", (int)driver->major,(int)minor);
return; return;
} }
# ifdef CONFIG_UNIX98_PTYS
if ( (driver->major >= UNIX98_PTY_SLAVE_MAJOR) && if (IS_TTY_DEV(dev) || IS_PTMX_DEV(dev))
(driver->major < UNIX98_PTY_SLAVE_MAJOR + UNIX98_NR_MAJORS) ) mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
flags |= DEVFS_FL_CURRENT_OWNER;
# endif
sprintf(buf, driver->name, idx + driver->name_base); sprintf(buf, driver->name, idx + driver->name_base);
devfs_register (NULL, buf, flags | DEVFS_FL_DEFAULT, devfs_register(NULL, buf, 0, driver->major, minor, mode,
driver->major, minor, mode, &tty_fops, NULL); &tty_fops, NULL);
#endif /* CONFIG_DEVFS_FS */
} }
void tty_unregister_devfs (struct tty_driver *driver, unsigned minor) static void tty_unregister_devfs(struct tty_driver *driver, unsigned minor)
{ {
devfs_remove(driver->name, minor-driver->minor_start+driver->name_base); devfs_remove(driver->name,
minor - driver->minor_start + driver->name_base);
} }
#else
# define tty_register_devfs(driver, minor) do { } while (0)
# define tty_unregister_devfs(driver, minor) do { } while (0)
#endif /* CONFIG_DEVFS_FS */
/* /*
* Register a tty device described by <driver>, with minor number <minor>. * Register a tty device described by <driver>, with minor number <minor>.
*/ */
void tty_register_device (struct tty_driver *driver, unsigned minor) void tty_register_device(struct tty_driver *driver, unsigned minor)
{ {
tty_register_devfs(driver, 0, minor); tty_register_devfs(driver, minor);
} }
void tty_unregister_device (struct tty_driver *driver, unsigned minor) void tty_unregister_device(struct tty_driver *driver, unsigned minor)
{ {
tty_unregister_devfs(driver, minor); tty_unregister_devfs(driver, minor);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment