2 Proprietary Rand Corporation
, 1981.
3 Further distribution of
this software
4 subject to the terms of the Rand
13 /* this routine returns the internal number */
14 /* of the given tty name (string) */
15 /* if the name="tty" or "", the number is that */
16 /* of the user's tty. */
17 /* this is obviously very system dependent */
18 register int major
, minor
, flags
;
20 struct { char low
, high
; };
22 if (*name
== '\0' || equal(name
,"tty")) {
23 if (fstat(2,&ibuf
) < 0 &&
24 fstat(1,&ibuf
) < 0) return(-1);
27 if (stat(cat("/dev/",name
),&ibuf
) < 0 &&
28 stat(cat("/dev/tty",name
),&ibuf
) < 0) return(-1);
30 if ((flags
& IFMT
) != IFCHR
) return(-1);
31 minor
= ibuf
.i_addr
[0].low
;
32 major
= ibuf
.i_addr
[0].high
;