Alan Barrett <apb%cequrux.com@localhost> writes: > On Tue, 11 Nov 2014, Aymeric Vincent wrote: >>while looking at usr.bin/login/login.c, I noticed the following strange >>test: >> >> if (tty[sizeof("tty")-1] == 'd') >> syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name); > > That's a little strange. If we really want such log messages, then > they should probably be conditional on bits in the device minor > number, rather than conditional on the spelling of the name. > > We could invent a new ioctl for "is this a dialout device?", or add a > new bit to the data returned by an existing ioctl (perhaps TIOCMGET). > > Theoretically, each tty-like driver makes its own decision about how > to interpret the minor bits. In practice, they almost all use 0x80000 > for dialout: > > sys/dev/ic/cd18xxvar.h:#define CD18XX_DIALOUT(x) ((minor(x) & 0x80000) != 0) > sys/dev/ic/clmpcc.c:#define CLMPCCDIALOUT(x) (minor(x) & 0x80000) > sys/dev/ic/com.c:#define COMDIALOUT_MASK 0x80000 > sys/dev/ic/cy.c:#define CYDIALOUT_MASK 0x80000 > sys/dev/ic/z8530tty.c:#define ZSDIALOUT(x) (minor(x) & 0x80000) > sys/dev/marvell/gtmpsc.c:#define GTMPSCDIALOUT_MASK 0x80000 > sys/dev/pci/cz.c:#define CZTTYDIALOUT_MASK 0x80000 > sys/dev/usb/ucom.c:#define UCOMDIALOUT_MASK 0x80000 > sys/dev/usb/ucycom.c:#define UCYCOMDIALOUT_MASK 0x80000 > sys/dev/usb/uhso.c:#define UHSO_DIALOUT_MASK 0x80000 > > However, these do not use 0x80000: > > sys/dev/sbus/magmareg.h:#define MTTY_DIALOUT(x) (minor(x) & 0x10) > sys/dev/sbus/spifreg.h:#define STTY_DIALOUT(x) (minor(x) & 0x10) It would seem a suggested exercise for the reader to host this macro to an MI place and have all the drivers use it, move the two that don't, and also use it in login.c.
Attachment:
pgp6_ZY1vDsHK.pgp
Description: PGP signature