ttyslot() 함수 해석을 제나름대로 해봤습니다. 확인한번 부탁드릴게요

anaud2의 이미지

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.
(유산 기능ttyslot()은 어떤 파일안에 현재 사용자 s 입장의 색인을 돌려보낸다 어떤파일 이냐고 물어본다면 history를 봐라)

Ancient History
There used to be a file /etc/ttys in Unix V6, that was read by the init(8) program to
(Unix v6에서는 /etc/ttys에 파일이 있다 . either terminal lin을 읽기 위해서 그파일을 init프로그램으로 읽어 들인다. Each line 은 3개의 char로 이루어져 있다?)
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".
(첫번째 char는 0이나 1 , 0은 "ignore".을 의도한다.)
The second character denoted the terminal: '8' stood for "/dev/tty8".
(두번째 char는 terminal의 값이다 예 8-> /dev/tty8")
The third character was an argument to getty(8) indicating the sequence of line speeds to try ('-' was: start trying 110 baud).(3번째 문자는 getty의 반복속도의 인자값이다’-‘은 시작속도 110baud이다)
Thus a typical line was "18-". (이렇듯이 전형적인 line 은 “18-“이다.)
A hang on some line was solved by changing the '1' to a '0', signalling init, changing back again, and signalling init again. (신호방식이 1이나 0에 따라 신호방식 init back again and init이다)

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) (3번째 문자는 getty의 반복속도의 인자값이다’0‘은 사이클 속도 300-1200-150-110 baud 4는 console DECwriter)
while the rest of the line contained the name of the tty. (Line의 나머지가 tty를 포함하는동안 Thus a typical line was "14console". 이와 같은 대표적line은 "14console")

Later systems have more elaborate syntax. (나중의 시스템에는 더욱 정교한 syntax가 있다.) SYSV-like systems have /etc/inittab instead. (SYSV 시스템은 /etc/inittab 대신가지고있다.)

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). (이와반대로, 현재 접속되는 사람을 목록으로 만들는 파일/etc/utmp있는다. 그것은login(8)에의해 유지된다)
It has a fixed size, and the appropriate index in the file was determined by login(8)
(그것은 조정크기가 있고 파일안의 index login에 의해서 결정된다.)
using the ttyslot() call to find the number of the line in /etc/ttys (counting from 1).
(Ttyslot()을 사용하여 /etc/ttys 의 line 번호를 찾는다 )

The semantics of ttyslot (ttyslot의 의미론)
Thus, the function ttyslot() returns the index of the controlling terminal of the current process in the file /etc/ttys, (이와 같이 ttyslot함수는 /etc/ttys의 최신 terminal 프로세스의 컨트롤 index를 리턴한다.)
and that is (usually) the same as the index of the entry for the current user in the file /etc/utmp. (그리고 그것은 /etc/utmp.의 현재사용자의 entry index와 같다.)
BSD still has the /etc/ttys file, but SYSV-like systems do not, and hence cannot refer to it. (BSD는 여전히 /etc/ttys file이 있다 그러나 SYSV 시스템에는 없다. 그리고 때에따라서는 위탁되지 않는다.)
Thus, on such systems the documentation says that ttyslot() returns the current user's index in the user accounting data base.
(따라서, 그런 체계에ttyslot()이 사용자 회계 데이타베이스안에 현재 사용자 s 색인을 돌려보내는 것과 문서 제시는 말한다.)

RETURN VALUE
If successful, this function returns the slot number.
함수 성공시 slot번호를 전달한다.
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. (에러시에는 Unix V6 and V7 and BSD-like systems,에서는 0을YSV-like systems에서는 -1을 리턴한다. )

NOTES
The utmp file is found various places on various systems, (utmp 파일은 각종 체계에서 발견한 각종 장소이다(?))
such as /etc/utmp, /var/adm/utmp, /var/run/utmp. (여기서 찾는다.)

The glibc2 implementation of this function reads the file _PATH_TTYS, (이함수는 _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.
(를 선언해야 되고 /etc/ttys가 있어야 하고 일반적으로 리눅스 시스템에는 /etc/ttys 가 없다 그러면 항상 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)

"( )"안에 있는게 제가 해석한 부분입니다. 원본은 밑에도 올렸으니까 따로 안올릴게요 제나름대로 인터넷과 단어 해석을 곁들여서 해석을 해봤는데 무슨뜻인지
잘알기 어렵네요;;;
그러나 분명한것은 제가 사용하고 있는 리눅스 시스템에 /etc/ttys가 없고 ttyslot()를 호출하면 0이 리턴이 되어요
===============================================================================================================================
defined in as "/etc/ttys". It returns 0 on error. Since Linux systems do not usually have "/etc/ttys", it will always return 0.
(를 선언해야 되고 /etc/ttys가 있어야 하고 일반적으로 리눅스 시스템에는 /etc/ttys 가 없다 그러면 항상 0을 리턴한다.)
===============================================================================================================================
자료에서 이렇게 되어있는거롤 봐서 리눅스에는 원래 없는것인지....이함수를 제가 분석,변형해야하는 파일에 사용하고 있기에 다른 해결책을 찾아야 하는데
저걸 어디서 가져 올수 있는것인지 난감하네요...

도움에 손길이 절실합니다. ㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.