OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man2 / getdomainname.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified 1997-08-25 by Nicolás Lichtmaier <nick@debian.org>
26 .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Modified 2008-11-27 by mtk
28 .\"
29 .TH GETDOMAINNAME 2 2009-09-27 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 getdomainname, setdomainname \- get/set domain name
32 .SH SYNOPSIS
33 .B #include <unistd.h>
34 .sp
35 .BI "int getdomainname(char *" name ", size_t " len );
36 .br
37 .BI "int setdomainname(const char *" name ", size_t " len );
38 .sp
39 .in -4n
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
42 .in
43 .sp
44 .ad l
45 .BR getdomainname (),
46 .BR setdomainname ():
47 .RS 4
48 _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
49 .RE
50 .ad
51 .SH DESCRIPTION
52 These functions are used to access or to change the domain name of the
53 host system.
54
55 .BR setdomainname ()
56 sets the domain name to the value given in the character array
57 .IR name .
58 The
59 .I len
60 argument specifies the number of bytes in
61 .IR name .
62 (Thus,
63 .I name
64 does not require a terminating null byte.)
65
66 .BR getdomainname ()
67 returns the null-terminated domain name in the character array
68 .IR name ,
69 which has a length of
70 .I len
71 bytes.
72 If the null-terminated domain name requires more than \fIlen\fP bytes,
73 .BR getdomainname ()
74 returns the first \fIlen\fP bytes (glibc) or gives an error (libc).
75 .SH "RETURN VALUE"
76 On success, zero is returned.
77 On error, \-1 is returned, and
78 .I errno
79 is set appropriately.
80 .SH ERRORS
81 .BR setdomainname ()
82 can fail with the following errors:
83 .TP
84 .B EFAULT
85 .I name
86 pointed outside of user address space.
87 .TP
88 .B EINVAL
89 .I len
90 was negative or too large.
91 .TP
92 .B EPERM
93 the caller is unprivileged (Linux: does not have the
94 .B CAP_SYS_ADMIN
95 capability).
96 .PP
97 .BR getdomainname ()
98 can fail with the following errors:
99 .TP
100 .B EINVAL
101 For
102 .BR getdomainname ()
103 under libc:
104 .I name
105 is NULL or
106 .I name
107 is longer than
108 .I len
109 bytes.
110 .SH "CONFORMING TO"
111 POSIX does not specify these calls.
112 .\" But they appear on most systems...
113 .SH NOTES
114 Since Linux 1.0, the limit on the length of a domain name,
115 including the terminating null byte, is 64 bytes.
116 In older kernels, it was 8 bytes.
117
118 On most Linux architectures (including x86),
119 there is no
120 .BR getdomainname ()
121 system call; instead, glibc implements
122 .BR getdomainname ()
123 as a library function that returns a copy of the
124 .I domainname
125 field returned from a call to
126 .BR uname (2).
127 .SH "SEE ALSO"
128 .BR gethostname (2),
129 .BR sethostname (2),
130 .BR uname (2)