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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
46 .TH PATHCHK 1 "Feb 1, 1995"
48 pathchk \- check path names
52 \fBpathchk\fR [\fB-p\fR] \fIpath\fR...
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.
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:
71 is longer than \fIPATH_MAX\fR bytes.
77 contains any component longer than \fINAME_MAX\fR bytes in its containing
84 contains any component in a directory that is not searchable
90 contains any character in any component that is not valid in its containing
95 The format of the diagnostic message is not specified, but will indicate the
96 error detected and the corresponding \fIpath\fR operand.
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
106 The following option is supported:
113 Instead of performing checks based on the underlying file system, write a
114 diagnostic for each \fIpath\fR operand that:
119 is longer than \fB_POSIX_PATH_MAX \fR bytes
125 contains any component longer than \fB_POSIX_NAME_MAX\fR bytes
131 contains any character in any component that is not in the portable filename
139 The following operand is supported:
146 A path to be checked.
152 See \fBlargefile\fR(5) for the description of the behavior of \fBpathchk\fR
153 when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
156 \fBExample 1 \fRUsing the pathchk command
159 To verify that all paths in an imported data interchange archive are legitimate
160 and unambiguous on the current system:
165 example% \fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk
170 echo Investigate problems before importing files.
179 To verify that all files in the current directory hierarchy could be moved to
180 any system conforming to the X/Open specification that also supports the
181 \fBpax\fR(1) command:
186 example% \fBfind . -print | xargs pathchk -p
191 echo Portable archive cannot be created.
200 To verify that a user-supplied path names a readable file and that the
201 application can create a file extending the given path without truncation and
202 without overwriting any existing file:
207 example% \fBcase $- in
212 test -r "$path" && pathchk "$path.out" &&
213 rm "$path.out" > "$path.out"
214 if [ $? -ne 0 ]; then
215 printf "%s: %s not found or %s.out fails \e
216 creation checks.\en" $0 "$path" "$path"
217 $reset # reset the noclobber option in case a trap
218 # on EXIT depends on it
222 PROCESSING < "$path" > "$path.out"\fR
229 The following assumptions are made in this example:
234 \fBPROCESSING\fR represents the code that will be used by the application to
235 use \fB$path\fR once it is verified that \fB$path.out\fR will work as intended.
240 The state of the \fBnoclobber\fR option is unknown when this code is invoked
241 and should be set on exit to the state it was in when this code was invoked.
242 (The \fBreset\fR variable is used in this example to restore the initial
252 \fBrm "$path.out" > "$path.out"\fR
263 The \fBpathchk\fR command has already verified, at this point, that
264 \fB$path.out\fR will not be truncated.
273 With the \fBnoclobber\fR option set, the shell will verify that \fB$path.out\fR
274 does not already exist before invoking \fBrm\fR.
283 If the shell succeeded in creating \fB$path.out\fR, \fBrm\fR will remove it so
284 that the application can create the file again in the \fBPROCESSING\fR step.
293 If the \fBPROCESSING\fR step wants the file to exist already when it is
298 \fBrm "$path.out" > "$path.out"\fR
303 should be replaced with:
312 which will verify that the file did not already exist, but leave
313 \fB$path.out\fR in place for use by \fBPROCESSING\fR.
317 .SH ENVIRONMENT VARIABLES
320 See \fBenviron\fR(5) for descriptions of the following environment variables
321 that affect the execution of \fBpathchk\fR: \fBLANG\fR, \fBLC_ALL\fR,
322 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
326 The following exit values are returned:
333 All \fIpath\fR operands passed all of the checks.
348 See \fBattributes\fR(5) for descriptions of the following attributes:
356 ATTRIBUTE TYPE ATTRIBUTE VALUE
358 Interface Stability Standard
364 \fBpax\fR(1), \fBtest\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
365 \fBlargefile\fR(5), \fBstandards\fR(5)