WG15 Defect Report Ref: 9945-2-68
Topic: cp pathname arguments


This is an approved interpretation of 9945-2:1993.

.

Last update: 1997-05-20


								9945-2-68

 _____________________________________________________________________________

	Topic:			cp pathname arguments
	Relevant Sections:	2.13.1


Defect Report:
-----------------------


(From: fred@mindcraft.com)
-----------------------

Dear Standards Board,

	I would like to an request official, binding interpretation
	from WG15 concerning the following point in ISO/IEC
	9945-2:1993 (POSIX.2).

	POSIX.2 defines pathname resolution by reference to POSIX.1
	(ISO/IEC 9945-1:1990), and specifically refers to the definition
	of PATH_MAX in POSIX.1 (see subclauses 2.2.2.121, 2.2.2.123 and
	2.13.1 of POSIX.2).  Those utilities specified in POSIX.2 that
	take pathname arguments are required to be able to resolve
	pathnames that (including an implied trailing null byte) are
	no more than PATH_MAX bytes in length, assuming no other system
	resource limits arise.

	The issue I would like resolved has to do with files that are
	implicitly referenced by utilities with pathnames that are
	longer than PATH_MAX.  Specifically, consider the command line

		cp <filename> <dirname>

	where <dirname> is a pathname of length PATH_MAX-1 that refers to
	a directory, and <filename> names a regular file.  The semantics
	of the cp utility require that (assuming no access or permission
	issues interfere) cp create a copy of <filename> in <dirname>.
	No pathname argument exceeds PATH_MAX-1 bytes,  However, this
	command implies a pathname of the target file, <dirname>/<filename>,
	that exceeds PATH_MAX bytes.  The reference is somewhat more than
	implicit, since the description of cp (POSIX.2 subclause 4.13.2,
	lines 2589-2591) states

		The cp utility shall copy the contents of each source_file
		to the destination path named by the concatenation of
		target, a slash character and the last component of
		source_file.

	Is cp required to work in this case?

	Note that a similar question can be asked with respect to the
	mv and ln utilities and perhaps others.

Thank you for your attention to this matter.

WG15 response for 9945-2:1993 
-----------------------------------

The wording in cp as specified in this interpretation 
request clearly allows an implementation of cp to call open with the 
pathname created by concatenating dirname, slash("/"), and filename and 
in cases where this string is resulted longer than PATH_MAX there is no 
requirement that this should succeed.

Rationale for Interpretation:
-----------------------------
None.



 _____________________________________________________________________________