리눅스 ttyslot() 에 해석 좀 도와 주세요 ㅠ
소스 분석을 하고 있는데요 telnet서버 입니다..
조금 제게 어려운 문제와 부딪쳐서 어려움이 많네요 그중 처음 보는 함수인데 이부분 때문에 실행이 멈추고 있습니다. man페이지를 봤지만
제 짧은영어로는 어떤뜻인지 좀 해석이 안되네요 경로가 나와있는곳을 봐도 제가 리눅스에는 파일도 없고... 어떤뜻인지 죄송하지만 도움을 요청해 드립니다.
대략적인 뜻이라도 저에겐 큰 도움이 됩니다.
TTYSLOT(3) Linux Programmer's Manual TTYSLOT(3)
NAME
ttyslot - find the slot of the current user's terminal in some file
SYNOPSIS
#include /* on BSD-like systems */
#include /* on SYSV-like systems */
int ttyslot(void);
DESCRIPTION
The legacy function ttyslot() returns the index of the current user's entry in some file.
Now "What file?" you ask. Well, let's first look at some history.
Ancient History
There used to be a file /etc/ttys in Unix V6, that was read by the init(8) program to find out what to do with each terminal line. Each line consisted of three characters. The first character was either '0' or '1', where '0' meant "ignore". The second character denoted the terminal: '8' stood for "/dev/tty8". The third character was an argument to getty(8) indicating the sequence of line speeds to try ('-' was: start trying 110 baud). Thus a typical line was "18-".A hang on some line was solved by changing the '1' to a '0', signalling init, changing back again, and signalling init again.
In Unix V7 the format was changed: here the second character was the argument to getty(8) indicating the sequence of line speeds to try ('0' was: cycle through 300-1200-150-110 baud; '4' was for the on-line console DECwriter) while the rest of the line contained the name of the tty. Thus a typical line was "14console".
Later systems have more elaborate syntax. SYSV-like systems have /etc/inittab instead.
Ancient History (2)
On the other hand, there is the file /etc/utmp listing the people currently logged in. It is maintained by login(8). It has a fixed size, and the appropriate index in the file was determined by login(8) using the ttyslot() call to find the number of the line in /etc/ttys (counting from 1).
The semantics of ttyslot
Thus, the function ttyslot() returns the index of the controlling terminal of the current process in the file /etc/ttys, and that is (usually) the same as the index of the entry for the current user in the file /etc/utmp. BSD still has the /etc/ttys file, but SYSV-like systems do not, and hence cannot refer to it. Thus, on such systems the documentation says that ttyslot() returns the current user's index in the user accounting data base.
RETURN VALUE
If successful, this function returns the slot number. On error (e.g., if none of the file descriptors 0, 1 or 2 is associated with a terminal that occurs in this data base) it returns 0 on Unix V6 and V7 and BSD-like systems, but -1 on SYSV-like systems.
NOTES
The utmp file is found various places on various systems, such /etc/utmp, /var/adm/utmp, /var/run/utmp.
The glibc2 implementation of this function reads the file _PATH_TTYS, defined in as "/etc/ttys". It returns 0 on error. Since Linux systems do not usually have "/etc/ttys", it will always return 0.
Minix also has fttyslot(fd).
HISTORY
ttyslot() appeared in Unix V7.
CONFORMS TO
XPG2. Legacy in SUSv2. Deleted in SUSv3. SUSv2 requires -1 on error.
SEE ALSO
getttyent(3), ttyname(3), utmp(5)
댓글 달기