Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getutx(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ttyslot(3C)

utmp(4)

utmpx(4)

getutx(3C)                                                       getutx(3C)

NAME
     getutx: getutxent, getutxid, getutxline, pututxline, setutxent,
     endutxent, utmpxname, getutmp, getutmpx, updwtmp, updwtmpx - access
     utmpx file entry

SYNOPSIS
     #include <utmpx.h>

     struct utmpx *getutxent(void);

     struct utmpx *getutxid(const struct utmpx *id);

     struct utmpx *getutxline(const struct utmpx *line);

     struct utmpx *pututxline(const struct utmpx *utmpx);

     void setutxent(void);

     void endutxent(void);

     int utmpxname(const char *file);

     void getutmp(struct utmpx *utmpx, struct utmp *utmp);

     void getutmpx(struct utmp *utmp, struct utmpx *utmpx);

     void updwtmp(char *wfile, struct utmp *utmp);

     void updwtmpx(char *wfilex, struct utmpx *utmpx);

DESCRIPTION
     getutxent(), getutxid(), and getutxline() each return a pointer to a
     structure of the following type:

     struct     utmpx {
         char     utuser[32];  /* user login name */
         char     utid[4];     /* /sbin/inittab id (usually line #) */
         char     utline[32];  /* device name (console, lnxx) */
         pidt    utpid;       /* process id */
         short    uttype;      /* type of entry */
         struct     exitstatus {
             short     etermination; /* termination status */
             short     eexit;        /* exit status */
         } utexit; /* exit status of a process */
                      /* marked as DEADPROCESS */
         struct timeval     uttv;     /* time entry was made */
         short utsyslen;     /* significant length of uthost */
                              /* including terminating null */
         char     uthost[257];     /* host name, if remote */
     };





Page 1                       Reliant UNIX 5.44                Printed 11/98

getutx(3C)                                                       getutx(3C)

     getutxent() reads in the next entry from a utmpx-like file. If the
     file is not already open, it opens it. If it reaches the end of the
     file, it fails.

     getutxid() searches forward from the current point in the utmpx file
     until it finds an entry with a uttype matching id->uttype if the
     type specified is RUNLVL, BOOTTIME, OLDTIME, or NEWTIME. If the
     type specified in id is INITPROCESS, LOGINPROCESS, USERPROCESS, or
     DEADPROCESS, then getutxid() will return a pointer to the first entry
     whose type is one of these four and whose utid field matches id-
     >utid. If the end of file is reached without a match, it fails.

     uttype member           Other members with meaningful data
     ___________________________________________________________________
     EMPTY            No others
     BOOTTIME        uttv
     OLDTIME         uttv
     NEWTIME         uttv
     USERPROCESS     utid, utuser (login name of the user), utline,
                      utpid, uttv
     INITPROCESS     utid, utpid, uttv
     LOGINPROCESS    utid, utuser (implementation-specific name of
                      the login process), utpid, uttv
     DEADPROCESS     utid, utpid, uttv

     getutxline() searches forward from the current point in the utmpx file
     until it finds an entry of the type LOGINPROCESS or USERPROCESS
     which also has a utline string matching the line->utline string. If
     the end of file is reached without a match, it fails.

     pututxline() writes out the supplied utmpx structure into the utmpx
     file. It uses getutxid() to search forward for the proper place if it
     finds that it is not already at the proper place. It is expected that
     normally the user of pututxline() will have searched for the proper
     entry using one of the getutx() routines. If so, pututxline() will not
     search. If pututxline() does not find a matching slot for the new
     entry, it will add a new entry to the end of the file. It returns a
     pointer to the utmpx structure.

     setutxent() resets the input stream to the beginning of the file. This
     should be done before searching the entire file for a new entry.

     endutxent() closes the open file.

     utmpxname() allows the user to change the name of the file examined,
     from /var/adm/utmpx to any other filename. In most cases, this other
     file will be /var/adm/wtmpx. If the file does not exist, this will not
     be apparent until the first attempt to reference the file is made.
     utmpxname() does not open the file. It just closes the old file if it
     is currently open and saves the new filename. The new filename must
     end with the x character to allow the name of the corresponding utmp
     file to be easily obtainable. Otherwise an error code of 1 is returned.


Page 2                       Reliant UNIX 5.44                Printed 11/98

getutx(3C)                                                       getutx(3C)

     getutmp() copies the information stored in the fields of the utmpx
     structure to the corresponding fields of the utmp structure. If the
     information in any field of utmpx does not fit in the corresponding
     utmp field, the data is truncated.

     getutmpx() copies the information stored in the fields of the utmp
     structure to the corresponding fields of the utmpx structure.

     updwtmp() checks the existence of wfile and its parallel file, whose
     name is obtained by appending an x to wfile. If only one of them
     exists, the second one is created and initialized to reflect the state
     of the existing file. utmp is written to wfile and the corresponding
     utmpx structure is written to the parallel file.

     updwtmpx() checks the existence of wfilex and its parallel file, whose
     name is obtained by truncating the final x from wfilex. If only one of
     them exists, the second one is created and initialized to reflect the
     state of the existing file. utmpx is written to wfilex, and the corre-
     sponding utmp structure is written to the parallel file.

RESULT
     A null pointer is returned upon failure to read, whether for permis-
     sions or having reached the end of file, or upon failure to write.

ERRORS
     The following error code description is function-specific. You will
     find a general description in introprm2(2) or in errno(5).

     No errors are defined for the endutxent(), getutxent(), getutxid(),
     getutxline() and setutxent() functions.

     The pututxline() function may fail if:

     EPERM     The process does not have appropriate privileges.

NOTES
     The most current entry is saved in a static structure. Before reac-
     cessing the file, this entry must be copied. On each call to either
     getutxid() or getutxline(), the routine examines the static structure
     before performing more I/O. If the contents of the static structure
     match what it is searching for, it looks no further. For this reason,
     to use getutxline() to search for identical entries, it would be
     necessary to zero out the static area after each success, or
     getutxline() would just return the same structure over and over again.
     There is one exception to this rule: the implicit read done by
     pututxline() (if the correct place in the file has not yet been
     reached) will not hurt the contents of the static structure returned
     by the getutxent(), getutxid(), or getutxline() routines, if the user
     has just modified those contents and passed the pointer back to
     pututxline().




Page 3                       Reliant UNIX 5.44                Printed 11/98

getutx(3C)                                                       getutx(3C)

     These routines use buffered standard I/O for input, but pututxline()
     uses an unbuffered write to avoid race conditions between processes
     trying to modify the utmpx and wtmpx files.

FILES
     /var/adm/utmp

     /var/adm/utmpx

     /var/adm/wtmp

     /var/adm/wtmpx

SEE ALSO
     ttyslot(3C), utmp(4), utmpx(4).







































Page 4                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026