mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
pty: use new anonymous devfs operations
Switch the old hacky way of registering a new pty master into using the new anonymous api.
This commit is contained in:
+4
-9
@@ -261,25 +261,20 @@ static int open(int oldminor, vnode_t **vnode, int flags) {
|
|||||||
|
|
||||||
pty->minor = newminor;
|
pty->minor = newminor;
|
||||||
|
|
||||||
char tmpname[20];
|
int error = devfs_register_anonymous(&devops, V_TYPE_CHDEV, DEV_MAJOR_PTY, newminor,
|
||||||
snprintf(tmpname, 20, ".ptmx%d", newminor);
|
0, NULL, &pty->mastervnode);
|
||||||
|
|
||||||
// register a master device and immediatelly remove it from the filesystem and tables
|
|
||||||
// while holding the refcount
|
|
||||||
int error = devfs_register(&devops, tmpname, V_TYPE_CHDEV, DEV_MAJOR_PTY, newminor, 0, NULL);
|
|
||||||
if (error) {
|
if (error) {
|
||||||
freeptyminor(newminor);
|
freeptyminor(newminor);
|
||||||
freepty(pty);
|
freepty(pty);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
__assert(devfs_getbyname(tmpname, &pty->mastervnode) == 0);
|
devfs_remove_anonymous(DEV_MAJOR_PTY, newminor);
|
||||||
|
|
||||||
devfs_remove(tmpname, DEV_MAJOR_PTY, newminor);
|
|
||||||
|
|
||||||
// we are now the only ones to hold the master vnode and its inaccessible from devfs
|
// we are now the only ones to hold the master vnode and its inaccessible from devfs
|
||||||
// create a pairing slave device
|
// create a pairing slave device
|
||||||
|
|
||||||
|
char tmpname[20];
|
||||||
snprintf(tmpname, 20, "pts/%d", newminor);
|
snprintf(tmpname, 20, "pts/%d", newminor);
|
||||||
pty->tty = tty_create(tmpname, writetopty, ttyinactive, NULL, hup_check, pty);
|
pty->tty = tty_create(tmpname, writetopty, ttyinactive, NULL, hup_check, pty);
|
||||||
if (pty->tty == NULL) {
|
if (pty->tty == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user