'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. .\" This notice shall appear on any product containing this material. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH PATHCHK 1 "Feb 1, 1995" .SH NAME pathchk \- check path names .SH SYNOPSIS .LP .nf \fBpathchk\fR [\fB-p\fR] \fIpath\fR... .fi .SH DESCRIPTION .sp .LP The \fBpathchk\fR command will check that one or more path names are valid (that is, they could be used to access or create a file without causing syntax errors) and portable (that is, no filename truncation will result). More extensive portability checks are provided by the \fB-p\fR option. .sp .LP By default, \fBpathchk\fR will check each component of each \fIpath\fR operand based on the underlying file system. A diagnostic will be written for each \fIpath\fR operand that: .RS +4 .TP .ie t \(bu .el o is longer than \fIPATH_MAX\fR bytes. .RE .RS +4 .TP .ie t \(bu .el o contains any component longer than \fINAME_MAX\fR bytes in its containing directory .RE .RS +4 .TP .ie t \(bu .el o contains any component in a directory that is not searchable .RE .RS +4 .TP .ie t \(bu .el o contains any character in any component that is not valid in its containing directory. .RE .sp .LP The format of the diagnostic message is not specified, but will indicate the error detected and the corresponding \fIpath\fR operand. .sp .LP It will not be considered an error if one or more components of a \fIpath\fR operand do not exist as long as a file matching the path name specified by the missing components could be created that does not violate any of the checks specified above. .SH OPTIONS .sp .LP The following option is supported: .sp .ne 2 .na \fB\fB-p\fR\fR .ad .RS 6n Instead of performing checks based on the underlying file system, write a diagnostic for each \fIpath\fR operand that: .RS +4 .TP .ie t \(bu .el o is longer than \fB_POSIX_PATH_MAX \fR bytes .RE .RS +4 .TP .ie t \(bu .el o contains any component longer than \fB_POSIX_NAME_MAX\fR bytes .RE .RS +4 .TP .ie t \(bu .el o contains any character in any component that is not in the portable filename character set. .RE .RE .SH OPERANDS .sp .LP The following operand is supported: .sp .ne 2 .na \fB\fIpath\fR\fR .ad .RS 8n A path to be checked. .RE .SH USAGE .sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBpathchk\fR when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). .SH EXAMPLES .LP \fBExample 1 \fRUsing the pathchk command .sp .LP To verify that all paths in an imported data interchange archive are legitimate and unambiguous on the current system: .sp .in +2 .nf example% \fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk if [ $? -eq 0 ] then pax -r -f archive else echo Investigate problems before importing files. exit 1 fi\fR .fi .in -2 .sp .sp .LP To verify that all files in the current directory hierarchy could be moved to any system conforming to the X/Open specification that also supports the \fBpax\fR(1) command: .sp .in +2 .nf example% \fBfind . -print | xargs pathchk -p if [ $? \(mieq 0 ] then pax -w -f archive . else echo Portable archive cannot be created. exit 1 fi\fR .fi .in -2 .sp .sp .LP To verify that a user-supplied path names a readable file and that the application can create a file extending the given path without truncation and without overwriting any existing file: .sp .in +2 .nf example% \fBcase $- in *C*) reset="";; *) reset="set +C" set -C;; esac test -r "$path" && pathchk "$path.out" && rm "$path.out" > "$path.out" if [ $? -ne 0 ]; then printf "%s: %s not found or %s.out fails \e creation checks.\en" $0 "$path" "$path" $reset # reset the noclobber option in case a trap # on EXIT depends on it exit 1 fi $reset PROCESSING < "$path" > "$path.out"\fR .fi .in -2 .sp .sp .LP The following assumptions are made in this example: .RS +4 .TP 1. \fBPROCESSING\fR represents the code that will be used by the application to use \fB$path\fR once it is verified that \fB$path.out\fR will work as intended. .RE .RS +4 .TP 2. The state of the \fBnoclobber\fR option is unknown when this code is invoked and should be set on exit to the state it was in when this code was invoked. (The \fBreset\fR variable is used in this example to restore the initial state.) .RE .RS +4 .TP 3. Note the usage of: .sp .in +2 .nf \fBrm "$path.out" > "$path.out"\fR .fi .in -2 .sp .sp .ne 2 .na \fBa.\fR .ad .RS 6n The \fBpathchk\fR command has already verified, at this point, that \fB$path.out\fR will not be truncated. .RE .sp .ne 2 .na \fBb.\fR .ad .RS 6n With the \fBnoclobber\fR option set, the shell will verify that \fB$path.out\fR does not already exist before invoking \fBrm\fR. .RE .sp .ne 2 .na \fBc.\fR .ad .RS 6n If the shell succeeded in creating \fB$path.out\fR, \fBrm\fR will remove it so that the application can create the file again in the \fBPROCESSING\fR step. .RE .sp .ne 2 .na \fBd.\fR .ad .RS 6n If the \fBPROCESSING\fR step wants the file to exist already when it is invoked, the: .sp .in +2 .nf \fBrm "$path.out" > "$path.out"\fR .fi .in -2 .sp should be replaced with: .sp .in +2 .nf \fB> "$path.out"\fR .fi .in -2 .sp which will verify that the file did not already exist, but leave \fB$path.out\fR in place for use by \fBPROCESSING\fR. .RE .RE .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBpathchk\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS .sp .LP The following exit values are returned: .sp .ne 2 .na \fB\fB0\fR\fR .ad .RS 6n All \fIpath\fR operands passed all of the checks. .RE .sp .ne 2 .na \fB\fB>0\fR\fR .ad .RS 6n An error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard .TE .SH SEE ALSO .sp .LP \fBpax\fR(1), \fBtest\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)