libfsmgt.h revision 2
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 1N/A * Public data type declarations * Represents a list of /etc/mnttab entries with associated * information from kstat. /* paths for failover. */ int nml_timeo;
/* inital timeout in 10th sec */ * Command execution interface method declarations * Method: cmd_execute_command * Description: Executes the command passed into the function as if it was * the input to a shell and returns the separated stdout and stderr messages * which can be accessed by the client via the returned file descriptors using * the cmd_retrieve_string method or one of their own methods. * char * - The command to execute. Expected in the format of a shell command. * int * - Upon return from the function, this is the file descriptor that can * be used to access the output from the command to stdout. * int * - Upon return from the function, this is the file descriptor that can * be used to access the output from the command to stderr. * Supposed to be the integer representing the exit value of the command * executed, but due to the way blocking on file descriptors works, it will * only return a 0 (zero) value. The reason: The producer, in this case the * command being executed, will block when a certain amount of data is written * to the file descriptor and will not be able to write any more data until the * consumer reads from the file descriptor so since we are not reading in the * data from the file descriptors in this method and we are allowing the client * do what they want with the data we can't wait until the command is finished * executing to get the return value. * Method: cmd_execute_command_and_retrieve_string * Description: Executes the command passed into the function as if it was the * input to a shell and returns the output to stderr and stdout as a string as * it would appear in the shell (stdout and stderr are mixed). * char * - The command to execute. Expected in the format of a shell command. * int * - Upon return from the function, this should be used to determine if an * error occurred in the execution of the command and the retrieval of * output data from the command. * The output to stdout and stderr created by the execution of the passed in * Method: cmd_retrieve_string * Description: Retrieves the data from the passed in file descriptor and * returns it to the caller in the form of a string. * int - The file descriptor to be read from. * int * - Upon return from the function, this should be the used to determine * if an error occurred in the retrieval of the data from the file * A non-zero value represents the occurrence of an error. * The data from the file descriptor in the form of a string. * NOTE: The caller must free the space allocated (with calloc) for the return * File interface method declarations * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fileutil_free_string_array() * Method: fileutil_add_string_to_array * Description: Adds one line to the file image string array * char ***string_array - pointer array of strings holding the lines * char *line - the line to be added to the new file * int *count - the number of elements in the string array * int *err - error pointer for returning any errors encountered * B_TRUE on success, B_FALSE on failure. * On success string_array is set to the new array of strings. On failure * string_array is unchanged. * Method: fileutil_free_string_array * Description: Frees the space allocated to a string array. * char ** - is the array to be freed * int - the number of elements in the array * Method: fileutil_get_cmd_from_string * Description: Returns a string containing a line with all comments and * trailing white space removed. * char *input_stringp - the line to remove all coments and trailing white * Note: The memory allocated for the returned string must be freed by the * caller of fileutil_get_cmd_from_string(). * Method: fileutil_get_first_column_data * Description: Returns a string array which is filled with the data in the * first column of the lines in a table formatted file. * FILE* - The file pointer of the table formatted file to get data from. * int* - will be filled with the number of elements in the array that is passed * int* - error pointer. If an error occurs this will be non-zero upon return * Two-dimensional array of characters (string array). Each element in the * array is the first column data of each row in the table. * Description: Convenience function for retrieving the default remote file * The default remote filesystem type. * Method: fileutil_getline * Description: Convenience function for retrieving the next line from a file. * Commented lines are not returned and comments at the end of * FILE * - The file pointer to a file that has been opened for reading. * char * - The line retrived from the file will be placed in this string. * int * - error pointer - If an error occurs this will be non-zero upon * return from the function. * If successfull the line retrieved from the file will be returned. * Otherwise NULL be be returned. * Mount defaults (/etc/vfstab) interface method declarations * Method: fs_add_mount_default * Description: Adds an entry to vfstab based on the fs_mntdefaults_t * structure that is passed in. * fs_mntdefaults_t *newp - The structure containing the mount information * to be placed in vfstab. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function. * If successful a pointer to a list containing all the present vfstab * entries is returned. On failure NULL is returned. * Method: fs_check_for_duplicate_DFStab_paths * Description: Checks dfstab for duplicate paths and returns the number of * times the path passed in was encountered. The functon is used to help make * sure a path is only listed in dfstab once. * char *path - the path to check for * int *err - error pointer - If an error occurs this will be non-zero upon * return from the function. * The number of times the specified path is encountered in dfstab. * Method: fs_del_mount_default_ent * Description: Deletes the specified vfstab entry from the vfstab file. * fs_mntdefaults_t *old_vfstab_ent - The mount information that corresponds * to the vfstab entry to be deleted. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function. * If successful a pointer to a list containing all the changed vfstab * entries is returned. On failure NULL is returned. * Method: fs_edit_mount_defaults * Description: Edits the specified vfstab entry with the new mount * fs_mntdefaults_t *old_vfstab_ent - The old vfstab entry that is to be edited. * fs_mntdefaults_t *new_vfstab_ent - The new vfstab entry information. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Method: fs_free_mntdefaults_list * Description: Frees the memory used when a fs_mntdefaults_t structure * fs_mntdefaults_t *headp - The pointer to the first element in the list * of mntdefault structures. * Method: fs_get_filtered_mount_defaults * Description: Retrieves vfstab entries based in the fields in the * fs_mntdefaults_t structure passed in. The fields that are not to * be used in the filter will be set to NULL. * fs_mntdefaults_t *filter - The structure containing the fields to be * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * The list of all vfstab entries meeting the filter criteria are returned. * On failure NULL is returned. * Method: fs_get_mount_defaults * Description: Retrieves vfstab entries and returns a list of * fs_mntdefaults_t structures. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * fs_mntdefaults_t * - Returns a list of all vfstab entries. * Mount (/etc/mnttab) interface method declarations * Method: fs_free_mount_list * Description: Frees the mount list created when retrieving mnttab entries. * fs_mntlist_t *headp - The mount list to be freed. * Method: fs_get_availablesize * Description: Calculates the total size available on the filesystem. * char *mntpnt - The mount point to use for gathering the stat information * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * The total size available on the filesystem. * Method: fs_get_avail_for_nonsuperuser_size * Description: Calculates the available space on the filesystem for * char *mntpnt - The mount point for the filesystem. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * The available space for nonsuperusers. * On failure NULL is returned. * Method: fs_get_blocksize * Description: Retrieves the preferred filesystem block size. * char *mntpnt - The mount point for the filesystem. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the preferred filesystem block size. * On failure NULL is returned. * Method: fs_get_filtered_mount_list * Description: Can be used to filter mounts only by the following mount * attributes or a mixture of them: * 3.) mount option string * char *resource - The name of the resource to be mounted * char *mountp - The pathname of the directory on which the filesystem * char *mntopts - The mount options * char *time - The time at which the filesystem was mounted * boolean_t find_overlays - Flag used to turn on overlay checking * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * The list of all mnttab entries meeting the filter criteria are returned. * On failure NULL is returned. * Method: fs_get_fragsize * Description: Determines the fundamental filesystem block size. * char *mntpnt - The mount point for the filesystem. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the fundamental filesystem block size. * On failure NULL is returned. * Method: fs_get_maxfilenamelen * Description: Determines the maximum file name length for the filesystem. * char *mntpnt - The mount point for the filesystem. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the maximum file name length for the specified filesystem. * On failure NULL is returned. * Method: fs_get_mounts_by_mntopt * Description: Returns only mounts with the specified mount option set. * char *mntopt - The mount option used for filtering mounts * boolean_t find_overlays - Flag used to turn on overlay checking * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the list of all mnttab entries with the matching mount option. * On failure NULL is returned. * Method: fs_get_mount_list * Description: Returns a list of all mounts in mnttab * char *mntpnt - The mount point for the filesystem * boolean_t find_overlays - Flag used to turn on overlay checking * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the list of all mounts and associated mount information for mounts * listed in mnttab. On failure NULL is returned. * Method: fs_get_totalsize * Description: Determines the total size of the filesystem using the * total number of blocks and the block size. * char *mntpnt - The mount point for the filesystem * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the total size of the filesystem. * On failure NULL is returned. * Method: fs_get_usedsize * Description: Calculates the size of the used portion of the filesystem. * char *mntpnt - The mount point for the filesystem * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the size of the the used portion of the filesystem. * On failure NULL is returned. * Description: Checks the filesystem flags to see if the filesystem is * char *mntpnt - The mount point for the filesystem * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns B_TRUE if the readonly flag is set and B_FALSE if not. * On error the error pointer is set to errno. * Method: fs_parse_optlist_for_option * This method will parse the given comma delimited option list (optlist) for * the option passed into the function. If the option (opt) to search for * is one that sets a value such as onerror=, the value to the right of the "=" * character will be returned from the function. This function expects the * opt parameter to have the "=" character appended when searching for options * char *optlist - The option string to be parsed * char *opt - The option to search for * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the option as found in the option list. * If the option is not found NULL is returned. * On error NULL is returned and the error pointer is set to errno. * Method: fs_free_share_list * Description: Used to free populated fs_sharelist_t structures * fs_sharelist_t *headp - the pointer to the first element in the list. * Method: fs_get_share_list * Description: Gets a list of the shares on the system from /etc/dfs/sharetab * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns a list of fs_sharelist_t structures containing all of the shares * On error NULL is returned and errp is set to errno. * Method: fs_parse_opts_for_sec_modes * Description: Parses the option string for security modes and returns * an array of strings containing all modes. * char * - options string to be parsed. * int * - count of the number of modes found. * Returns an array of string containing all security opts listed in the * passed in option string. On error NULL is returned. * Method: fs_create_array_from_accesslist * Description: Takes the colon separated access list parses the list * into an array containing all the elements of the list. * The array created is returned and count is set to the * number of elements in the array. * char *access_list - The string containing the colon sperated access list. * int *count - Will contain the number of elements in the array. * int *err - any errors encountered. * Method: fs_add_DFStab_ent * Description: Adds an entry to dfstab and to the list of dfstab * entries. Returns a pointer to the head of the dfstab entry list. * char *cmd - the share command to be added to dfstab * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the pointer to the updated dfstab entry list. * Method: fs_del_DFStab_ent * Description: Deletes an entry from dfstab and from the list of * char *del_cmd - The share command to be removed * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the pointer to the updated dfstab entry list. * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fs_free_DFStab_ents() * Method: fs_edit_DFStab_ent * Description: Changes the specified line in dfstab to match the second * char *old_cmd - The share command that will be changed. * char *new_cmd - The share command that will replace old_cmd. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the pointer to the updated dfstab entry list. * Method: fs_free_DFStab_ents * Description: Frees the dfstab entry list. * fs_dfstab_entry_t list - The pointer to the dfstab entry list. * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fs_free_DFStab_ents() * Method: fs_get_DFStab_ents * Description: Retrieves the dfstab entry list. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the pointer to the dfstab entry list. * If NULL is returned and errp is 0 then dfstab has no entries. If errp is * not 0 there was an error and the value of errp is set to the errno * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fs_free_DFStab_ents() * Method: fs_get_DFStab_ent_Desc * Description: Retrieves the description information for the present * fs_dfstab_entry_t entry - the dfstab entry to retrieve the description from. * The string containing the description for the dfstab entry. * If the description is not set NULL is returned. * Note: the description is an optional share option and a return value of * NULL is not an error but indicates that the description was not set. * Method: fs_get_DFStab_ent_Fstype * Description: Retrieves the filesystem type information from the dfstab * fs_dfstab_entry_t entry - the dfstab entry to retrieve the fstype from. * The string containing the filesystem type. * Note: if fstype is not set in the dfstab entry the default fstype is * Method: fs_get_DFStab_ent_Next * Description: Retrieves the next entry in the dfstab entry list. * fs_dfstab_entry_t entry - The dfstab entry pointer to get the next * Returns the next dfstab entry. * A return value of NULL indicates the end of the dfstab entry list. * Method: fs_get_DFStab_ent_Options * Description: Retrieves the share options from the dfstab * fs_dfstab_entry_t entry - The dfstab entry to retrieve the share * Returns the string containing the share options. * A NULL value indicates that no options were specified in the dfstab entry. * Method: fs_get_DFStab_ent_Path * Description: Retrieves the path information from the dfstab * fs_dfstab_entry_t entry - the dfstab entry to retrieve the path from. * Returns the string containing the path. * A NULL value indecates that no path information is available for the * dfstab entry. A NULL value here is an error and indicates an invalid * Method: fs_get_DFStab_ent_Res * Description: Retrieves the resource information from the dfstab entry * fs_dfstab_entry_t entry - the dfstab entry to retrieve the resource * Returns the string containing the path. * A NULL value indecates that no resource information is available for the * Method: fs_get_Dfstab_share_cmd * Description: Retrieves the share command that corresponds to the * dfstab entry passed in. * fs_dfstab_entry_t entry - The dfstab entry that will be used to create * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns the string containing the share command. * A NULL value indicates an error occured and errp will be non zero. * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fs_free_DFStab_ents() * Method: fs_set_DFStab_ent * Description: Used to add entries into dfstab * char *path - The path for the dfstab entry * char *fstype - The filesystem type for the share * char *options - The share options to be used for the dfstab entry * char *description - The description for the share * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * Returns a pointer to the begining of the dfstab entry list * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling fs_free_DFStab_ents() * Method: fs_del_All_DFStab_ents_with_Path * Description: Removes all dfstab entries with the specified path. * char *path - The path to checked for removal from dfstab. * int *err - error pointer. * Return: returns a pointer to the nfs list of dfstab entries. * NFS mount interface method declarations * Method: nfs_free_mntinfo_list * Description: Used to free the network id list, which is an array of strings. * nfs_mntlist_t *mountinfo_list - The list of mounts and associated mount * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling nfs_free_mntinfo_list() * Method: nfs_get_filtered_mount_list * Description: Can be used to filter nfs mounts only by the following mount * attributes or a mixture of them: * 3.) mount option string * NULL must be passed into the options that are not being used in the filter. * char *resource - The name of the resource to be mounted * char *mountp - The pathname of the directory on which the filesystem * char *mntopts - The mount options * char *time - The time at which the filesystem was mounted * boolean_t find_overlays - Flag used to turn on overlay checking * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * nfs_mntlist_t * - Returns a list of nfs mounts based on the * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling nfs_free_mntinfo_list() * Method: nfs_get_mounts_by_mntopt * Description: Can be used to filter mounts by the mount options attribute. * char *mntopts - The mount options * boolean_t find_overlays - Flag used to turn on overlay checking * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * nfs_mntlist_t * - Returns a list of nfs mounts based on the * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling nfs_free_mntinfo_list() * Method: nfs_get_mount_list * Description: Used to gather all NFS mounts and there associated * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * nfs_mntlist_t * - Returns a list of all nfs mounts. * Method: netcfg_free_networkid_list * Description: Used to free the network id list, which is an array of strings. * char **netlist - The array of strings containing the network id list * int num_elements - The number of elements in the network id list * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling netcfg_free_networkid_list() * Method: netcfg_get_networkid_list * Description: Used to create the network id list. * int *num_elements - The number of elements in the network id list. * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * char ** - Returns the netowk id list. * Method: nfssec_free_secmode_list * Description: Used to free the NFS security mode list. * char **seclist - The array of strings containing the security mode list * int num_elements - The number of elements in the list * Method: nfssec_get_default_secmode * Description: Used to retrieve the default security mode * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * char * - Returns the name of the default security mode * NOTE: the caller of this function is responsible for freeing any * memory allocated by calling nfssec_free_secmode_list() * Method: nfssec_get_nfs_secmode_list * Description: Used to create the NFS security mode list. * int *num_elements - The number of elements in the security mode list * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * char ** - Returns the NFS security mode list * System information interface method declarations * Method: sys_get_hostname * Description: Used to retrieve the name of the host * int *errp - error pointer - If an error occurs this will be non-zero upon * return from the function * char * - Returns the name of the host system