vxfs_ap_assign_file_pat - assign a pattern-based allocation policy for a directory
cc -I /opt/VRTS/include -L /opt/VRTS/lib-l vxfsutil -ldl
int vxfs_ap_assign_file_pat(int fd,
struct fsap_pattern_table *pat_assign,
vxfs_ap_assign_file_pat() assigns the pattern table for a directory specified by fd. If the directory has an existing pattern table, the table is replaced. After successfully setting the table, when a regular file is created in this directory, the files name and creating process UID and GID are matched to the patterns defined in the table in the given order. The first successful match is used to set the allocation policies of the file, taking precedence over inheriting per-file allocation policies. The flags in the matching pattern entry are applied to the allocation policy of the file being created.
To use this function, specify -l vxfsutil while linking.
When a subdirectory is created, the subdirectory can inherit the pattern table of its parent directory, if the table is inheritable.
The fd field is the file descriptor of the mount points directory.
The pat_assign field is a pointer to a structure that has pattern information to be assigned. Possible values for pat_assign are:
When a new file is created, the pattern matching matches the file name, user ID, and group ID with each entry in the pattern table in the same order as specified in the table, stopping with the first match.
pt_flags Pattern flags. pt_num Number of patterns to be set. If specified as zero, the call deletes the pattern table. pt_data Array of patterns (fsap_pattern_entry structures). Possible values for fsap_pattern_entry are: pe_flags Pattern entry flags. Possible values for pe_flags are:
FSAP_INHERIT Sets the flags of newly created files allocation policies to inherit. 0 Does not set the flags of newly created files allocation policies. pe_uid The user ID to match. Possible values for pe_uid are:
FSAP_PATTERN_ID_NONE Matches any user ID. 0 or greater Matches the specified user ID. pe_gid The group ID to match. Possible values for pe_gid are:
FSAP_PATTERN_ID_NONE Matches any group ID. 0 or greater Matches the specified group ID. pe_filename Specifies the filename component to match. Must be a non-null string to perform a match. pe_data_policy Specifies the data policy name string. The name cannot contain "\n" or "/". pe_meta_policy Specifies the meta policy name string. The name cannot contain "\n" or "/".
The pattern data can have a maximum of 8064 bytes. The number of patterns that can be stored depends on the number of pattern entries, the size of each entry, and the overhead required to store each entry.
Patterns can be checked only at runtime.
The pe_flags entry of the struct fsap_pattern_entry is unused and must be passed as zero (0).
Assigning or defining an allocation policy can fail because of a conflict with volume flags. The conflict detection attempts to detect all conflicts, but there is no guarantee that all conflicts will be detected.
This API supports file system versions 6.0 and above.
Possible values for pt_flags are:
FSAP_PATTERN_INHERIT Subdirectories created in the directory specified by fd inherit the directorys pattern table. Possible values for flags are: 0 The flags field must be passed with a value of 0.
vxfs_ap_assign_file_pat() returns zero on success, non-zero on failure.
EINVAL Invalid policy name. The name has invalid characters. ENOENT The named policy does not exist. E2BIG The number of patterns or pattern data exceeds the maximum allowed. EPERM The user cannot access the policy. The policy is defined as ROOT only. ENXIO An I/O error occurred during the operation. ENOTDIR The fd field does not point to a directory. ENOSPC There is not enough space to complete the operation. ENOSYS No appropriate licenses are installed. EROFS The specified file system is mounted read-only.