Blame manual/sysinfo.texi

Packit 6c4009
@node System Management, System Configuration, Users and Groups, Top
Packit 6c4009
@c %MENU% Controlling the system and getting information about it
Packit 6c4009
@chapter System Management
Packit 6c4009
Packit 6c4009
This chapter describes facilities for controlling the system that
Packit 6c4009
underlies a process (including the operating system and hardware) and
Packit 6c4009
for getting information about it.  Anyone can generally use the
Packit 6c4009
informational facilities, but usually only a properly privileged process
Packit 6c4009
can make changes.
Packit 6c4009
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* Host Identification::         Determining the name of the machine.
Packit 6c4009
* Platform Type::               Determining operating system and basic
Packit 6c4009
                                  machine type
Packit 6c4009
* Filesystem Handling::         Controlling/querying mounts
Packit 6c4009
* System Parameters::           Getting and setting various system parameters
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
To get information on parameters of the system that are built into the
Packit 6c4009
system, such as the maximum length of a filename, @ref{System
Packit 6c4009
Configuration}.
Packit 6c4009
Packit 6c4009
@node Host Identification
Packit 6c4009
@section Host Identification
Packit 6c4009
Packit 6c4009
This section explains how to identify the particular system on which your
Packit 6c4009
program is running.  First, let's review the various ways computer systems
Packit 6c4009
are named, which is a little complicated because of the history of the
Packit 6c4009
development of the Internet.
Packit 6c4009
Packit 6c4009
Every Unix system (also known as a host) has a host name, whether it's
Packit 6c4009
connected to a network or not.  In its simplest form, as used before
Packit 6c4009
computer networks were an issue, it's just a word like @samp{chicken}.
Packit 6c4009
@cindex host name
Packit 6c4009
Packit 6c4009
But any system attached to the Internet or any network like it conforms
Packit 6c4009
to a more rigorous naming convention as part of the Domain Name System
Packit 6c4009
(DNS).  In the DNS, every host name is composed of two parts:
Packit 6c4009
@cindex DNS
Packit 6c4009
@cindex Domain Name System
Packit 6c4009
Packit 6c4009
@enumerate
Packit 6c4009
@item
Packit 6c4009
hostname
Packit 6c4009
@cindex hostname
Packit 6c4009
@item
Packit 6c4009
domain name
Packit 6c4009
@cindex domain name
Packit 6c4009
@end enumerate
Packit 6c4009
Packit 6c4009
You will note that ``hostname'' looks a lot like ``host name'', but is
Packit 6c4009
not the same thing, and that people often incorrectly refer to entire
Packit 6c4009
host names as ``domain names.''
Packit 6c4009
Packit 6c4009
In the DNS, the full host name is properly called the FQDN (Fully Qualified
Packit 6c4009
Domain Name) and consists of the hostname, then a period, then the
Packit 6c4009
domain name.  The domain name itself usually has multiple components
Packit 6c4009
separated by periods.  So for example, a system's hostname may be
Packit 6c4009
@samp{chicken} and its domain name might be @samp{ai.mit.edu}, so
Packit 6c4009
its FQDN (which is its host name) is @samp{chicken.ai.mit.edu}.
Packit 6c4009
@cindex FQDN
Packit 6c4009
Packit 6c4009
Adding to the confusion, though, is that the DNS is not the only name space
Packit 6c4009
in which a computer needs to be known.  Another name space is the
Packit 6c4009
NIS (aka YP) name space.  For NIS purposes, there is another domain
Packit 6c4009
name, which is called the NIS domain name or the YP domain name.  It
Packit 6c4009
need not have anything to do with the DNS domain name.
Packit 6c4009
@cindex YP
Packit 6c4009
@cindex NIS
Packit 6c4009
@cindex NIS domain name
Packit 6c4009
@cindex YP domain name
Packit 6c4009
Packit 6c4009
Confusing things even more is the fact that in the DNS, it is possible for
Packit 6c4009
multiple FQDNs to refer to the same system.  However, there is always
Packit 6c4009
exactly one of them that is the true host name, and it is called the
Packit 6c4009
canonical FQDN.
Packit 6c4009
Packit 6c4009
In some contexts, the host name is called a ``node name.''
Packit 6c4009
Packit 6c4009
For more information on DNS host naming, see @ref{Host Names}.
Packit 6c4009
Packit 6c4009
@pindex hostname
Packit 6c4009
@pindex hostid
Packit 6c4009
@pindex unistd.h
Packit 6c4009
Prototypes for these functions appear in @file{unistd.h}.
Packit 6c4009
Packit 6c4009
The programs @code{hostname}, @code{hostid}, and @code{domainname} work
Packit 6c4009
by calling these functions.
Packit 6c4009
Packit 6c4009
@deftypefun int gethostname (char *@var{name}, size_t @var{size})
Packit 6c4009
@standards{BSD, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall on unix; implemented in terms of uname on posix and of
Packit 6c4009
@c hurd_get_host_config on hurd.
Packit 6c4009
This function returns the host name of the system on which it is called,
Packit 6c4009
in the array @var{name}.  The @var{size} argument specifies the size of
Packit 6c4009
this array, in bytes.  Note that this is @emph{not} the DNS hostname.
Packit 6c4009
If the system participates in the DNS, this is the FQDN (see above).
Packit 6c4009
Packit 6c4009
The return value is @code{0} on success and @code{-1} on failure.  In
Packit 6c4009
@theglibc{}, @code{gethostname} fails if @var{size} is not large
Packit 6c4009
enough; then you can try again with a larger array.  The following
Packit 6c4009
@code{errno} error condition is defined for this function:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item ENAMETOOLONG
Packit 6c4009
The @var{size} argument is less than the size of the host name plus one.
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@pindex sys/param.h
Packit 6c4009
On some systems, there is a symbol for the maximum possible host name
Packit 6c4009
length: @code{MAXHOSTNAMELEN}.  It is defined in @file{sys/param.h}.
Packit 6c4009
But you can't count on this to exist, so it is cleaner to handle
Packit 6c4009
failure and try again.
Packit 6c4009
Packit 6c4009
@code{gethostname} stores the beginning of the host name in @var{name}
Packit 6c4009
even if the host name won't entirely fit.  For some purposes, a
Packit 6c4009
truncated host name is good enough.  If it is, you can ignore the
Packit 6c4009
error code.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int sethostname (const char *@var{name}, size_t @var{length})
Packit 6c4009
@standards{BSD, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall on unix; implemented in terms of hurd_set_host_config
Packit 6c4009
@c on hurd.
Packit 6c4009
The @code{sethostname} function sets the host name of the system that
Packit 6c4009
calls it to @var{name}, a string with length @var{length}.  Only
Packit 6c4009
privileged processes are permitted to do this.
Packit 6c4009
Packit 6c4009
Usually @code{sethostname} gets called just once, at system boot time.
Packit 6c4009
Often, the program that calls it sets it to the value it finds in the
Packit 6c4009
file @code{/etc/hostname}.
Packit 6c4009
@cindex /etc/hostname
Packit 6c4009
Packit 6c4009
Be sure to set the host name to the full host name, not just the DNS
Packit 6c4009
hostname (see above).
Packit 6c4009
Packit 6c4009
The return value is @code{0} on success and @code{-1} on failure.
Packit 6c4009
The following @code{errno} error condition is defined for this function:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item EPERM
Packit 6c4009
This process cannot set the host name because it is not privileged.
Packit 6c4009
@end table
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int getdomainnname (char *@var{name}, size_t @var{length})
Packit 6c4009
@standards{???, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Syscalls uname, then strlen and memcpy.
Packit 6c4009
@cindex NIS domain name
Packit 6c4009
@cindex YP domain name
Packit 6c4009
Packit 6c4009
@code{getdomainname} returns the NIS (aka YP) domain name of the system
Packit 6c4009
on which it is called.  Note that this is not the more popular DNS
Packit 6c4009
domain name.  Get that with @code{gethostname}.
Packit 6c4009
Packit 6c4009
The specifics of this function are analogous to @code{gethostname}, above.
Packit 6c4009
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int setdomainname (const char *@var{name}, size_t @var{length})
Packit 6c4009
@standards{???, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall.
Packit 6c4009
@cindex NIS domain name
Packit 6c4009
@cindex YP domain name
Packit 6c4009
Packit 6c4009
@code{setdomainname} sets the NIS (aka YP) domain name of the system
Packit 6c4009
on which it is called.  Note that this is not the more popular DNS
Packit 6c4009
domain name.  Set that with @code{sethostname}.
Packit 6c4009
Packit 6c4009
The specifics of this function are analogous to @code{sethostname}, above.
Packit 6c4009
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {long int} gethostid (void)
Packit 6c4009
@standards{BSD, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{@mtshostid{} @mtsenv{} @mtslocale{}}@asunsafe{@ascudlopen{} @ascuplugin{} @asucorrupt{} @ascuheap{} @asulock{}}@acunsafe{@aculock{} @acucorrupt{} @acsmem{} @acsfd{}}}
Packit 6c4009
@c On HURD, calls _hurd_get_host_config and strtol.  On Linux, open
Packit 6c4009
@c HOSTIDFILE, reads an int32_t and closes; if that fails, it calls
Packit 6c4009
@c gethostname and gethostbyname_r to use the h_addr.
Packit 6c4009
This function returns the ``host ID'' of the machine the program is
Packit 6c4009
running on.  By convention, this is usually the primary Internet IP address
Packit 6c4009
of that machine, converted to a @w{@code{long int}}.  However, on some
Packit 6c4009
systems it is a meaningless but unique number which is hard-coded for
Packit 6c4009
each machine.
Packit 6c4009
Packit 6c4009
This is not widely used.  It arose in BSD 4.2, but was dropped in BSD 4.4.
Packit 6c4009
It is not required by POSIX.
Packit 6c4009
Packit 6c4009
The proper way to query the IP address is to use @code{gethostbyname}
Packit 6c4009
on the results of @code{gethostname}.  For more information on IP addresses,
Packit 6c4009
@xref{Host Addresses}.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int sethostid (long int @var{id})
Packit 6c4009
@standards{BSD, unistd.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasuconst{:@mtshostid{}}}@asunsafe{}@acunsafe{@acucorrupt{} @acsfd{}}}
Packit 6c4009
The @code{sethostid} function sets the ``host ID'' of the host machine
Packit 6c4009
to @var{id}.  Only privileged processes are permitted to do this.  Usually
Packit 6c4009
it happens just once, at system boot time.
Packit 6c4009
Packit 6c4009
The proper way to establish the primary IP address of a system
Packit 6c4009
is to configure the IP address resolver to associate that IP address with
Packit 6c4009
the system's host name as returned by @code{gethostname}.  For example,
Packit 6c4009
put a record for the system in @file{/etc/hosts}.
Packit 6c4009
Packit 6c4009
See @code{gethostid} above for more information on host ids.
Packit 6c4009
Packit 6c4009
The return value is @code{0} on success and @code{-1} on failure.
Packit 6c4009
The following @code{errno} error conditions are defined for this function:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item EPERM
Packit 6c4009
This process cannot set the host name because it is not privileged.
Packit 6c4009
Packit 6c4009
@item ENOSYS
Packit 6c4009
The operating system does not support setting the host ID.  On some
Packit 6c4009
systems, the host ID is a meaningless but unique number hard-coded for
Packit 6c4009
each machine.
Packit 6c4009
@end table
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@node Platform Type
Packit 6c4009
@section Platform Type Identification
Packit 6c4009
Packit 6c4009
You can use the @code{uname} function to find out some information about
Packit 6c4009
the type of computer your program is running on.  This function and the
Packit 6c4009
associated data type are declared in the header file
Packit 6c4009
@file{sys/utsname.h}.
Packit 6c4009
@pindex sys/utsname.h
Packit 6c4009
Packit 6c4009
As a bonus, @code{uname} also gives some information identifying the
Packit 6c4009
particular system your program is running on.  This is the same information
Packit 6c4009
which you can get with functions targeted to this purpose described in
Packit 6c4009
@ref{Host Identification}.
Packit 6c4009
Packit 6c4009
Packit 6c4009
@deftp {Data Type} {struct utsname}
Packit 6c4009
@standards{POSIX.1, sys/utsname.h}
Packit 6c4009
The @code{utsname} structure is used to hold information returned
Packit 6c4009
by the @code{uname} function.  It has the following members:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item char sysname[]
Packit 6c4009
This is the name of the operating system in use.
Packit 6c4009
Packit 6c4009
@item char release[]
Packit 6c4009
This is the current release level of the operating system implementation.
Packit 6c4009
Packit 6c4009
@item char version[]
Packit 6c4009
This is the current version level within the release of the operating
Packit 6c4009
system.
Packit 6c4009
Packit 6c4009
@item char machine[]
Packit 6c4009
This is a description of the type of hardware that is in use.
Packit 6c4009
Packit 6c4009
Some systems provide a mechanism to interrogate the kernel directly for
Packit 6c4009
this information.  On systems without such a mechanism, @theglibc{}
Packit 6c4009
fills in this field based on the configuration name that was
Packit 6c4009
specified when building and installing the library.
Packit 6c4009
Packit 6c4009
GNU uses a three-part name to describe a system configuration; the three
Packit 6c4009
parts are @var{cpu}, @var{manufacturer} and @var{system-type}, and they
Packit 6c4009
are separated with dashes.  Any possible combination of three names is
Packit 6c4009
potentially meaningful, but most such combinations are meaningless in
Packit 6c4009
practice and even the meaningful ones are not necessarily supported by
Packit 6c4009
any particular GNU program.
Packit 6c4009
Packit 6c4009
Since the value in @code{machine} is supposed to describe just the
Packit 6c4009
hardware, it consists of the first two parts of the configuration name:
Packit 6c4009
@samp{@var{cpu}-@var{manufacturer}}.  For example, it might be one of these:
Packit 6c4009
Packit 6c4009
@quotation
Packit 6c4009
@code{"sparc-sun"},
Packit 6c4009
@code{"i386-@var{anything}"},
Packit 6c4009
@code{"m68k-hp"},
Packit 6c4009
@code{"m68k-sony"},
Packit 6c4009
@code{"m68k-sun"},
Packit 6c4009
@code{"mips-dec"}
Packit 6c4009
@end quotation
Packit 6c4009
Packit 6c4009
@item char nodename[]
Packit 6c4009
This is the host name of this particular computer.  In @theglibc{},
Packit 6c4009
the value is the same as that returned by @code{gethostname};
Packit 6c4009
see @ref{Host Identification}.
Packit 6c4009
Packit 6c4009
@code{gethostname} is implemented with a call to @code{uname}.
Packit 6c4009
Packit 6c4009
@item char domainname[]
Packit 6c4009
This is the NIS or YP domain name.  It is the same value returned by
Packit 6c4009
@code{getdomainname}; see @ref{Host Identification}.  This element
Packit 6c4009
is a relatively recent invention and use of it is not as portable as
Packit 6c4009
use of the rest of the structure.
Packit 6c4009
Packit 6c4009
@c getdomainname() is implemented with a call to uname().
Packit 6c4009
Packit 6c4009
@end table
Packit 6c4009
@end deftp
Packit 6c4009
Packit 6c4009
@deftypefun int uname (struct utsname *@var{info})
Packit 6c4009
@standards{POSIX.1, sys/utsname.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall on unix; the posix fallback is to call gethostname and
Packit 6c4009
@c then fills in the other fields with constants; on HURD, it calls
Packit 6c4009
@c proc_uname and then gethostname.
Packit 6c4009
The @code{uname} function fills in the structure pointed to by
Packit 6c4009
@var{info} with information about the operating system and host machine.
Packit 6c4009
A non-negative return value indicates that the data was successfully stored.
Packit 6c4009
Packit 6c4009
@code{-1} as the return value indicates an error.  The only error possible is
Packit 6c4009
@code{EFAULT}, which we normally don't mention as it is always a
Packit 6c4009
possibility.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
Packit 6c4009
@node Filesystem Handling
Packit 6c4009
@section Controlling and Querying Mounts
Packit 6c4009
Packit 6c4009
All files are in filesystems, and before you can access any file, its
Packit 6c4009
filesystem must be mounted.  Because of Unix's concept of
Packit 6c4009
@emph{Everything is a file}, mounting of filesystems is central to doing
Packit 6c4009
almost anything.  This section explains how to find out what filesystems
Packit 6c4009
are currently mounted and what filesystems are available for mounting,
Packit 6c4009
and how to change what is mounted.
Packit 6c4009
Packit 6c4009
The classic filesystem is the contents of a disk drive.  The concept is
Packit 6c4009
considerably more abstract, though, and lots of things other than disk
Packit 6c4009
drives can be mounted.
Packit 6c4009
Packit 6c4009
Some block devices don't correspond to traditional devices like disk
Packit 6c4009
drives.  For example, a loop device is a block device whose driver uses
Packit 6c4009
a regular file in another filesystem as its medium.  So if that regular
Packit 6c4009
file contains appropriate data for a filesystem, you can by mounting the
Packit 6c4009
loop device essentially mount a regular file.
Packit 6c4009
Packit 6c4009
Some filesystems aren't based on a device of any kind.  The ``proc''
Packit 6c4009
filesystem, for example, contains files whose data is made up by the
Packit 6c4009
filesystem driver on the fly whenever you ask for it.  And when you
Packit 6c4009
write to it, the data you write causes changes in the system.  No data
Packit 6c4009
gets stored.
Packit 6c4009
Packit 6c4009
@c It would be good to mention NFS mounts here.
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* Mount Information::           What is or could be mounted?
Packit 6c4009
* Mount-Unmount-Remount::       Controlling what is mounted and how
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
@node Mount Information, Mount-Unmount-Remount, , Filesystem Handling
Packit 6c4009
@subsection Mount Information
Packit 6c4009
Packit 6c4009
For some programs it is desirable and necessary to access information
Packit 6c4009
about whether a certain filesystem is mounted and, if it is, where, or
Packit 6c4009
simply to get lists of all the available filesystems.  @Theglibc{}
Packit 6c4009
provides some functions to retrieve this information portably.
Packit 6c4009
Packit 6c4009
Traditionally Unix systems have a file named @file{/etc/fstab} which
Packit 6c4009
describes all possibly mounted filesystems.  The @code{mount} program
Packit 6c4009
uses this file to mount at startup time of the system all the
Packit 6c4009
necessary filesystems.  The information about all the filesystems
Packit 6c4009
actually mounted is normally kept in a file named either
Packit 6c4009
@file{/var/run/mtab} or @file{/etc/mtab}.  Both files share the same
Packit 6c4009
syntax and it is crucial that this syntax is followed all the time.
Packit 6c4009
Therefore it is best to never directly write to the files.  The functions
Packit 6c4009
described in this section can do this and they also provide the
Packit 6c4009
functionality to convert the external textual representation to the
Packit 6c4009
internal representation.
Packit 6c4009
Packit 6c4009
Note that the @file{fstab} and @file{mtab} files are maintained on a
Packit 6c4009
system by @emph{convention}.  It is possible for the files not to exist
Packit 6c4009
or not to be consistent with what is really mounted or available to
Packit 6c4009
mount, if the system's administration policy allows it.  But programs
Packit 6c4009
that mount and unmount filesystems typically maintain and use these
Packit 6c4009
files as described herein.
Packit 6c4009
Packit 6c4009
@vindex _PATH_FSTAB
Packit 6c4009
@vindex _PATH_MNTTAB
Packit 6c4009
@vindex _PATH_MOUNTED
Packit 6c4009
@vindex FSTAB
Packit 6c4009
@vindex MNTTAB
Packit 6c4009
@vindex MOUNTED
Packit 6c4009
The filenames given above should never be used directly.  The portable
Packit 6c4009
way to handle these files is to use the macros @code{_PATH_FSTAB},
Packit 6c4009
defined in @file{fstab.h}, or @code{_PATH_MNTTAB}, defined in
Packit 6c4009
@file{mntent.h} and @file{paths.h}, for @file{fstab}; and the macro
Packit 6c4009
@code{_PATH_MOUNTED}, also defined in @file{mntent.h} and
Packit 6c4009
@file{paths.h}, for @file{mtab}.  There are also two alternate macro
Packit 6c4009
names @code{FSTAB}, @code{MNTTAB}, and @code{MOUNTED} defined but
Packit 6c4009
these names are deprecated and kept only for backward compatibility.
Packit 6c4009
The names @code{_PATH_MNTTAB} and @code{_PATH_MOUNTED} should always be used.
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* fstab::                       The @file{fstab} file
Packit 6c4009
* mtab::                        The @file{mtab} file
Packit 6c4009
* Other Mount Information::     Other (non-libc) sources of mount information
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
@node fstab
Packit 6c4009
@subsubsection The @file{fstab} file
Packit 6c4009
Packit 6c4009
The internal representation for entries of the file is @w{@code{struct
Packit 6c4009
fstab}}, defined in @file{fstab.h}.
Packit 6c4009
Packit 6c4009
@deftp {Data Type} {struct fstab}
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
This structure is used with the @code{getfsent}, @code{getfsspec}, and
Packit 6c4009
@code{getfsfile} functions.
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item char *fs_spec
Packit 6c4009
This element describes the device from which the filesystem is mounted.
Packit 6c4009
Normally this is the name of a special device, such as a hard disk
Packit 6c4009
partition, but it could also be a more or less generic string.  For
Packit 6c4009
@dfn{NFS} it would be a hostname and directory name combination.
Packit 6c4009
Packit 6c4009
Even though the element is not declared @code{const} it shouldn't be
Packit 6c4009
modified.  The missing @code{const} has historic reasons, since this
Packit 6c4009
function predates @w{ISO C}.  The same is true for the other string
Packit 6c4009
elements of this structure.
Packit 6c4009
Packit 6c4009
@item char *fs_file
Packit 6c4009
This describes the mount point on the local system.  I.e., accessing any
Packit 6c4009
file in this filesystem has implicitly or explicitly this string as a
Packit 6c4009
prefix.
Packit 6c4009
Packit 6c4009
@item char *fs_vfstype
Packit 6c4009
This is the type of the filesystem.  Depending on what the underlying
Packit 6c4009
kernel understands it can be any string.
Packit 6c4009
Packit 6c4009
@item char *fs_mntops
Packit 6c4009
This is a string containing options passed to the kernel with the
Packit 6c4009
@code{mount} call.  Again, this can be almost anything.  There can be
Packit 6c4009
more than one option, separated from the others by a comma.  Each option
Packit 6c4009
consists of a name and an optional value part, introduced by an @code{=}
Packit 6c4009
character.
Packit 6c4009
Packit 6c4009
If the value of this element must be processed it should ideally be done
Packit 6c4009
using the @code{getsubopt} function; see @ref{Suboptions}.
Packit 6c4009
Packit 6c4009
@item const char *fs_type
Packit 6c4009
This name is poorly chosen.  This element points to a string (possibly
Packit 6c4009
in the @code{fs_mntops} string) which describes the modes with which the
Packit 6c4009
filesystem is mounted.  @file{fstab} defines five macros to describe the
Packit 6c4009
possible values:
Packit 6c4009
Packit 6c4009
@vtable @code
Packit 6c4009
@item FSTAB_RW
Packit 6c4009
The filesystem gets mounted with read and write enabled.
Packit 6c4009
@item FSTAB_RQ
Packit 6c4009
The filesystem gets mounted with read and write enabled.  Write access
Packit 6c4009
is restricted by quotas.
Packit 6c4009
@item FSTAB_RO
Packit 6c4009
The filesystem gets mounted read-only.
Packit 6c4009
@item FSTAB_SW
Packit 6c4009
This is not a real filesystem, it is a swap device.
Packit 6c4009
@item FSTAB_XX
Packit 6c4009
This entry from the @file{fstab} file is totally ignored.
Packit 6c4009
@end vtable
Packit 6c4009
Packit 6c4009
Testing for equality with these values must happen using @code{strcmp}
Packit 6c4009
since these are all strings.  Comparing the pointer will probably always
Packit 6c4009
fail.
Packit 6c4009
Packit 6c4009
@item int fs_freq
Packit 6c4009
This element describes the dump frequency in days.
Packit 6c4009
Packit 6c4009
@item int fs_passno
Packit 6c4009
This element describes the pass number on parallel dumps.  It is closely
Packit 6c4009
related to the @code{dump} utility used on Unix systems.
Packit 6c4009
@end table
Packit 6c4009
@end deftp
Packit 6c4009
Packit 6c4009
Packit 6c4009
To read the entire content of the of the @file{fstab} file @theglibc{}
Packit 6c4009
contains a set of three functions which are designed in the usual way.
Packit 6c4009
Packit 6c4009
@deftypefun int setfsent (void)
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:fsent}}@asunsafe{@ascuheap{} @asucorrupt{} @asulock{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{} @acsfd{}}}
Packit 6c4009
@c setfsent @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c  fstab_init(1) @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c   malloc dup @ascuheap @acsmem
Packit 6c4009
@c   rewind dup @asucorrupt @acucorrupt [no @aculock]
Packit 6c4009
@c   setmntent dup @ascuheap @asulock @acsmem @acsfd @aculock
Packit 6c4009
This function makes sure that the internal read pointer for the
Packit 6c4009
@file{fstab} file is at the beginning of the file.  This is done by
Packit 6c4009
either opening the file or resetting the read pointer.
Packit 6c4009
Packit 6c4009
Since the file handle is internal to the libc this function is not
Packit 6c4009
thread-safe.
Packit 6c4009
Packit 6c4009
This function returns a non-zero value if the operation was successful
Packit 6c4009
and the @code{getfs*} functions can be used to read the entries of the
Packit 6c4009
file.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun void endfsent (void)
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:fsent}}@asunsafe{@ascuheap{} @asucorrupt{} @asulock{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{} @acsfd{}}}
Packit 6c4009
@c endfsent @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c  endmntent dup @ascuheap @asulock @aculock @acsmem @acsfd
Packit 6c4009
This function makes sure that all resources acquired by a prior call to
Packit 6c4009
@code{setfsent} (explicitly or implicitly by calling @code{getfsent}) are
Packit 6c4009
freed.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {struct fstab *} getfsent (void)
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:fsent} @mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{}}}
Packit 6c4009
@c getfsent @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @asulock @acucorrupt @aculock @acsmem
Packit 6c4009
@c  fstab_init(0) dup @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c  fstab_fetch @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
@c   getmntent_r dup @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
@c  fstab_convert @mtasurace:fsent
Packit 6c4009
@c   hasmntopt dup ok
Packit 6c4009
This function returns the next entry of the @file{fstab} file.  If this
Packit 6c4009
is the first call to any of the functions handling @file{fstab} since
Packit 6c4009
program start or the last call of @code{endfsent}, the file will be
Packit 6c4009
opened.
Packit 6c4009
Packit 6c4009
The function returns a pointer to a variable of type @code{struct
Packit 6c4009
fstab}.  This variable is shared by all threads and therefore this
Packit 6c4009
function is not thread-safe.  If an error occurred @code{getfsent}
Packit 6c4009
returns a @code{NULL} pointer.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {struct fstab *} getfsspec (const char *@var{name})
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:fsent} @mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{}}}
Packit 6c4009
@c getffsspec @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @asulock @acucorrupt @aculock @acsmem
Packit 6c4009
@c  fstab_init(1) dup @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c  fstab_fetch dup @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
@c  strcmp dup ok
Packit 6c4009
@c  fstab_convert dup @mtasurace:fsent
Packit 6c4009
This function returns the next entry of the @file{fstab} file which has
Packit 6c4009
a string equal to @var{name} pointed to by the @code{fs_spec} element.
Packit 6c4009
Since there is normally exactly one entry for each special device it
Packit 6c4009
makes no sense to call this function more than once for the same
Packit 6c4009
argument.  If this is the first call to any of the functions handling
Packit 6c4009
@file{fstab} since program start or the last call of @code{endfsent},
Packit 6c4009
the file will be opened.
Packit 6c4009
Packit 6c4009
The function returns a pointer to a variable of type @code{struct
Packit 6c4009
fstab}.  This variable is shared by all threads and therefore this
Packit 6c4009
function is not thread-safe.  If an error occurred @code{getfsent}
Packit 6c4009
returns a @code{NULL} pointer.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {struct fstab *} getfsfile (const char *@var{name})
Packit 6c4009
@standards{BSD, fstab.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:fsent} @mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{}}}
Packit 6c4009
@c getffsfile @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @asulock @acucorrupt @aculock @acsmem
Packit 6c4009
@c  fstab_init(1) dup @mtasurace:fsent @ascuheap @asucorrupt @asulock @acucorrupt @aculock @acsmem @acsfd
Packit 6c4009
@c  fstab_fetch dup @mtasurace:fsent @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
@c  strcmp dup ok
Packit 6c4009
@c  fstab_convert dup @mtasurace:fsent
Packit 6c4009
This function returns the next entry of the @file{fstab} file which has
Packit 6c4009
a string equal to @var{name} pointed to by the @code{fs_file} element.
Packit 6c4009
Since there is normally exactly one entry for each mount point it
Packit 6c4009
makes no sense to call this function more than once for the same
Packit 6c4009
argument.  If this is the first call to any of the functions handling
Packit 6c4009
@file{fstab} since program start or the last call of @code{endfsent},
Packit 6c4009
the file will be opened.
Packit 6c4009
Packit 6c4009
The function returns a pointer to a variable of type @code{struct
Packit 6c4009
fstab}.  This variable is shared by all threads and therefore this
Packit 6c4009
function is not thread-safe.  If an error occurred @code{getfsent}
Packit 6c4009
returns a @code{NULL} pointer.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
Packit 6c4009
@node mtab
Packit 6c4009
@subsubsection The @file{mtab} file
Packit 6c4009
The following functions and data structure access the @file{mtab} file.
Packit 6c4009
Packit 6c4009
@deftp {Data Type} {struct mntent}
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
This structure is used with the @code{getmntent}, @code{getmntent_r},
Packit 6c4009
@code{addmntent}, and @code{hasmntopt} functions.
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item char *mnt_fsname
Packit 6c4009
This element contains a pointer to a string describing the name of the
Packit 6c4009
special device from which the filesystem is mounted.  It corresponds to
Packit 6c4009
the @code{fs_spec} element in @code{struct fstab}.
Packit 6c4009
Packit 6c4009
@item char *mnt_dir
Packit 6c4009
This element points to a string describing the mount point of the
Packit 6c4009
filesystem.  It corresponds to the @code{fs_file} element in
Packit 6c4009
@code{struct fstab}.
Packit 6c4009
Packit 6c4009
@item char *mnt_type
Packit 6c4009
@code{mnt_type} describes the filesystem type and is therefore
Packit 6c4009
equivalent to @code{fs_vfstype} in @code{struct fstab}.  @file{mntent.h}
Packit 6c4009
defines a few symbolic names for some of the values this string can have.
Packit 6c4009
But since the kernel can support arbitrary filesystems it does not
Packit 6c4009
make much sense to give them symbolic names.  If one knows the symbol
Packit 6c4009
name one also knows the filesystem name.  Nevertheless here follows the
Packit 6c4009
list of the symbols provided in @file{mntent.h}.
Packit 6c4009
Packit 6c4009
@vtable @code
Packit 6c4009
@item MNTTYPE_IGNORE
Packit 6c4009
This symbol expands to @code{"ignore"}.  The value is sometimes used in
Packit 6c4009
@file{fstab} files to make sure entries are not used without removing them.
Packit 6c4009
@item MNTTYPE_NFS
Packit 6c4009
Expands to @code{"nfs"}.  Using this macro sometimes could make sense
Packit 6c4009
since it names the default NFS implementation, in case both version 2
Packit 6c4009
and 3 are supported.
Packit 6c4009
@item MNTTYPE_SWAP
Packit 6c4009
This symbol expands to @code{"swap"}.  It names the special @file{fstab}
Packit 6c4009
entry which names one of the possibly multiple swap partitions.
Packit 6c4009
@end vtable
Packit 6c4009
Packit 6c4009
@item char *mnt_opts
Packit 6c4009
The element contains a string describing the options used while mounting
Packit 6c4009
the filesystem.  As for the equivalent element @code{fs_mntops} of
Packit 6c4009
@code{struct fstab} it is best to use the function @code{getsubopt}
Packit 6c4009
(@pxref{Suboptions}) to access the parts of this string.
Packit 6c4009
Packit 6c4009
The @file{mntent.h} file defines a number of macros with string values
Packit 6c4009
which correspond to some of the options understood by the kernel.  There
Packit 6c4009
might be many more options which are possible so it doesn't make much sense
Packit 6c4009
to rely on these macros but to be consistent here is the list:
Packit 6c4009
Packit 6c4009
@vtable @code
Packit 6c4009
@item MNTOPT_DEFAULTS
Packit 6c4009
Expands to @code{"defaults"}.  This option should be used alone since it
Packit 6c4009
indicates all values for the customizable values are chosen to be the
Packit 6c4009
default.
Packit 6c4009
@item MNTOPT_RO
Packit 6c4009
Expands to @code{"ro"}.  See the @code{FSTAB_RO} value, it means the
Packit 6c4009
filesystem is mounted read-only.
Packit 6c4009
@item MNTOPT_RW
Packit 6c4009
Expands to @code{"rw"}.  See the @code{FSTAB_RW} value, it means the
Packit 6c4009
filesystem is mounted with read and write permissions.
Packit 6c4009
@item MNTOPT_SUID
Packit 6c4009
Expands to @code{"suid"}.  This means that the SUID bit (@pxref{How
Packit 6c4009
Change Persona}) is respected when a program from the filesystem is
Packit 6c4009
started.
Packit 6c4009
@item MNTOPT_NOSUID
Packit 6c4009
Expands to @code{"nosuid"}.  This is the opposite of @code{MNTOPT_SUID},
Packit 6c4009
the SUID bit for all files from the filesystem is ignored.
Packit 6c4009
@item MNTOPT_NOAUTO
Packit 6c4009
Expands to @code{"noauto"}.  At startup time the @code{mount} program
Packit 6c4009
will ignore this entry if it is started with the @code{-a} option to
Packit 6c4009
mount all filesystems mentioned in the @file{fstab} file.
Packit 6c4009
@end vtable
Packit 6c4009
Packit 6c4009
As for the @code{FSTAB_*} entries introduced above it is important to
Packit 6c4009
use @code{strcmp} to check for equality.
Packit 6c4009
Packit 6c4009
@item mnt_freq
Packit 6c4009
This elements corresponds to @code{fs_freq} and also specifies the
Packit 6c4009
frequency in days in which dumps are made.
Packit 6c4009
Packit 6c4009
@item mnt_passno
Packit 6c4009
This element is equivalent to @code{fs_passno} with the same meaning
Packit 6c4009
which is uninteresting for all programs beside @code{dump}.
Packit 6c4009
@end table
Packit 6c4009
@end deftp
Packit 6c4009
Packit 6c4009
For accessing the @file{mtab} file there is again a set of three
Packit 6c4009
functions to access all entries in a row.  Unlike the functions to
Packit 6c4009
handle @file{fstab} these functions do not access a fixed file and there
Packit 6c4009
is even a thread safe variant of the get function.  Besides this @theglibc{}
Packit 6c4009
contains functions to alter the file and test for specific options.
Packit 6c4009
Packit 6c4009
@deftypefun {FILE *} setmntent (const char *@var{file}, const char *@var{mode})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@acsmem{} @acsfd{} @aculock{}}}
Packit 6c4009
@c setmntent @ascuheap @asulock @acsmem @acsfd @aculock
Packit 6c4009
@c  strlen dup ok
Packit 6c4009
@c  mempcpy dup ok
Packit 6c4009
@c  memcpy dup ok
Packit 6c4009
@c  fopen dup @ascuheap @asulock @acsmem @acsfd @aculock
Packit 6c4009
@c  fsetlocking dup ok [no @mtasurace:stream @asulock: exclusive stream]
Packit 6c4009
The @code{setmntent} function prepares the file named @var{FILE} which
Packit 6c4009
must be in the format of a @file{fstab} and @file{mtab} file for the
Packit 6c4009
upcoming processing through the other functions of the family.  The
Packit 6c4009
@var{mode} parameter can be chosen in the way the @var{opentype}
Packit 6c4009
parameter for @code{fopen} (@pxref{Opening Streams}) can be chosen.  If
Packit 6c4009
the file is opened for writing the file is also allowed to be empty.
Packit 6c4009
Packit 6c4009
If the file was successfully opened @code{setmntent} returns a file
Packit 6c4009
handle for future use.  Otherwise the return value is @code{NULL}
Packit 6c4009
and @code{errno} is set accordingly.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int endmntent (FILE *@var{stream})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
Packit 6c4009
@c endmntent @ascuheap @asulock @aculock @acsmem @acsfd
Packit 6c4009
@c  fclose dup @ascuheap @asulock @aculock @acsmem @acsfd
Packit 6c4009
This function takes for the @var{stream} parameter a file handle which
Packit 6c4009
previously was returned from the @code{setmntent} call.
Packit 6c4009
@code{endmntent} closes the stream and frees all resources.
Packit 6c4009
Packit 6c4009
The return value is @math{1} unless an error occurred in which case it
Packit 6c4009
is @math{0}.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {struct mntent *} getmntent (FILE *@var{stream})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtunsafe{@mtasurace{:mntentbuf} @mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{} @asuinit{}}@acunsafe{@acuinit{} @acucorrupt{} @aculock{} @acsmem{}}}
Packit 6c4009
@c getmntent @mtasurace:mntentbuf @mtslocale @asucorrupt @ascuheap @asuinit @acuinit @acucorrupt @aculock @acsmem
Packit 6c4009
@c  libc_once @ascuheap @asuinit @acuinit @acsmem
Packit 6c4009
@c   allocate @ascuheap @acsmem
Packit 6c4009
@c    malloc dup @ascuheap @acsmem
Packit 6c4009
@c  getmntent_r dup @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
The @code{getmntent} function takes as the parameter a file handle
Packit 6c4009
previously returned by a successful call to @code{setmntent}.  It returns
Packit 6c4009
a pointer to a static variable of type @code{struct mntent} which is
Packit 6c4009
filled with the information from the next entry from the file currently
Packit 6c4009
read.
Packit 6c4009
Packit 6c4009
The file format used prescribes the use of spaces or tab characters to
Packit 6c4009
separate the fields.  This makes it harder to use names containing one
Packit 6c4009
of these characters (e.g., mount points using spaces).  Therefore
Packit 6c4009
these characters are encoded in the files and the @code{getmntent}
Packit 6c4009
function takes care of the decoding while reading the entries back in.
Packit 6c4009
@code{'\040'} is used to encode a space character, @code{'\011'} to
Packit 6c4009
encode a tab character, @code{'\012'} to encode a newline character,
Packit 6c4009
and @code{'\\'} to encode a backslash.
Packit 6c4009
Packit 6c4009
If there was an error or the end of the file is reached the return value
Packit 6c4009
is @code{NULL}.
Packit 6c4009
Packit 6c4009
This function is not thread-safe since all calls to this function return
Packit 6c4009
a pointer to the same static variable.  @code{getmntent_r} should be
Packit 6c4009
used in situations where multiple threads access the file.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {struct mntent *} getmntent_r (FILE *@var{stream}, struct mntent *@var{result}, char *@var{buffer}, int @var{bufsize})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{@mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{}}@acunsafe{@acucorrupt{} @aculock{} @acsmem{}}}
Packit 6c4009
@c getmntent_r @mtslocale @asucorrupt @ascuheap @acucorrupt @aculock @acsmem
Packit 6c4009
@c  flockfile dup @aculock
Packit 6c4009
@c  fgets_unlocked dup @asucorrupt @acucorrupt [locked, so no @mtsrace:stream]
Packit 6c4009
@c  funlockfile dup @aculock
Packit 6c4009
@c  strchr dup ok
Packit 6c4009
@c  strspn dup ok
Packit 6c4009
@c  strsep dup ok
Packit 6c4009
@c  decode_name ok
Packit 6c4009
@c  sscanf dup @mtslocale @ascuheap @acsmem
Packit 6c4009
The @code{getmntent_r} function is the reentrant variant of
Packit 6c4009
@code{getmntent}.  It also returns the next entry from the file and
Packit 6c4009
returns a pointer.  The actual variable the values are stored in is not
Packit 6c4009
static, though.  Instead the function stores the values in the variable
Packit 6c4009
pointed to by the @var{result} parameter.  Additional information (e.g.,
Packit 6c4009
the strings pointed to by the elements of the result) are kept in the
Packit 6c4009
buffer of size @var{bufsize} pointed to by @var{buffer}.
Packit 6c4009
Packit 6c4009
Escaped characters (space, tab, backslash) are converted back in the
Packit 6c4009
same way as it happens for @code{getmentent}.
Packit 6c4009
Packit 6c4009
The function returns a @code{NULL} pointer in error cases.  Errors could be:
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item
Packit 6c4009
error while reading the file,
Packit 6c4009
@item
Packit 6c4009
end of file reached,
Packit 6c4009
@item
Packit 6c4009
@var{bufsize} is too small for reading a complete new entry.
Packit 6c4009
@end itemize
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun int addmntent (FILE *@var{stream}, const struct mntent *@var{mnt})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{@mtsrace{:stream} @mtslocale{}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
Packit 6c4009
@c addmntent @mtasurace:stream @mtslocale @asucorrupt @acucorrupt
Packit 6c4009
@c  fseek dup @asucorrupt @acucorrupt [no @aculock]
Packit 6c4009
@c  encode_name ok
Packit 6c4009
@c  fprintf dup @mtslocale @asucorrupt @acucorrupt [no @ascuheap @acsmem, no @aculock]
Packit 6c4009
@c  fflush dup @asucorrupt @acucorrupt [no @aculock]
Packit 6c4009
The @code{addmntent} function allows adding a new entry to the file
Packit 6c4009
previously opened with @code{setmntent}.  The new entries are always
Packit 6c4009
appended.  I.e., even if the position of the file descriptor is not at
Packit 6c4009
the end of the file this function does not overwrite an existing entry
Packit 6c4009
following the current position.
Packit 6c4009
Packit 6c4009
The implication of this is that to remove an entry from a file one has
Packit 6c4009
to create a new file while leaving out the entry to be removed and after
Packit 6c4009
closing the file remove the old one and rename the new file to the
Packit 6c4009
chosen name.
Packit 6c4009
Packit 6c4009
This function takes care of spaces and tab characters in the names to be
Packit 6c4009
written to the file.  It converts them and the backslash character into
Packit 6c4009
the format described in the @code{getmntent} description above.
Packit 6c4009
Packit 6c4009
This function returns @math{0} in case the operation was successful.
Packit 6c4009
Otherwise the return value is @math{1} and @code{errno} is set
Packit 6c4009
appropriately.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {char *} hasmntopt (const struct mntent *@var{mnt}, const char *@var{opt})
Packit 6c4009
@standards{BSD, mntent.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c hasmntopt ok
Packit 6c4009
@c  strlen dup ok
Packit 6c4009
@c  strstr dup ok
Packit 6c4009
@c  strchr dup ok
Packit 6c4009
This function can be used to check whether the string pointed to by the
Packit 6c4009
@code{mnt_opts} element of the variable pointed to by @var{mnt} contains
Packit 6c4009
the option @var{opt}.  If this is true a pointer to the beginning of the
Packit 6c4009
option in the @code{mnt_opts} element is returned.  If no such option
Packit 6c4009
exists the function returns @code{NULL}.
Packit 6c4009
Packit 6c4009
This function is useful to test whether a specific option is present but
Packit 6c4009
when all options have to be processed one is better off with using the
Packit 6c4009
@code{getsubopt} function to iterate over all options in the string.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@node Other Mount Information
Packit 6c4009
@subsubsection Other (Non-libc) Sources of Mount Information
Packit 6c4009
Packit 6c4009
On a system with a Linux kernel and the @code{proc} filesystem, you can
Packit 6c4009
get information on currently mounted filesystems from the file
Packit 6c4009
@file{mounts} in the @code{proc} filesystem.  Its format is similar to
Packit 6c4009
that of the @file{mtab} file, but represents what is truly mounted
Packit 6c4009
without relying on facilities outside the kernel to keep @file{mtab} up
Packit 6c4009
to date.
Packit 6c4009
Packit 6c4009
Packit 6c4009
@node Mount-Unmount-Remount, , Mount Information, Filesystem Handling
Packit 6c4009
@subsection Mount, Unmount, Remount
Packit 6c4009
Packit 6c4009
This section describes the functions for mounting, unmounting, and
Packit 6c4009
remounting filesystems.
Packit 6c4009
Packit 6c4009
Only the superuser can mount, unmount, or remount a filesystem.
Packit 6c4009
Packit 6c4009
These functions do not access the @file{fstab} and @file{mtab} files.  You
Packit 6c4009
should maintain and use these separately.  @xref{Mount Information}.
Packit 6c4009
Packit 6c4009
The symbols in this section are declared in @file{sys/mount.h}.
Packit 6c4009
Packit 6c4009
@deftypefun {int} mount (const char *@var{special_file}, const char *@var{dir}, const char *@var{fstype}, unsigned long int @var{options}, const void *@var{data})
Packit 6c4009
@standards{SVID, sys/mount.h}
Packit 6c4009
@standards{BSD, sys/mount.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall.
Packit 6c4009
Packit 6c4009
@code{mount} mounts or remounts a filesystem.  The two operations are
Packit 6c4009
quite different and are merged rather unnaturally into this one function.
Packit 6c4009
The @code{MS_REMOUNT} option, explained below, determines whether
Packit 6c4009
@code{mount} mounts or remounts.
Packit 6c4009
Packit 6c4009
For a mount, the filesystem on the block device represented by the
Packit 6c4009
device special file named @var{special_file} gets mounted over the mount
Packit 6c4009
point @var{dir}.  This means that the directory @var{dir} (along with any
Packit 6c4009
files in it) is no longer visible; in its place (and still with the name
Packit 6c4009
@var{dir}) is the root directory of the filesystem on the device.
Packit 6c4009
Packit 6c4009
As an exception, if the filesystem type (see below) is one which is not
Packit 6c4009
based on a device (e.g. ``proc''), @code{mount} instantiates a
Packit 6c4009
filesystem and mounts it over @var{dir} and ignores @var{special_file}.
Packit 6c4009
Packit 6c4009
For a remount, @var{dir} specifies the mount point where the filesystem
Packit 6c4009
to be remounted is (and remains) mounted and @var{special_file} is
Packit 6c4009
ignored.  Remounting a filesystem means changing the options that control
Packit 6c4009
operations on the filesystem while it is mounted.  It does not mean
Packit 6c4009
unmounting and mounting again.
Packit 6c4009
Packit 6c4009
For a mount, you must identify the type of the filesystem with
Packit 6c4009
@var{fstype}.  This type tells the kernel how to access the filesystem
Packit 6c4009
and can be thought of as the name of a filesystem driver.  The
Packit 6c4009
acceptable values are system dependent.  On a system with a Linux kernel
Packit 6c4009
and the @code{proc} filesystem, the list of possible values is in the
Packit 6c4009
file @file{filesystems} in the @code{proc} filesystem (e.g. type
Packit 6c4009
@kbd{cat /proc/filesystems} to see the list).  With a Linux kernel, the
Packit 6c4009
types of filesystems that @code{mount} can mount, and their type names,
Packit 6c4009
depends on what filesystem drivers are configured into the kernel or
Packit 6c4009
loaded as loadable kernel modules.  An example of a common value for
Packit 6c4009
@var{fstype} is @code{ext2}.
Packit 6c4009
Packit 6c4009
For a remount, @code{mount} ignores @var{fstype}.
Packit 6c4009
Packit 6c4009
@c This is traditionally called "rwflag" for historical reasons.
Packit 6c4009
@c No point in confusing people today, though.
Packit 6c4009
@var{options} specifies a variety of options that apply until the
Packit 6c4009
filesystem is unmounted or remounted.  The precise meaning of an option
Packit 6c4009
depends on the filesystem and with some filesystems, an option may have
Packit 6c4009
no effect at all.  Furthermore, for some filesystems, some of these
Packit 6c4009
options (but never @code{MS_RDONLY}) can be overridden for individual
Packit 6c4009
file accesses via @code{ioctl}.
Packit 6c4009
Packit 6c4009
@var{options} is a bit string with bit fields defined using the
Packit 6c4009
following mask and masked value macros:
Packit 6c4009
Packit 6c4009
@vtable @code
Packit 6c4009
@item MS_MGC_MASK
Packit 6c4009
This multibit field contains a magic number.  If it does not have the value
Packit 6c4009
@code{MS_MGC_VAL}, @code{mount} assumes all the following bits are zero and
Packit 6c4009
the @var{data} argument is a null string, regardless of their actual values.
Packit 6c4009
Packit 6c4009
@item MS_REMOUNT
Packit 6c4009
This bit on means to remount the filesystem.  Off means to mount it.
Packit 6c4009
@c There is a mask MS_RMT_MASK in mount.h that says only two of the options
Packit 6c4009
@c can be reset by remount.  But the Linux kernel has its own version of
Packit 6c4009
@c MS_RMT_MASK that says they all can be reset.  As far as I can tell,
Packit 6c4009
@c libc just passes the arguments straight through to the kernel.
Packit 6c4009
Packit 6c4009
@item MS_RDONLY
Packit 6c4009
This bit on specifies that no writing to the filesystem shall be allowed
Packit 6c4009
while it is mounted.  This cannot be overridden by @code{ioctl}.  This
Packit 6c4009
option is available on nearly all filesystems.
Packit 6c4009
Packit 6c4009
@item MS_NOSUID
Packit 6c4009
This bit on specifies that Setuid and Setgid permissions on files in the
Packit 6c4009
filesystem shall be ignored while it is mounted.
Packit 6c4009
Packit 6c4009
@item MS_NOEXEC
Packit 6c4009
This bit on specifies that no files in the filesystem shall be executed
Packit 6c4009
while the filesystem is mounted.
Packit 6c4009
Packit 6c4009
@item MS_NODEV
Packit 6c4009
This bit on specifies that no device special files in the filesystem
Packit 6c4009
shall be accessible while the filesystem is mounted.
Packit 6c4009
Packit 6c4009
@item MS_SYNCHRONOUS
Packit 6c4009
This bit on specifies that all writes to the filesystem while it is
Packit 6c4009
mounted shall be synchronous; i.e., data shall be synced before each
Packit 6c4009
write completes rather than held in the buffer cache.
Packit 6c4009
Packit 6c4009
@item MS_MANDLOCK
Packit 6c4009
This bit on specifies that mandatory locks on files shall be permitted while
Packit 6c4009
the filesystem is mounted.
Packit 6c4009
Packit 6c4009
@item MS_NOATIME
Packit 6c4009
This bit on specifies that access times of files shall not be updated when
Packit 6c4009
the files are accessed while the filesystem is mounted.
Packit 6c4009
Packit 6c4009
@item MS_NODIRATIME
Packit 6c4009
This bit on specifies that access times of directories shall not be updated
Packit 6c4009
when the directories are accessed while the filesystem in mounted.
Packit 6c4009
Packit 6c4009
@c there is also S_QUOTA Linux fs.h (mount.h still uses its former name
Packit 6c4009
@c S_WRITE), but I can't see what it does.  Turns on quotas, I guess.
Packit 6c4009
Packit 6c4009
@end vtable
Packit 6c4009
Packit 6c4009
Any bits not covered by the above masks should be set off; otherwise,
Packit 6c4009
results are undefined.
Packit 6c4009
Packit 6c4009
The meaning of @var{data} depends on the filesystem type and is controlled
Packit 6c4009
entirely by the filesystem driver in the kernel.
Packit 6c4009
Packit 6c4009
Example:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
@group
Packit 6c4009
#include <sys/mount.h>
Packit 6c4009
Packit 6c4009
mount("/dev/hdb", "/cdrom", MS_MGC_VAL | MS_RDONLY | MS_NOSUID, "");
Packit 6c4009
Packit 6c4009
mount("/dev/hda2", "/mnt", MS_MGC_VAL | MS_REMOUNT, "");
Packit 6c4009
Packit 6c4009
@end group
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
Appropriate arguments for @code{mount} are conventionally recorded in
Packit 6c4009
the @file{fstab} table.  @xref{Mount Information}.
Packit 6c4009
Packit 6c4009
The return value is zero if the mount or remount is successful.  Otherwise,
Packit 6c4009
it is @code{-1} and @code{errno} is set appropriately.  The values of
Packit 6c4009
@code{errno} are filesystem dependent, but here is a general list:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item EPERM
Packit 6c4009
The process is not superuser.
Packit 6c4009
@item ENODEV
Packit 6c4009
The file system type @var{fstype} is not known to the kernel.
Packit 6c4009
@item ENOTBLK
Packit 6c4009
The file @var{dev} is not a block device special file.
Packit 6c4009
@item EBUSY
Packit 6c4009
Packit 6c4009
@itemize @bullet
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
The device is already mounted.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
The mount point is busy.  (E.g. it is some process' working directory or
Packit 6c4009
has a filesystem mounted on it already).
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
The request is to remount read-only, but there are files open for writing.
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
@item EINVAL
Packit 6c4009
@itemize @bullet
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
A remount was attempted, but there is no filesystem mounted over the
Packit 6c4009
specified mount point.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
The supposed filesystem has an invalid superblock.
Packit 6c4009
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
@item EACCES
Packit 6c4009
@itemize @bullet
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
The filesystem is inherently read-only (possibly due to a switch on the
Packit 6c4009
device) and the process attempted to mount it read/write (by setting the
Packit 6c4009
@code{MS_RDONLY} bit off).
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
@var{special_file} or @var{dir} is not accessible due to file permissions.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
@var{special_file} is not accessible because it is in a filesystem that is
Packit 6c4009
mounted with the @code{MS_NODEV} option.
Packit 6c4009
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
@item EM_FILE
Packit 6c4009
The table of dummy devices is full.  @code{mount} needs to create a
Packit 6c4009
dummy device (aka ``unnamed'' device) if the filesystem being mounted is
Packit 6c4009
not one that uses a device.
Packit 6c4009
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
Packit 6c4009
@deftypefun {int} umount2 (const char *@var{file}, int @var{flags})
Packit 6c4009
@standards{GNU, sys/mount.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall.
Packit 6c4009
Packit 6c4009
@code{umount2} unmounts a filesystem.
Packit 6c4009
Packit 6c4009
You can identify the filesystem to unmount either by the device special
Packit 6c4009
file that contains the filesystem or by the mount point.  The effect is
Packit 6c4009
the same.  Specify either as the string @var{file}.
Packit 6c4009
Packit 6c4009
@var{flags} contains the one-bit field identified by the following
Packit 6c4009
mask macro:
Packit 6c4009
Packit 6c4009
@vtable @code
Packit 6c4009
Packit 6c4009
@item MNT_FORCE
Packit 6c4009
This bit on means to force the unmounting even if the filesystem is
Packit 6c4009
busy, by making it unbusy first.  If the bit is off and the filesystem is
Packit 6c4009
busy, @code{umount2} fails with @code{errno} = @code{EBUSY}.  Depending
Packit 6c4009
on the filesystem, this may override all, some, or no busy conditions.
Packit 6c4009
Packit 6c4009
@end vtable
Packit 6c4009
Packit 6c4009
All other bits in @var{flags} should be set to zero; otherwise, the result
Packit 6c4009
is undefined.
Packit 6c4009
Packit 6c4009
Example:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
@group
Packit 6c4009
#include <sys/mount.h>
Packit 6c4009
Packit 6c4009
umount2("/mnt", MNT_FORCE);
Packit 6c4009
Packit 6c4009
umount2("/dev/hdd1", 0);
Packit 6c4009
Packit 6c4009
@end group
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
After the filesystem is unmounted, the directory that was the mount point
Packit 6c4009
is visible, as are any files in it.
Packit 6c4009
Packit 6c4009
As part of unmounting, @code{umount2} syncs the filesystem.
Packit 6c4009
Packit 6c4009
If the unmounting is successful, the return value is zero.  Otherwise, it
Packit 6c4009
is @code{-1} and @code{errno} is set accordingly:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item EPERM
Packit 6c4009
The process is not superuser.
Packit 6c4009
@item EBUSY
Packit 6c4009
The filesystem cannot be unmounted because it is busy.  E.g. it contains
Packit 6c4009
a directory that is some process's working directory or a file that some
Packit 6c4009
process has open.  With some filesystems in some cases, you can avoid
Packit 6c4009
this failure with the @code{MNT_FORCE} option.
Packit 6c4009
Packit 6c4009
@item EINVAL
Packit 6c4009
@var{file} validly refers to a file, but that file is neither a mount
Packit 6c4009
point nor a device special file of a currently mounted filesystem.
Packit 6c4009
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
This function is not available on all systems.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
@deftypefun {int} umount (const char *@var{file})
Packit 6c4009
@standards{SVID, sys/mount.h}
Packit 6c4009
@standards{GNU, sys/mount.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall or wrapper for umount2.
Packit 6c4009
Packit 6c4009
@code{umount} does the same thing as @code{umount2} with @var{flags} set
Packit 6c4009
to zeroes.  It is more widely available than @code{umount2} but since it
Packit 6c4009
lacks the possibility to forcefully unmount a filesystem is deprecated
Packit 6c4009
when @code{umount2} is also available.
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
Packit 6c4009
Packit 6c4009
@node System Parameters
Packit 6c4009
@section System Parameters
Packit 6c4009
Packit 6c4009
This section describes the @code{sysctl} function, which gets and sets
Packit 6c4009
a variety of system parameters.
Packit 6c4009
Packit 6c4009
The symbols used in this section are declared in the file @file{sys/sysctl.h}.
Packit 6c4009
Packit 6c4009
@deftypefun int sysctl (int *@var{names}, int @var{nlen}, void *@var{oldval}, size_t *@var{oldlenp}, void *@var{newval}, size_t @var{newlen})
Packit 6c4009
@standards{BSD, sys/sysctl.h}
Packit 6c4009
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Packit 6c4009
@c Direct syscall, Linux only.
Packit 6c4009
Packit 6c4009
@code{sysctl} gets or sets a specified system parameter.  There are so
Packit 6c4009
many of these parameters that it is not practical to list them all here,
Packit 6c4009
but here are some examples:
Packit 6c4009
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item network domain name
Packit 6c4009
@item paging parameters
Packit 6c4009
@item network Address Resolution Protocol timeout time
Packit 6c4009
@item maximum number of files that may be open
Packit 6c4009
@item root filesystem device
Packit 6c4009
@item when kernel was built
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
The set of available parameters depends on the kernel configuration and
Packit 6c4009
can change while the system is running, particularly when you load and
Packit 6c4009
unload loadable kernel modules.
Packit 6c4009
Packit 6c4009
The system parameters with which @code{sysctl} is concerned are arranged
Packit 6c4009
in a hierarchical structure like a hierarchical filesystem.  To identify
Packit 6c4009
a particular parameter, you specify a path through the structure in a
Packit 6c4009
way analogous to specifying the pathname of a file.  Each component of
Packit 6c4009
the path is specified by an integer and each of these integers has a
Packit 6c4009
macro defined for it by @file{sys/sysctl.h}.  @var{names} is the path, in
Packit 6c4009
the form of an array of integers.  Each component of the path is one
Packit 6c4009
element of the array, in order.  @var{nlen} is the number of components
Packit 6c4009
in the path.
Packit 6c4009
Packit 6c4009
For example, the first component of the path for all the paging
Packit 6c4009
parameters is the value @code{CTL_VM}.  For the free page thresholds, the
Packit 6c4009
second component of the path is @code{VM_FREEPG}.  So to get the free
Packit 6c4009
page threshold values, make @var{names} an array containing the two
Packit 6c4009
elements @code{CTL_VM} and @code{VM_FREEPG} and make @var{nlen} = 2.
Packit 6c4009
Packit 6c4009
Packit 6c4009
The format of the value of a parameter depends on the parameter.
Packit 6c4009
Sometimes it is an integer; sometimes it is an ASCII string; sometimes
Packit 6c4009
it is an elaborate structure.  In the case of the free page thresholds
Packit 6c4009
used in the example above, the parameter value is a structure containing
Packit 6c4009
several integers.
Packit 6c4009
Packit 6c4009
In any case, you identify a place to return the parameter's value with
Packit 6c4009
@var{oldval} and specify the amount of storage available at that
Packit 6c4009
location as *@var{oldlenp}.  *@var{oldlenp} does double duty because it
Packit 6c4009
is also the output location that contains the actual length of the
Packit 6c4009
returned value.
Packit 6c4009
Packit 6c4009
If you don't want the parameter value returned, specify a null pointer
Packit 6c4009
for @var{oldval}.
Packit 6c4009
Packit 6c4009
To set the parameter, specify the address and length of the new value
Packit 6c4009
as @var{newval} and @var{newlen}.  If you don't want to set the parameter,
Packit 6c4009
specify a null pointer as @var{newval}.
Packit 6c4009
Packit 6c4009
If you get and set a parameter in the same @code{sysctl} call, the value
Packit 6c4009
returned is the value of the parameter before it was set.
Packit 6c4009
Packit 6c4009
Each system parameter has a set of permissions similar to the
Packit 6c4009
permissions for a file (including the permissions on directories in its
Packit 6c4009
path) that determine whether you may get or set it.  For the purposes of
Packit 6c4009
these permissions, every parameter is considered to be owned by the
Packit 6c4009
superuser and Group 0 so processes with that effective uid or gid may
Packit 6c4009
have more access to system parameters.  Unlike with files, the superuser
Packit 6c4009
does not invariably have full permission to all system parameters, because
Packit 6c4009
some of them are designed not to be changed ever.
Packit 6c4009
Packit 6c4009
Packit 6c4009
@code{sysctl} returns a zero return value if it succeeds.  Otherwise, it
Packit 6c4009
returns @code{-1} and sets @code{errno} appropriately.  Besides the
Packit 6c4009
failures that apply to all system calls, the following are the
Packit 6c4009
@code{errno} codes for all possible failures:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item EPERM
Packit 6c4009
The process is not permitted to access one of the components of the
Packit 6c4009
path of the system parameter or is not permitted to access the system parameter
Packit 6c4009
itself in the way (read or write) that it requested.
Packit 6c4009
@c There is some indication in the Linux 2.2 code that the code is trying to
Packit 6c4009
@c return EACCES here, but the EACCES value never actually makes it to the
Packit 6c4009
@c user.
Packit 6c4009
@item ENOTDIR
Packit 6c4009
There is no system parameter corresponding to @var{name}.
Packit 6c4009
@item EFAULT
Packit 6c4009
@var{oldval} is not null, which means the process wanted to read the parameter,
Packit 6c4009
but *@var{oldlenp} is zero, so there is no place to return it.
Packit 6c4009
@item EINVAL
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item
Packit 6c4009
The process attempted to set a system parameter to a value that is not valid
Packit 6c4009
for that parameter.
Packit 6c4009
@item
Packit 6c4009
The space provided for the return of the system parameter is not the right
Packit 6c4009
size for that parameter.
Packit 6c4009
@end itemize
Packit 6c4009
@item ENOMEM
Packit 6c4009
This value may be returned instead of the more correct @code{EINVAL} in some
Packit 6c4009
cases where the space provided for the return of the system parameter is too
Packit 6c4009
small.
Packit 6c4009
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@end deftypefun
Packit 6c4009
Packit 6c4009
If you have a Linux kernel with the @code{proc} filesystem, you can get
Packit 6c4009
and set most of the same parameters by reading and writing to files in
Packit 6c4009
the @code{sys} directory of the @code{proc} filesystem.  In the @code{sys}
Packit 6c4009
directory, the directory structure represents the hierarchical structure
Packit 6c4009
of the parameters.  E.g. you can display the free page thresholds with
Packit 6c4009
@smallexample
Packit 6c4009
cat /proc/sys/vm/freepages
Packit 6c4009
@end smallexample
Packit 6c4009
@c In Linux, the sysctl() and /proc instances of the parameter are created
Packit 6c4009
@c together.  The proc filesystem accesses the same data structure as
Packit 6c4009
@c sysctl(), which has special fields in it for /proc.  But it is still
Packit 6c4009
@c possible to create a sysctl-only parameter.
Packit 6c4009
Packit 6c4009
Some more traditional and more widely available, though less general,
Packit 6c4009
@glibcadj{} functions for getting and setting some of the same system
Packit 6c4009
parameters are:
Packit 6c4009
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item
Packit 6c4009
@code{getdomainname}, @code{setdomainname}
Packit 6c4009
@item
Packit 6c4009
@code{gethostname}, @code{sethostname} (@xref{Host Identification}.)
Packit 6c4009
@item
Packit 6c4009
@code{uname} (@xref{Platform Type}.)
Packit 6c4009
@end itemize