tpf_setFileAttribute–Set the value of a file attribute
This function allows an application to set the named attribute for a specified file.
Last updated
- Changed for PUT10 (information only; no code change).
- Added for PUT00.
Format
int tpf_setFileAttribute(const char *path, const char *attribute, int flag); - path
- A pointer to a null-terminated character string that defines the file on which the function will act.
- attribute
- A null-terminated character string, in the form name=value of the attribute to be set.
- flag
- Specifies whether the file attribute will be changed. If the flag is 0 and the attribute exists already, it will not be changed. If the flag is nonzero and the attribute exists already, its value will be changed to the one specified.
Normal return
If the function call is successful, a value of 0 will be returned.
Error return
If an error occurred, a value
of -1 will be returned and errno is set to one
of the following values:
- ENOTDIR
- A component of the path prefix is not a directory.
- ENAMETOOLONG
- A component of a path name exceeded 255 characters, or an entire path name exceeded 1023 characters.
- ENOENT
- One of the following occurred:
- The named file does not exist.
- A component of the path name that must exist does not exist.
- EACCES
- One of the following occurred:
- Search permission is denied for a component of the path prefix.
- The required file permissions for writing are not set.
- ELOOP
- Too many symbolic links were found while translating the path name.
- EROFS
- The named file resides on a read-only file system, and the file is to be modified.
- EOPNOTSUPP
- The named file is in a file system that does not support this function.
- ENOSPC
- There is no space available in the file system to hold the attribute.
- EIO
- An I/O error occurred while making the attribute entry.
- EFAULT
- The path or attribute argument points outside the allocated address space for the process.
- EINVAL
- An attempt was made to pass an incorrect formatted attribute string. The string must be in the format name=value.
Programming considerations
Users must have write access to the file to set or change a file attribute.
Examples
The following example sets the
specified file attribute.
#include <tpf/cfattr.h>
⋮
char attr{}="servicelevel=1";
char path{}="/usr/name/file1";
int flag=1, rc=0;
if((rc=tpf_setFileAttribute(path,attr,flag))==-1)
{
...process error
} Related information
- For more information, see the following structure and functions:
- IfileAttribute: File attribute structure for open
- tpf_delFileAttribute–Delete a file attribute
- tpf_fdelFileAttribute–Delete a file attribute
- tpf_fgetFileAttribute–Get the value of a file attribute
- tpf_fsetFileAttribute–Set the value of a file attribute
- tpf_getFileAttribute–Get the value of a file attribute.
- For more information about z/TPF C/C++ language support, see z/TPF C functions overview.
- For more information about the file attributes that are supported on the file system, see File attribute support in the z/TPF Concepts and Structures.