Messages in this thread |  | | | Date | Mon, 15 Jun 1998 12:11:37 +1000 | | From | Richard Gooch <> | | Subject | Re: Can I open a special file with major/minor instead of name? |
| |
Dave Cinege writes: > Richard Gooch wrote: > > > > > So.....how can I do this: (void) open( MKDEV(TTY_MAJOR,1) ,O_RDWR,0); > > > with 2.0? > > > > Check out <chrdev_open> in fs/devices.c > > I knew about this but I didn't think it opened it right at fd 0. > > Well it looks like it...might. Linuxrc gets run fine but the kernel starts > screaming at me: > > Warning: dev (04:01) tty->count(1) != #fd's(0) in do_tty_hangup > > Warning: dev (04:01) tty->count(3) != #fd's(2) in tty_open > Warning: dev (04:01) tty->count(3) != #fd's(2) in release_dev > > Warning: dev (04:01) tty->count(2) != #fd's(1) in tty_open > Warning: dev (04:01) tty->count(2) != #fd's(1) in release_dev > > > Am I not closing it right? (Look for major stupidities, I'm not in my C groove > right now : P) > > > static int do_linuxrc(void * shell) > { > int rc; > struct inode inode; > struct file file; > > static char *argv[] = { "linuxrc", NULL, }; > > close(0);close(1);close(2); > setsid(); > > memset(&file, 0, sizeof(file)); > memset(&inode, 0, sizeof(inode)); > inode.i_rdev = MKDEV(TTY_MAJOR,1); > file.f_mode = 3; > file.f_inode = &inode; > (void) chrdev_open(&inode, &file); > (void) dup(0); > (void) dup(0); > > rc = execve(shell, argv, envp_init); > > if (file.f_op->release) > file.f_op->release(&inode, &file); > > return rc; > }
You probably should use <get_empty_filp> in fs/file_table.c
Regards,
Richard.... - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
|  |