Remove Directory (RMDIR)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Remove Directory (RMDIR) command removes a specified directory from the system after all objects in the directory have been unlinked and the directory is no longer in use. If a directory to be removed contains objects, this command optionally unlinks all of the objects and then deletes the directory. If the user does not have the authority to unlink every object in the directory, only those objects for which the user has the authority are unlinked. When an object cannot be unlinked, the directory and all objects in the directory that cannot be unlinked are not removed.

This command is an alias for the Remove Directory (RMVDIR) command and can also be issued using the following alternative command names:

For more information about integrated file system commands, see the Integrated file system information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.

Restrictions:

  1. In the "root" (/),QOpenSys and user-defined file systems, the user must have object existence (*OBJEXIST) authority for the specified directory, and *OBJEXIST authority for every object in it. If the user does not have *OBJEXIST authority for one or more objects in the directory, those objects are not unlinked and the directory is not removed.
  2. In the "root" (/),QOpenSys, and user-defined file systems, the user must have write, execute (*WX) authority to the parent directory.
  3. In the QDLS file system, the user must have all (*ALL) authority to the directory and execute (*X) authority to its parent directory.
  4. The user must have execute (*X) authority to the prefix directory.
  5. See the iSeries Security Reference, SC41-5302 book for the authority requirements for other file systems.
  6. A user cannot remove a directory within a "root" (/), QOpenSys, or user-defined file system directory that has the "restricted rename and unlink" attribute set on (this attribute is equivalent to the S_ISVTX mode bit) unless one or more of the following are true:
    1. The user is the owner of the directory to be removed.
    2. The user is the owner of the parent directory of the directory to be removed.
    3. The user has all object (*ALLOBJ) special authority.
  7. A directory can not be removed if it is the current directory for a job.
  8. This command cannot be used to delete reserved directories and libraries.
  9. When an object is in use in QSYS.LIB, independent ASP QSYS.LIB, or QDLS, the object cannot be unlinked. When an object is in use in QOpenSys or the "root" (/) file system, the object is successfully unlinked, and the object is deleted when no longer in use.
Top

Parameters

Keyword Description Choices Notes
DIR Directory Path name Required, Positional 1
RMVLNK Remove link *NO, *YES Optional
Top

Directory (DIR)

Specifies the path name of the directory or a pattern to match the path name or names of directories to be removed.

The object path name can be either a simple name or a name that is qualified with the name of the directory in which the object is located. A pattern can be specified in the last part of the path name. An asterisk (*) matches any number of characters and a question mark (?) matches a single character. If the path name is qualified or contains a pattern, it must be enclosed in apostrophes.

For more information on specifying path names, refer to "Object naming rules" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.

Top

Remove link (RMVLNK)

Specifies whether to unlink all objects in a directory or not allow the directory to be deleted if it contains objects.

*NO
Only an empty directory is removed. A directory may contain entries for the directory (.) and for the parent directory (..) and still be treated as an empty directory.
*YES
All objects within the specified directory are deleted. If the file system that contains the directory does not support removal of links in the directory, error message CPFA0AC "Request cannot be completed. Directory contains objects." will be sent.
Top

Examples

The alternative command name for RMDIR is RMVDIR. The following examples use the alternative command name, but RMDIR can be replaced directly for RMVDIR in all of them.

Example 1: Removing a Directory and the Objects in that Directory

RMVDIR   DIR('W')  RMVLNK(*YES)

This command removes directory W after all of its objects have been unlinked. If directory W contains objects and you have the authority to unlink all of those objects, all of the objects are unlinked and directory W is removed. If you do not have authority to unlink all of the objects, only those for which you have authority are unlinked and the directory is not removed.

Top

Error messages

*ESCAPE Messages

CPFA085
Home directory not found for user &1.
CPFA093
Name matching pattern not found.
CPFA09C
Not authorized to object. Object is &1.
CPFA09D
Error occurred in program &1.
CPFA09E
Object in use. Object is &1.
CPFA0A1
An input or output error occurred.
CPFA0A3
Path name resolution causes looping.
CPFA0A7
Path name too long.
CPFA0A9
Object not found. Object is &1.
CPFA0AB
Operation failed for object. Object is &1.
CPFA0AC
Request cannot be completed. Directory contains objects.
CPFA0AD
Function not supported by file system.
CPFA0B1
Requested operation not allowed. Access problem.
CPFA0B2
No objects satisfy request.
CPFA0B7
&1 directories removed. &2 directories not removed.
Top