lchown (BPX1LCO, BPX4LCO) — Change the owner or group of a file, directory, or symbolic link
Function
The lchown service changes the owner or group (or both) of a file or a directory. The owner is identified by a user ID (UID) and a group ID (GID).
The lchown service is identical to the chown service, except when the Pathname specified is a symbolic link (a pointer to another file or directory). If the Pathname is a symbolic link, the UID and/or the GID of the symbolic link are updated, rather than the UID or GID of the file to which the symbolic link refers. See chown (BPX1CHO, BPX4CHO) — Change the owner or group of a file or directory.
Requirements
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1LCO): | 31-bit |
AMODE (BPX4LCO): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
Format
|
AMODE 64 callers use BPX4LCO with the same parameters.
Parameters
- Pathname_length
- Supplied parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword that contains the length of the path name of the file for which the owner or group is to be changed.
- Pathname
- Supplied parameter
- Type:
- Character string
- Character set:
- No restriction
- Length:
- Specified by the Pathname_length parameter
The name of a field that contains the path name of the file. The length of this field is specified in Pathname_length.
Path names can begin with or without a slash.- A path name that begins with a slash is an absolute path name. The slash refers to the root directory, and the search for the file starts at the root directory.
- A path name that does not begin with a slash is a relative path name. The search for the file starts at the working directory.
If the path name specifies a symbolic link file, the lchown service changes the ownership of the symbolic link file itself.
- Owner_UID
- Supplied parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword field that contains the new owner UID that is assigned to the file; or the present value or -1, if there is no change. This parameter must be specified.
- Group_ID
- Supplied parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword field that contains the new owner GID that is assigned to the file; or the present value or -1, if there is no change. This parameter must be specified.
- Return_value
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the lchown service returns 0 if the request is successful, or -1 if it is not successful.
- Return_code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the lchown service stores the return code. The lchown service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The lchown service can return one of the following values in the Return_code parameter:Return_code Explanation EACCES The calling process does not have permission to search some component of the Pathname prefix. EINVAL The Owner_UID or Group_ID parameter is incorrect. ELOOP A loop exists in symbolic links that were encountered during resolution of the Pathname argument. This error is issued if more than 24 symbolic links are detected in the resolution of Pathname. ENAMETOOLONG Pathname is longer than 1023 characters; or a component of the path name is longer than 255 characters. ENOENT No file named Pathname was found; or no path name was specified. The following reason code can accompany the return code: JRFileNotThere. ENOTDIR Some component of the Pathname prefix is not a directory. EPERM The calling process does not have appropriate privileges (see Authorization). EROFS Pathname is on a read-only file system. The following reason code can accompany the return code: JRReadOnlyFS. - Reason_code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the lchown service stores the reason code. The lchown service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
Usage notes
- The lchown service changes the owner UID and owner GID of a file. Only a caller with appropriate privileges (see Authorization) can change the owner UID of a file.
- The owner GID of a file can be changed by a caller if the caller
has appropriate privileges, or if the caller meets all of these conditions:
- The effective UID of the caller matches the file's owner UID.
- The Owner_UID value that is specified in the change request matches the file's owner UID.
- The Group_ID value that is specified in the change request is the effective GID, or one of the supplementary GIDs, of the caller.
- The set-user-ID-on-execution and set-group-ID-on-execution permissions of the file mode are automatically turned off.
- If the change request is successful, the change time for the file is updated.
- Values for both Owner_UID and Group_ID must be specified. To change only one of these values, set the other to its present value or to -1.
Related services
- chown (BPX1CHO, BPX4CHO) — Change the owner or group of a file or directory
- fstat (BPX1FST, BPX4FST) — Get status information about a file by descriptor
- lstat (BPX1LST, BPX4LST) — Get status information about a file or symbolic link by path name
- stat (BPX1STA, BPX4STA) — Get status information about a file by pathname
Characteristics and restrictions
There are no restrictions on the use of the lchown service.
Examples
For an example using this callable service, see BPX1LCO (lchown) example.