Consolidate duplicated information about ut_tv and ut_session

on biarch platforms.
This commit is contained in:
Michael Kerrisk 2008-06-29 05:24:03 +00:00
parent b40e1143a6
commit 3721bd3f13
1 changed files with 27 additions and 35 deletions

View File

@ -210,34 +210,6 @@ or
.BR agetty (8)).
None of these programs creates the file, so if it is
removed, record-keeping is turned off.
.PP
Note that on \fIbiarch\fP platforms, that is, systems which can run both
32-bit and 64-bit applications (x86-64, ppc64, s390x, etc.),
\fIut_tv\fP is the same size in 32-bit mode as in 64-bit mode.
The same goes for \fIut_session\fP and \fIut_time\fP if they are present.
This allows data files and shared memory to be shared between
32-bit and 64-bit applications.
Since \fIut_tv\fP may not be the same as \fIstruct timeval\fP,
then instead of the call:
.in +4n
.nf
.sp
gettimeofday((struct timeval *) &ut.ut_tv, NULL);
.fi
.in
the following method of setting this field is recommended:
.in +4n
.nf
.sp
struct utmp ut;
struct timeval tv;
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_tv.tv_usec = tv.tv_usec;
.fi
.in
.SH FILES
/var/run/utmp
.br
@ -284,9 +256,12 @@ binaries using the old libc5 struct will corrupt
The file format is machine-dependent, so it is recommended that it be
processed only on the machine architecture where it was created.
.PP
Note that on platforms which can run both 32-bit and 64-bit applications
(x86-64, ppc64, s390x, etc.), the sizes of the fields of a \fIutmp\fP struct
must be the same in 32-bit mode as in 64-bit mode.
Note that on \fIbiarch\fP platforms, that is, systems which can run both
32-bit and 64-bit applications (x86-64, ppc64, s390x, etc.),
\fIut_tv\fP is the same size in 32-bit mode as in 64-bit mode.
The same goes for \fIut_session\fP and \fIut_time\fP if they are present.
This allows data files and shared memory to be shared between
32-bit and 64-bit applications.
This is achieved by changing the type of
.I ut_session
to
@ -299,10 +274,27 @@ fields
.I tv_sec
and
.IR tv_usec .
(Thus, in order to fill it, first get the
time into a real \fIstruct timeval\fP,
then copy the two fields to
.IR ut_tv .)
Since \fIut_tv\fP may not be the same as \fIstruct timeval\fP,
then instead of the call:
.in +4n
.nf
.sp
gettimeofday((struct timeval *) &ut.ut_tv, NULL);
.fi
.in
the following method of setting this field is recommended:
.in +4n
.nf
.sp
struct utmp ut;
struct timeval tv;
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_tv.tv_usec = tv.tv_usec;
.fi
.in
.SH BUGS
This man page is based on the libc5 one, things may work differently now.
.SH "SEE ALSO"