chdir in getty

Rob Landley rob at landley.net
Sat Sep 10 02:56:38 UTC 2005


On Thursday 08 September 2005 02:45, Ladislav Michl wrote:
> Getty implementation is as well as util-linux one based on agetty.c -
> "another getty program for Linux" which changes dir to /dev in open_tty:
>
>  if (chdir("/dev"))
>   error("/dev: chdir() failed: %m");
>
> (Also note %m, which doesn't work in busybox)

No, %m is a gnu extension to glibc, one which uclibc supports via a CONFIG_ 
option.

> Now, when you choose some 
> other login program, like /bin/sh for testing purposes, you end in /dev
> as working directory, which is a bit unfortunate. Btw, Linux kernel does
> sys_chdir("/root") in do_mount_root.

And then a pivot_root, I thought.

> Also chown(tty, 0, 0) and 
> chmod(tty, 0622) can be avoided when tty is already connected to std
> input/output.

Doesn't hurt anything, and is generic for the tty being all sorts of things 
(serial consoles are pretty common in the embedded world).

> Is there any reason for changing directory to /dev? Any objections to
> rewrite it to use absolute path and avoid chdir when working with device
> node?

Hmmm...  I don't know who maintains this.  The code doesn't mention who ported 
it to busybox, and the AUTHORS file doesn't mention it at all.

The oldest source control entry (3 years ago) is by somebody named "sandman", 
and I have no idea how to look up users in the source control system.

Hey Erik!

Rob



More information about the busybox mailing list