vnop_setattr Entry Point

Purpose

Sets attributes of a file.

Syntax

int vnop_setattr (vp, cmd, arg1, arg2, arg3, crp)
struct vnode * vp;
int  cmd;
int  arg1;
int  arg2;
int  arg3;
struct ucred * crp;

Description

The vnop_setattr entry point is used by the logical file system to set the attributes of a file. This entry point is used to implement the chmod, chownx, and utime subroutines.

The values that the arg parameters take depend on the value of the cmd parameter. The vnop_setattr entry point accepts the following cmd values and arg parameters:

Possible cmd Values for the vnop_setattr Entry Point
Command V_OWN V_UTIME V_MODE
arg1 int flag; int flag; int mode;
arg2 int uid; timestruc_t *atime; Unused
arg3 int gid; timestruc_t *mtime; Unused
Note: For V_UTIME, if arg2 or arg3 is NULL, then the corresponding time field, atime and mtime, of the file should be left unchanged.

Parameters

Item Description
vp Points to the virtual node (v-node) of the file.
cmd Defines the setting operation. This parameter takes the following values:
V_OWN
Sets the user ID (UID) and group ID (GID) to the UID and GID values of the new file owner. The flag argument indicates which ID is affected.
V_UTIME
Sets the access and modification time for the new file. If the flag parameter has the value of T_SETTIME, then the specific values have not been provided and the access and modification times of the object should be set to current system time. If the T_SETTIME value is not specified, the values are specified by the atime and mtime variables.
V_MODE
Sets the file mode.

The /usr/include/sys/vattr.h file contains the definitions for the three command values.

arg1, arg2, arg3 Specify the command arguments. The values of the command arguments depend on which command calls the vnop_setattr entry point.
crp Points to the cred structure. This structure contains data that the file system can use to validate access permission.

Execution Environment

The vnop_setattr entry point can be called from the process environment only.

Return Values

Item Description
0 Indicates success.

Nonzero return values are returned from the /usr/include/sys/errno.h file to indicate failure.