teach manpages about largefile's demise
[unleashed.git] / share / man / man1 / pathchk.1
blob9cc0e86e986274d5304aeb6506651ae8d69ac558
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
45 .\"
46 .TH PATHCHK 1 "Feb 1, 1995"
47 .SH NAME
48 pathchk \- check path names
49 .SH SYNOPSIS
50 .LP
51 .nf
52 \fBpathchk\fR [\fB-p\fR] \fIpath\fR...
53 .fi
55 .SH DESCRIPTION
56 .sp
57 .LP
58 The \fBpathchk\fR command will check that one or more path names are valid
59 (that is, they could be used to access or create a file without causing syntax
60 errors) and portable (that is, no filename truncation will result). More
61 extensive portability checks are provided by the \fB-p\fR option.
62 .sp
63 .LP
64 By default, \fBpathchk\fR will check each component of each \fIpath\fR operand
65 based on the underlying file system. A diagnostic will be written for each
66 \fIpath\fR operand that:
67 .RS +4
68 .TP
69 .ie t \(bu
70 .el o
71 is longer than \fIPATH_MAX\fR bytes.
72 .RE
73 .RS +4
74 .TP
75 .ie t \(bu
76 .el o
77 contains any component longer than \fINAME_MAX\fR bytes in its containing
78 directory
79 .RE
80 .RS +4
81 .TP
82 .ie t \(bu
83 .el o
84 contains any component in a directory that is not searchable
85 .RE
86 .RS +4
87 .TP
88 .ie t \(bu
89 .el o
90 contains any character in any component that is not valid in its containing
91 directory.
92 .RE
93 .sp
94 .LP
95 The format of the diagnostic message is not specified, but will indicate the
96 error detected and the corresponding \fIpath\fR operand.
97 .sp
98 .LP
99 It will not be considered an error if one or more components of a \fIpath\fR
100 operand do not exist as long as a file matching the path name specified by the
101 missing components could be created that does not violate any of the checks
102 specified above.
103 .SH OPTIONS
106 The following option is supported:
108 .ne 2
110 \fB\fB-p\fR\fR
112 .RS 6n
113 Instead of performing checks based on the underlying file system, write a
114 diagnostic for each \fIpath\fR operand that:
115 .RS +4
117 .ie t \(bu
118 .el o
119 is longer than \fB_POSIX_PATH_MAX \fR bytes
121 .RS +4
123 .ie t \(bu
124 .el o
125 contains any component longer than \fB_POSIX_NAME_MAX\fR bytes
127 .RS +4
129 .ie t \(bu
130 .el o
131 contains any character in any component that is not in the portable filename
132 character set.
136 .SH OPERANDS
139 The following operand is supported:
141 .ne 2
143 \fB\fIpath\fR\fR
145 .RS 8n
146 A path to be checked.
149 .SH EXAMPLES
151 \fBExample 1 \fRUsing the pathchk command
154 To verify that all paths in an imported data interchange archive are legitimate
155 and unambiguous on the current system:
158 .in +2
160 example% \fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk
161 if [ $? -eq 0 ]
162 then
163         pax -r -f archive
164 else
165         echo Investigate problems before importing files.
166         exit 1
167 fi\fR
169 .in -2
174 To verify that all files in the current directory hierarchy could be moved to
175 any system conforming to the X/Open specification that also  supports the
176 \fBpax\fR(1) command:
179 .in +2
181 example% \fBfind . -print | xargs pathchk -p
182 if [ $? \(mieq 0 ]
183 then
184         pax -w -f archive .
185 else
186         echo Portable archive cannot be created.
187         exit 1
188 fi\fR
190 .in -2
195 To verify that a user-supplied path names a readable file and that the
196 application can create a file extending the given path without truncation and
197 without overwriting any existing file:
200 .in +2
202 example% \fBcase $- in
203         *C*)    reset="";;
204         *)      reset="set +C"
205                 set -C;;
206 esac
207 test -r "$path" && pathchk "$path.out" &&
208         rm "$path.out" > "$path.out"
209 if [ $? -ne 0 ]; then
210         printf "%s: %s not found or %s.out fails \e
211 creation checks.\en" $0 "$path" "$path"
212         $reset  # reset the noclobber option in case a trap
213                 # on EXIT depends on it
214         exit 1
216 $reset
217 PROCESSING < "$path" > "$path.out"\fR
219 .in -2
224 The following assumptions are made in this example:
226 .RS +4
229 \fBPROCESSING\fR represents the code that will be used by the application to
230 use \fB$path\fR once it is verified that \fB$path.out\fR will work as intended.
232 .RS +4
235 The state of the \fBnoclobber\fR option is unknown when this code is invoked
236 and should be set on exit to the state it was in when this code was invoked.
237 (The \fBreset\fR variable is used in this example to restore the initial
238 state.)
240 .RS +4
243 Note the usage of:
245 .in +2
247 \fBrm "$path.out" > "$path.out"\fR
249 .in -2
253 .ne 2
255 \fBa.\fR
257 .RS 6n
258 The \fBpathchk\fR command has already verified, at this point, that
259 \fB$path.out\fR will not be truncated.
263 .ne 2
265 \fBb.\fR
267 .RS 6n
268 With the \fBnoclobber\fR option set, the shell will verify that \fB$path.out\fR
269 does not already exist before invoking \fBrm\fR.
273 .ne 2
275 \fBc.\fR
277 .RS 6n
278 If the shell succeeded in creating \fB$path.out\fR, \fBrm\fR will remove it so
279 that the application can create the file again in the \fBPROCESSING\fR step.
283 .ne 2
285 \fBd.\fR
287 .RS 6n
288 If the \fBPROCESSING\fR step wants the file to exist already when it is
289 invoked, the:
291 .in +2
293 \fBrm "$path.out" > "$path.out"\fR
295 .in -2
298 should be replaced with:
300 .in +2
302 \fB> "$path.out"\fR
304 .in -2
307 which will verify that the file did not already exist, but leave
308 \fB$path.out\fR in place for use by \fBPROCESSING\fR.
312 .SH ENVIRONMENT VARIABLES
315 See \fBenviron\fR(5) for descriptions of the following environment variables
316 that affect the execution of \fBpathchk\fR: \fBLANG\fR, \fBLC_ALL\fR,
317 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
318 .SH EXIT STATUS
321 The following exit values are returned:
323 .ne 2
325 \fB\fB0\fR\fR
327 .RS 6n
328 All \fIpath\fR operands passed all of the checks.
332 .ne 2
334 \fB\fB>0\fR\fR
336 .RS 6n
337 An error occurred.
340 .SH ATTRIBUTES
343 See \fBattributes\fR(5) for descriptions of the following attributes:
348 box;
349 c | c
350 l | l .
351 ATTRIBUTE TYPE  ATTRIBUTE VALUE
353 Interface Stability     Standard
356 .SH SEE ALSO
359 \fBpax\fR(1), \fBtest\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
360 \fBstandards\fR(5)