Home | History | Annotate | Download | only in common
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef _LIBFSMGT_H
     28 #define	_LIBFSMGT_H
     29 
     30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31 
     32 #ifdef __cplusplus
     33 extern "C" {
     34 #endif
     35 
     36 #include <stdio.h>
     37 #include <sys/param.h>
     38 #include <nfs/nfs_sec.h>
     39 #include <sys/utsname.h>
     40 
     41 #define	DFSTYPES	"/etc/dfs/fstypes"		/* dfs list */
     42 #define	DFSTAB		"/etc/dfs/dfstab"		/* dfs list */
     43 #define	BUFSIZE		65536
     44 #define	LINESZ		2048
     45 
     46 typedef void *fs_dfstab_entry_t;
     47 
     48 /*
     49  * Public data type declarations
     50  */
     51 
     52 /*
     53  * Represents a list of the /etc/vfstab entries
     54  */
     55 typedef struct mount_default_list {
     56 	struct mount_default_list *next;
     57 	char *resource;
     58 	char *fsckdevice;
     59 	char *mountp;
     60 	char *fstype;
     61 	char *fsckpass;
     62 	char *mountatboot;
     63 	char *mntopts;
     64 } fs_mntdefaults_t;
     65 
     66 /*
     67  * Represents a list of /etc/mnttab entries
     68  */
     69 typedef struct mount_list {
     70 	struct mount_list *next;
     71 	char *resource;
     72 	char *mountp;
     73 	char *fstype;
     74 	char *mntopts;
     75 	char *time;
     76 	uint_t major;
     77 	uint_t minor;
     78 	boolean_t overlayed;
     79 } fs_mntlist_t;
     80 
     81 /*
     82  * Represents a /etc/dfs/sharetab entry
     83  */
     84 typedef struct share_list {
     85 	struct share_list *next;
     86 	char *path;
     87 	char *resource;
     88 	char *fstype;
     89 	char *options;
     90 	char *description;
     91 } fs_sharelist_t;
     92 
     93 /*
     94  * Represents a list of /etc/mnttab entries with associated
     95  * information from kstat.
     96  */
     97 typedef struct nfs_mntlist {
     98 	struct nfs_mntlist *next;
     99 	char		nml_curpath[MAXPATHLEN];	/* current path on */
    100 							/* server */
    101 	char		nml_curserver[SYS_NMLN];	/* current server */
    102 	char		**nml_failoverlist;	/* The list of servers */
    103 						/* and corresponding */
    104 						/* paths for failover. */
    105 	char		*nml_fstype;		/* filesystem type */
    106 	char		*nml_mntopts;		/* mount options */
    107 	char		*nml_mountp;		/* mount point */
    108 	char		*nml_resource;		/* mnttab.mnt_special */
    109 	char		nml_proto[KNC_STRSIZE];	/* transfer protocol */
    110 	char		*nml_securitymode;	/* security mode name */
    111 	char		*nml_time;		/* time mounted */
    112 	int		nml_failovercount;	/* number of failover servers */
    113 	int		nml_retrans;		/* times to retry request */
    114 	int		nml_timeo;		/* inital timeout in 10th sec */
    115 	ulong_t		nml_fsid;		/* filesystem ID */
    116 	uint_t		nml_acdirmax;	/* max time to hold cached dir attr */
    117 	uint_t		nml_acdirmin;	/* min time to hold cached dir attr */
    118 	uint_t		nml_acregmax;	/* max time to hold cached file attr */
    119 	uint_t		nml_acregmin;	/* min time to hold cached file attr */
    120 	uint32_t	nml_curread;		/* current read size */
    121 	uint32_t	nml_curwrite;		/* current write size */
    122 	uint32_t	nml_vers;		/* nfs version */
    123 	boolean_t	nml_directio;	/* force direct IO */
    124 	boolean_t	nml_grpid;	/* group id inherited from parent */
    125 	boolean_t	nml_hard;	/* hard or soft mount */
    126 	boolean_t	nml_intr;	/* Key board intrupts */
    127 	boolean_t	nml_noac;	/* no ata and attribute caching */
    128 	boolean_t	nml_nocto;	/* no close-to-open  consistency */
    129 	boolean_t	nml_overlayed;	/* Is filesystem overlayed */
    130 	boolean_t	nml_xattr;	/* allow extended attributes */
    131 } nfs_mntlist_t;
    132 
    133 /*
    134  * Command execution interface method declarations
    135  */
    136 
    137 /*
    138  * Method: cmd_execute_command
    139  *
    140  * Description: Executes the command passed into the function as if it was
    141  * the input to a shell and returns the separated stdout and stderr messages
    142  * which can be accessed by the client via the returned file descriptors using
    143  * the cmd_retrieve_string method or one of their own methods.
    144  *
    145  * Parameters:
    146  * char * - The command to execute.  Expected in the format of a shell command.
    147  * int * - Upon return from the function, this is the file descriptor that can
    148  * 	be used to access the output from the command to stdout.
    149  * int * - Upon return from the function, this is the file descriptor that can
    150  *	be used to access the output from the command to stderr.
    151  *
    152  * Return:
    153  * Returns 0 (zero).
    154  * Supposed to be the integer representing the exit value of the command
    155  * executed, but due to the way blocking on file descriptors works, it will
    156  * only return a 0 (zero) value.  The reason: The producer, in this case the
    157  * command being executed, will block when a certain amount of data is written
    158  * to the file descriptor and will not be able to write any more data until the
    159  * consumer reads from the file descriptor so since we are not reading in the
    160  * data from the file descriptors in this method and we are allowing the client
    161  * do what they want with the data we can't wait until the command is finished
    162  * executing to get the return value.
    163  */
    164 int	cmd_execute_command(char *cmd, int *output_filedes, int *error_filedes);
    165 
    166 /*
    167  * Method: cmd_execute_command_and_retrieve_string
    168  *
    169  * Description: Executes the command passed into the function as if it was the
    170  * input to a shell and returns the output to stderr and stdout as a string as
    171  * it would appear in the shell (stdout and stderr are mixed).
    172  *
    173  * Parameters:
    174  * char * - The command to execute.  Expected in the format of a shell command.
    175  * int * - Upon return from the function, this should be used to determine if an
    176  * 	error occurred in the execution of the command and the retrieval of
    177  *	output data from the command.
    178  * data from the command.
    179  *
    180  * Return:
    181  * The output to stdout and stderr created by the execution of the passed in
    182  * command.
    183  */
    184 char	*cmd_execute_command_and_retrieve_string(char *cmd, int *errp);
    185 
    186 /*
    187  * Method: cmd_retrieve_string
    188  *
    189  * Description: Retrieves the data from the passed in file descriptor and
    190  * returns it to the caller in the form of a string.
    191  *
    192  * Parameters:
    193  * int - The file descriptor to be read from.
    194  * int * - Upon return from the function, this should be the used to determine
    195  * 	if an error occurred in the retrieval of the data from the file
    196  *	descriptor.
    197  *	A non-zero value represents the occurrence of an error.
    198  *
    199  * Return:
    200  * The data from the file descriptor in the form of a string.
    201  * NOTE: The caller must free the space allocated (with calloc) for the return
    202  * value using free().
    203  */
    204 char	*cmd_retrieve_string(int filedes, int *errp);
    205 
    206 /*
    207  * File interface method declarations
    208  */
    209 
    210 /*
    211  * NOTE: the caller of this function is responsible for freeing any
    212  * memory allocated by calling fileutil_free_string_array()
    213  *
    214  * Method: fileutil_add_string_to_array
    215  *
    216  * Description: Adds one line to the file image string array
    217  *
    218  * Parameters:
    219  * char ***string_array - pointer array of strings holding the lines
    220  *         for the new file
    221  * char *line - the line to be added to the new file
    222  * int *count - the number of elements in the string array
    223  * int *err - error pointer for returning any errors encountered
    224  *
    225  * Return:
    226  * B_TRUE on success, B_FALSE on failure.
    227  *
    228  * Note:
    229  * On success string_array is set to the new array of strings. On failure
    230  * string_array is unchanged.
    231  */
    232 boolean_t fileutil_add_string_to_array(char ***, char *, int *, int *);
    233 
    234 /*
    235  * Method: fileutil_free_string_array
    236  *
    237  * Description: Frees the space allocated to a string array.
    238  *
    239  * Parameters:
    240  * char ** - is the array to be freed
    241  * int - the number of elements in the array
    242  */
    243 void	fileutil_free_string_array(char **, int);
    244 
    245 /*
    246  * Method: fileutil_get_cmd_from_string
    247  *
    248  * Description: Returns a string containing a line with all comments and
    249  * trailing white space removed.
    250  *
    251  * Parameters:
    252  * char *input_stringp - the line to remove all coments and trailing white
    253  *	space.
    254  *
    255  * Note: The memory allocated for the returned string must be freed by the
    256  * caller of fileutil_get_cmd_from_string().
    257  */
    258 char	*fileutil_get_cmd_from_string(char *input_stringp);
    259 
    260 /*
    261  * Method: fileutil_get_first_column_data
    262  *
    263  * Description: Returns a string array which is filled with the data in the
    264  * first column of the lines in a table formatted file.
    265  * Examples of table formatted files include: /etc/netcofig, /etc/nfssec.conf
    266  *
    267  * Parameters:
    268  * FILE* - The file pointer of the table formatted file to get data from.
    269  * int* - will be filled with the number of elements in the array that is passed
    270  *	back.
    271  * int* - error pointer.  If an error occurs this will be non-zero upon return
    272  * 	the function.
    273  *
    274  * Returns:
    275  * Two-dimensional array of characters (string array).  Each element in the
    276  * array is the first column data of each row in the table.
    277  */
    278 char	**fileutil_get_first_column_data(FILE *, int *, int *);
    279 
    280 /*
    281  * Method: fileutil_getfs
    282  *
    283  * Description: Convenience function for retrieving the default remote file
    284  * system type from /etc/dfs/fstypes.
    285  *
    286  * Parameters:
    287  * FILE * - The /etc/dfs/fstypes file pointer.
    288  *
    289  * Return:
    290  * The default remote filesystem type.
    291  */
    292 char	*fileutil_getfs(FILE *);
    293 
    294 /*
    295  * Method: fileutil_getline
    296  *
    297  * Description: Convenience function for retrieving the next line from a file.
    298  *              Commented lines are not returned and comments at the end of
    299  *              a line are removed.
    300  *
    301  * Parameters:
    302  * FILE * - The file pointer to a file that has been opened for reading.
    303  * char * - The line retrived from the file will be placed in this string.
    304  * int * - error pointer - If an error occurs this will be non-zero upon
    305  *                         return from the function.
    306  *
    307  * Return:
    308  * If successfull the line retrieved from the file will be returned.
    309  * Otherwise NULL be be returned.
    310  */
    311 char	*fileutil_getline(FILE *, char *, int);
    312 
    313 /*
    314  * Mount defaults (/etc/vfstab) interface method declarations
    315  */
    316 /*
    317  * Method: fs_add_mount_default
    318  *
    319  * Description: Adds an entry to vfstab based on the fs_mntdefaults_t
    320  *              structure that is passed in.
    321  *
    322  * Parameters:
    323  * fs_mntdefaults_t *newp - The structure containing the mount information
    324  *                          to be placed in vfstab.
    325  * int *errp - error pointer - If an error occurs this will be non-zero upon
    326  *                             return from the function.
    327  *
    328  * Return:
    329  * If successful a pointer to a list containing all the present vfstab
    330  * entries is returned. On failure NULL is returned.
    331  */
    332 fs_mntdefaults_t	*fs_add_mount_default(fs_mntdefaults_t *, int *);
    333 
    334 /*
    335  * Method: fs_check_for_duplicate_DFStab_paths
    336  *
    337  * Description: Checks dfstab for duplicate paths and returns the number of
    338  * times the path passed in was encountered. The functon is used to help make
    339  * sure a path is only listed in dfstab once.
    340  *
    341  * Parameters:
    342  * char *path - the path to check for
    343  * int *err - error pointer - If an error occurs this will be non-zero upon
    344  *	return from the function.
    345  *
    346  * Return:
    347  * The number of times the specified path is encountered in dfstab.
    348  */
    349 int fs_check_for_duplicate_DFStab_paths(char *path, int *err);
    350 
    351 /*
    352  * Method: fs_del_mount_default_ent
    353  *
    354  * Description: Deletes the specified vfstab entry from the vfstab file.
    355  *
    356  * Parameters:
    357  * fs_mntdefaults_t *old_vfstab_ent - The mount information that corresponds
    358  *                                    to the vfstab entry to be deleted.
    359  * int *errp - error pointer - If an error occurs this will be non-zero upon
    360  *                             return from the function.
    361  *
    362  * Return:
    363  * If successful a pointer to a list containing all the changed vfstab
    364  * entries is returned. On failure NULL is returned.
    365  */
    366 fs_mntdefaults_t	*fs_del_mount_default_ent(fs_mntdefaults_t *, int *);
    367 
    368 /*
    369  * Method: fs_edit_mount_defaults
    370  *
    371  * Description: Edits the specified vfstab entry with the new mount
    372  * information passed in.
    373  *
    374  * Parameters:
    375  * fs_mntdefaults_t *old_vfstab_ent - The old vfstab entry that is to be edited.
    376  * fs_mntdefaults_t *new_vfstab_ent - The new vfstab entry information.
    377  * int *errp - error pointer - If an error occurs this will be non-zero upon
    378  *                             return from the function
    379  *
    380  * Return:
    381  */
    382 fs_mntdefaults_t	*fs_edit_mount_defaults(fs_mntdefaults_t *,
    383 				fs_mntdefaults_t *, int *);
    384 
    385 /*
    386  * Method: fs_free_mntdefaults_list
    387  *
    388  * Description: Frees the memory used when a fs_mntdefaults_t structure
    389  *              is populated.
    390  *
    391  * Parameters:
    392  * fs_mntdefaults_t *headp - The pointer to the first element in the list
    393  *                           of mntdefault structures.
    394  */
    395 void	fs_free_mntdefaults_list(fs_mntdefaults_t *headp);
    396 
    397 
    398 /*
    399  * Method: fs_get_filtered_mount_defaults
    400  *
    401  * Description: Retrieves vfstab entries based in the fields in the
    402  * fs_mntdefaults_t structure passed in. The fields that are not to
    403  * be used in the filter will be set to NULL.
    404  *
    405  * Parameters:
    406  * fs_mntdefaults_t *filter - The structure containing the fields to be
    407  *                            used for the filter.
    408  * int *errp - error pointer - If an error occurs this will be non-zero upon
    409  *                             return from the function
    410  *
    411  * Return:
    412  * The list of all vfstab entries meeting the filter criteria are returned.
    413  * On failure NULL is returned.
    414  */
    415 fs_mntdefaults_t	*fs_get_filtered_mount_defaults(
    416 				fs_mntdefaults_t *filter, int *errp);
    417 
    418 /*
    419  * Method: fs_get_mount_defaults
    420  *
    421  * Description: Retrieves vfstab entries and returns a list of
    422  *              fs_mntdefaults_t structures.
    423  *
    424  * Parameters:
    425  * int *errp - error pointer - If an error occurs this will be non-zero upon
    426  *                             return from the function
    427  *
    428  * Return:
    429  * fs_mntdefaults_t * - Returns a list of all vfstab entries.
    430  */
    431 fs_mntdefaults_t	*fs_get_mount_defaults(int *errp);
    432 
    433 /*
    434  * Mount (/etc/mnttab) interface method declarations
    435  */
    436 /*
    437  * Method: fs_free_mount_list
    438  *
    439  * Description: Frees the mount list created when retrieving mnttab entries.
    440  *
    441  * Parameters:
    442  * fs_mntlist_t *headp - The mount list to be freed.
    443  */
    444 void	fs_free_mount_list(fs_mntlist_t *mnt_list);
    445 
    446 /*
    447  * Method: fs_get_availablesize
    448  *
    449  * Description: Calculates the total size available on the filesystem.
    450  *
    451  * Parameters:
    452  * char *mntpnt - The mount point to use for gathering the stat information
    453  * int *errp - error pointer - If an error occurs this will be non-zero upon
    454  *                             return from the function
    455  *
    456  * Return:
    457  * The total size available on the filesystem.
    458  */
    459 unsigned long long	fs_get_availablesize(char *mntpnt, int *errp);
    460 
    461 /*
    462  * Method: fs_get_avail_for_nonsuperuser_size
    463  *
    464  * Description: Calculates the available space on the filesystem for
    465  *              nonsuperusers.
    466  *
    467  * Parameters:
    468  * char *mntpnt - The mount point for the filesystem.
    469  * int *errp - error pointer - If an error occurs this will be non-zero upon
    470  *                             return from the function
    471  *
    472  * Return:
    473  * The available space for nonsuperusers.
    474  * On failure NULL is returned.
    475  */
    476 unsigned long long	fs_get_avail_for_nonsuperuser_size(char *mntpnt,
    477 				int *errp);
    478 
    479 /*
    480  * Method: fs_get_blocksize
    481  *
    482  * Description: Retrieves the preferred filesystem block size.
    483  *
    484  * Parameters:
    485  * char *mntpnt - The mount point for the filesystem.
    486  * int *errp - error pointer - If an error occurs this will be non-zero upon
    487  *                             return from the function
    488  *
    489  * Return:
    490  * Returns the preferred filesystem block size.
    491  * On failure NULL is returned.
    492  */
    493 
    494 unsigned long long	fs_get_blocksize(char *mntpnt, int *errp);
    495 
    496 /*
    497  * Method: fs_get_filtered_mount_list
    498  *
    499  * Description: Can be used to filter mounts only by the following mount
    500  * attributes or a mixture of them:
    501  * 1.) resource
    502  * 2.) mount point
    503  * 3.) mount option string
    504  * 4.) time mounted
    505  *
    506  * Parameters:
    507  * char *resource - The name of the resource to be mounted
    508  * char *mountp - The pathname of the directory on which the filesystem
    509  *                is mounted
    510  * char *mntopts - The mount options
    511  * char *time - The time at which the filesystem was mounted
    512  * boolean_t find_overlays - Flag used to turn on overlay checking
    513  * int *errp - error pointer - If an error occurs this will be non-zero upon
    514  *                             return from the function
    515  *
    516  * Return:
    517  * The list of all mnttab entries meeting the filter criteria are returned.
    518  * On failure NULL is returned.
    519  */
    520 fs_mntlist_t		*fs_get_filtered_mount_list(char *resource,
    521 				char *mountp, char *fstype, char *mntopts,
    522 				char *time, boolean_t find_overlays,
    523 				int *errp);
    524 
    525 /*
    526  * Method: fs_get_fragsize
    527  *
    528  * Description: Determines the fundamental filesystem block size.
    529  *
    530  * Parameters:
    531  * char *mntpnt - The mount point for the filesystem.
    532  * int *errp - error pointer - If an error occurs this will be non-zero upon
    533  *                             return from the function
    534  *
    535  * Return:
    536  * Returns the fundamental filesystem block size.
    537  * On failure NULL is returned.
    538  */
    539 unsigned long		fs_get_fragsize(char *mntpnt, int *errp);
    540 
    541 /*
    542  * Method: fs_get_maxfilenamelen
    543  *
    544  * Description: Determines the maximum file name length for the filesystem.
    545  *
    546  * Parameters:
    547  * char *mntpnt - The mount point for the filesystem.
    548  * int *errp - error pointer - If an error occurs this will be non-zero upon
    549  *                             return from the function
    550  *
    551  * Return:
    552  * Returns the  maximum file name length for the specified filesystem.
    553  * On failure NULL is returned.
    554  */
    555 unsigned long		fs_get_maxfilenamelen(char *mntpnt, int *errp);
    556 
    557 /*
    558  * Method: fs_get_mounts_by_mntopt
    559  *
    560  * Description: Returns only mounts with the specified mount option set.
    561  *
    562  * Parameters:
    563  * char *mntopt - The mount option used for filtering mounts
    564  * boolean_t find_overlays - Flag used to turn on overlay checking
    565  * int *errp - error pointer - If an error occurs this will be non-zero upon
    566  *                             return from the function
    567  *
    568  * Return:
    569  * Returns the list of all mnttab entries with the matching mount option.
    570  * On failure NULL is returned.
    571  */
    572 fs_mntlist_t		*fs_get_mounts_by_mntopt(char *mntopt,
    573 				boolean_t find_overlays, int *errp);
    574 
    575 /*
    576  * Method: fs_get_mount_list
    577  *
    578  * Description: Returns a list of all mounts in mnttab
    579  *
    580  * Parameters:
    581  * char *mntpnt - The mount point for the filesystem
    582  * boolean_t find_overlays - Flag used to turn on overlay checking
    583  * int *errp - error pointer - If an error occurs this will be non-zero upon
    584  *                             return from the function
    585  *
    586  * Return:
    587  * Returns the list of all mounts and associated mount information for mounts
    588  * listed in mnttab. On failure NULL is returned.
    589  */
    590 fs_mntlist_t		*fs_get_mount_list(boolean_t find_overlays, int *errp);
    591 
    592 /*
    593  * Method: fs_get_totalsize
    594  *
    595  * Description: Determines the total size of the filesystem using the
    596  * total number of blocks and the block size.
    597  *
    598  * Parameters:
    599  * char *mntpnt - The mount point for the filesystem
    600  * int *errp - error pointer - If an error occurs this will be non-zero upon
    601  *                             return from the function
    602  *
    603  * Return:
    604  * Returns the total size of the filesystem.
    605  * On failure NULL is returned.
    606  */
    607 unsigned long long	fs_get_totalsize(char *mntpnt, int *errp);
    608 
    609 /*
    610  * Method: fs_get_usedsize
    611  *
    612  * Description: Calculates the size of the used portion of the filesystem.
    613  *
    614  * Parameters:
    615  * char *mntpnt - The mount point for the filesystem
    616  * int *errp - error pointer - If an error occurs this will be non-zero upon
    617  *                             return from the function
    618  *
    619  * Return:
    620  * Returns the size of the the used portion of the filesystem.
    621  * On failure NULL is returned.
    622  */
    623 unsigned long long	fs_get_usedsize(char *mntpnt, int *errp);
    624 
    625 /*
    626  * Method: fs_is_readonly
    627  *
    628  * Description: Checks the filesystem flags to see if the filesystem is
    629  * readonly.
    630  *
    631  * Parameters:
    632  * char *mntpnt - The mount point for the filesystem
    633  * int *errp - error pointer - If an error occurs this will be non-zero upon
    634  *                             return from the function
    635  *
    636  * Return:
    637  * Returns B_TRUE if the readonly flag is set and B_FALSE if not.
    638  * On error the error pointer is set to errno.
    639  */
    640 boolean_t		fs_is_readonly(char *mntpnt, int *errp);
    641 
    642 /*
    643  * Method: fs_parse_optlist_for_option
    644  *
    645  * Description:
    646  * This method will parse the given comma delimited option list (optlist) for
    647  * the option passed into the function.  If the option (opt) to search for
    648  * is one that sets a value such as onerror=, the value to the right of the "="
    649  * character will be returned from the function.  This function expects the
    650  * opt parameter to have the "=" character appended when searching for options
    651  * which set a value.
    652  *
    653  * Parameters:
    654  * char *optlist - The option string to be parsed
    655  * char *opt - The option to search for
    656  * int *errp - error pointer - If an error occurs this will be non-zero upon
    657  *                             return from the function
    658  *
    659  * Return:
    660  * Returns the option as found in the option list.
    661  * If the option is not found NULL is returned.
    662  * On error NULL is returned and the error pointer is set to errno.
    663  */
    664 char			*fs_parse_optlist_for_option(char *optlist, char *opt,
    665 				int *errp);
    666 
    667 /*
    668  * Share (/etc/dfs/sharetab) interface method declarations
    669  */
    670 /*
    671  * Method: fs_free_share_list
    672  *
    673  * Description: Used to free populated fs_sharelist_t structures
    674  *
    675  * Parameters:
    676  * fs_sharelist_t *headp - the pointer to the first element in the list.
    677  */
    678 void		fs_free_share_list(fs_sharelist_t *share_list);
    679 
    680 /*
    681  * Method: fs_get_share_list
    682  *
    683  * Description: Gets a list of the shares on the system from /etc/dfs/sharetab
    684  *
    685  * Parameters:
    686  * int *errp - error pointer - If an error occurs this will be non-zero upon
    687  *                             return from the function
    688  *
    689  * Return:
    690  * Returns a list of fs_sharelist_t structures containing all of the shares
    691  * from sharetab.
    692  * On error NULL is returned and errp is set to errno.
    693  */
    694 fs_sharelist_t	*fs_get_share_list(int *errp);
    695 
    696 /*
    697  * Method: fs_parse_opts_for_sec_modes
    698  *
    699  * Description: Parses the option string for security modes and returns
    700  * an array of strings containing all modes.
    701  *
    702  * Parameters:
    703  * 	char * - options string to be parsed.
    704  * 	int * - count of the number of modes found.
    705  *	int * - error code.
    706  *
    707  * Return:
    708  * Returns an array of string containing all security opts listed in the
    709  * passed in option string. On error NULL is returned.
    710  */
    711 char **fs_parse_opts_for_sec_modes(char *, int *, int *);
    712 
    713 /*
    714  * Method: fs_create_array_from_accesslist
    715  *
    716  * Description: Takes the colon seperated access list parses the list
    717  *              into an array containing all the elements of the list.
    718  *              The array created is returned and count is set to the
    719  *              number of elements in the array.
    720  *
    721  * Parameters:
    722  * char *access_list - The string containing the colon sperated access list.
    723  * int *count - Will contain the number of elements in the array.
    724  * int *err - any errors encountered.
    725  */
    726 char **fs_create_array_from_accesslist(char *access_list, int *count, int *err);
    727 
    728 /*
    729  * FS dfstab (/etc/dfs/dfstab) interface method declarations
    730  */
    731 
    732 /*
    733  * Method: fs_add_DFStab_ent
    734  *
    735  * Description: Adds an entry to dfstab and to the list of dfstab
    736  * entries. Returns a pointer to the head of the dfstab entry list.
    737  *
    738  * Parameters:
    739  * char *cmd - the share command to be added to dfstab
    740  * int *errp - error pointer - If an error occurs this will be non-zero upon
    741  *                             return from the function
    742  *
    743  * Return:
    744  * Returns the pointer to the updated dfstab entry list.
    745  */
    746 fs_dfstab_entry_t fs_add_DFStab_ent(char *, int *);
    747 
    748 /*
    749  * Method: fs_del_DFStab_ent
    750  *
    751  * Description: Deletes an entry from dfstab and from the list of
    752  *              dfstab entries.
    753  *
    754  * Parameters:
    755  * char *del_cmd - The share command to be removed
    756  * int *errp - error pointer - If an error occurs this will be non-zero upon
    757  *                             return from the function
    758  *
    759  * Return:
    760  * Returns the pointer to the updated dfstab entry list.
    761  */
    762 fs_dfstab_entry_t fs_del_DFStab_ent(char *, int *);
    763 
    764 /*
    765  * NOTE: the caller of this function is responsible for freeing any
    766  * memory allocated by calling fs_free_DFStab_ents()
    767  *
    768  * Method: fs_edit_DFStab_ent
    769  *
    770  * Description: Changes the specified line in dfstab to match the second
    771  *              string passed in.
    772  *
    773  * Parameters:
    774  * char *old_cmd - The share command that will be changed.
    775  * char *new_cmd - The share command that will replace old_cmd.
    776  * int *errp - error pointer - If an error occurs this will be non-zero upon
    777  *                             return from the function
    778  *
    779  * Return:
    780  * Returns the pointer to the updated dfstab entry list.
    781  */
    782 fs_dfstab_entry_t fs_edit_DFStab_ent(char *, char *, int *);
    783 
    784 /*
    785  * Method: fs_free_DFStab_ents
    786  *
    787  * Description: Frees the dfstab entry list.
    788  *
    789  * Parameters:
    790  * fs_dfstab_entry_t list - The pointer to the dfstab entry list.
    791  */
    792 void fs_free_DFStab_ents(fs_dfstab_entry_t);
    793 
    794 /*
    795  * NOTE: the caller of this function is responsible for freeing any
    796  * memory allocated by calling fs_free_DFStab_ents()
    797  *
    798  * Method: fs_get_DFStab_ents
    799  *
    800  * Description: Retrieves the dfstab entry list.
    801  *
    802  * Parameters:
    803  * int *errp - error pointer - If an error occurs this will be non-zero upon
    804  *                             return from the function
    805  *
    806  * Return:
    807  * Returns the pointer to the dfstab entry list.
    808  * If NULL is returned and errp is 0 then dfstab has no entries. If errp is
    809  * not 0 there was an error and the value of errp is set to the errno
    810  * value for that error.
    811  */
    812 fs_dfstab_entry_t fs_get_DFStab_ents(int *err);
    813 
    814 /*
    815  * NOTE: the caller of this function is responsible for freeing any
    816  * memory allocated by calling fs_free_DFStab_ents()
    817  *
    818  * Method: fs_get_DFStab_ent_Desc
    819  *
    820  * Description: Retrieves the description information for the present
    821  *              dfstab entry.
    822  *
    823  * Parameters:
    824  * fs_dfstab_entry_t entry - the dfstab entry to retrieve the description from.
    825  *
    826  * Return:
    827  * The string containing the description for the dfstab entry.
    828  * If the description is not set NULL is returned.
    829  *
    830  * Note: the description is an optional share option and a return value of
    831  *       NULL is not an error but indicates that the description was not set.
    832  */
    833 char *fs_get_DFStab_ent_Desc(fs_dfstab_entry_t);
    834 
    835 /*
    836  * Method: fs_get_DFStab_ent_Fstype
    837  *
    838  * Description: Retrieves the filesystem type information from the dfstab
    839  *              entry passed in.
    840  *
    841  * Parameters:
    842  * fs_dfstab_entry_t entry - the dfstab entry to retrieve the fstype from.
    843  *
    844  * Return:
    845  * The string containing the filesystem type.
    846  *
    847  * Note: if fstype is not set in the dfstab entry the default fstype is
    848  *       returned.
    849  */
    850 char *fs_get_DFStab_ent_Fstype(fs_dfstab_entry_t);
    851 
    852 /*
    853  * Method: fs_get_DFStab_ent_Next
    854  *
    855  * Description: Retrieves the next entry in the dfstab entry list.
    856  *
    857  * Parameters:
    858  * fs_dfstab_entry_t entry - The dfstab entry pointer to get the next
    859  *                           pointer from.
    860  *
    861  * Return:
    862  * Returns the next dfstab entry.
    863  * A return value of NULL indicates the end of the dfstab entry list.
    864  */
    865 fs_dfstab_entry_t fs_get_DFStab_ent_Next(fs_dfstab_entry_t);
    866 
    867 /*
    868  * Method: fs_get_DFStab_ent_Options
    869  *
    870  * Description: Retrieves the share options from the dfstab
    871  *              entry passed in.
    872  *
    873  * Parameters:
    874  * fs_dfstab_entry_t entry - The dfstab entry to retrieve the share
    875  *                           options from.
    876  *
    877  * Return:
    878  * Returns the string containing the share options.
    879  * A NULL value indicates that no options were specified in the dfstab entry.
    880  */
    881 char *fs_get_DFStab_ent_Options(fs_dfstab_entry_t);
    882 
    883 /*
    884  * Method: fs_get_DFStab_ent_Path
    885  *
    886  * Description: Retrieves the path information from the dfstab
    887  *              entry passed in.
    888  *
    889  * Parameters:
    890  * fs_dfstab_entry_t entry - the dfstab entry to retrieve the path from.
    891  *
    892  * Return:
    893  * Returns the string containing the path.
    894  * A NULL value indecates that no path information is available for the
    895  * dfstab entry. A NULL value here is an error and indicates an invalid
    896  * dfstab entry.
    897  */
    898 char *fs_get_DFStab_ent_Path(fs_dfstab_entry_t);
    899 
    900 /*
    901  * Method: fs_get_DFStab_ent_Res
    902  *
    903  * Description: Retrieves the resource information from the dfstab entry
    904  *              passed in.
    905  *
    906  * Parameters:
    907  * fs_dfstab_entry_t entry - the dfstab entry to retrieve the resource
    908  *                           information from.
    909  *
    910  * Return:
    911  * Returns the string containing the path.
    912  * A NULL value indecates that no resource information is available for the
    913  * dfstab entry.
    914  */
    915 char *fs_get_DFStab_ent_Res(fs_dfstab_entry_t);
    916 
    917 /*
    918  * Method: fs_get_Dfstab_share_cmd
    919  *
    920  * Description: Retrieves the share command that corresponds to the
    921  *              dfstab entry passed in.
    922  *
    923  * Parameters:
    924  * fs_dfstab_entry_t entry - The dfstab entry that will be used to create
    925  *                           a share command.
    926  * int *errp - error pointer - If an error occurs this will be non-zero upon
    927  *                             return from the function
    928  *
    929  * Return:
    930  * Returns the string containing the share command.
    931  * A NULL value indicates an error occured and errp will be non zero.
    932  */
    933 char *fs_get_Dfstab_share_cmd(fs_dfstab_entry_t, int *);
    934 
    935 /*
    936  * NOTE: the caller of this function is responsible for freeing any
    937  * memory allocated by calling fs_free_DFStab_ents()
    938  *
    939  * Method: fs_set_DFStab_ent
    940  *
    941  * Description: Used to add entries into dfstab
    942  *
    943  * Parameters:
    944  * char *path - The path for the dfstab entry
    945  * char *fstype - The filesystem type for the share
    946  * char *options - The share options to be used for the dfstab entry
    947  * char *description - The description for the share
    948  * int *errp - error pointer - If an error occurs this will be non-zero upon
    949  *                             return from the function
    950  *
    951  * Return:
    952  * Returns a pointer to the begining of the dfstab entry list
    953  * Failure returns NULL
    954  */
    955 fs_dfstab_entry_t fs_set_DFStab_ent(char *, char *, char *, char *, int *);
    956 
    957 /*
    958  * NOTE: the caller of this function is responsible for freeing any
    959  * memory allocated by calling fs_free_DFStab_ents()
    960  *
    961  * Method: fs_del_All_DFStab_ents_with_Path
    962  *
    963  * Description: Removes all dfstab entries with the specified path.
    964  *
    965  * Parameters:
    966  *            char *path - The path to checked for removal from dfstab.
    967  *            int *err - error pointer.
    968  *
    969  * Return: returns a pointer to the nfs list of dfstab entries.
    970  */
    971 fs_dfstab_entry_t fs_del_All_DFStab_ents_with_Path(char *, int *);
    972 
    973 /*
    974  * Debuging functions
    975  */
    976 void fs_print_dfstab_entries(fs_dfstab_entry_t);
    977 
    978 /*
    979  * NFS mount interface method declarations
    980  */
    981 /*
    982  * Method: nfs_free_mntinfo_list
    983  *
    984  * Description: Used to free the network id list, which is an array of strings.
    985  *
    986  * Parameters:
    987  * nfs_mntlist_t *mountinfo_list - The list of mounts and associated mount
    988  *                                 information
    989  *
    990  */
    991 void nfs_free_mntinfo_list(nfs_mntlist_t *);
    992 
    993 /*
    994  * NOTE: the caller of this function is responsible for freeing any
    995  * memory allocated by calling nfs_free_mntinfo_list()
    996  *
    997  * Method: nfs_get_filtered_mount_list
    998  *
    999  * Description: Can be used to filter nfs mounts only by the following mount
   1000  * attributes or a mixture of them:
   1001  * 1.) resource
   1002  * 2.) mount point
   1003  * 3.) mount option string
   1004  * 4.) time mounted
   1005  *
   1006  * NULL must be passed into the options that are not being used in the filter.
   1007  *
   1008  * Parameters:
   1009  * char *resource - The name of the resource to be mounted
   1010  * char *mountp - The pathname of the directory on which the filesystem
   1011  *                is mounted
   1012  * char *mntopts - The mount options
   1013  * char *time - The time at which the filesystem was mounted
   1014  * boolean_t find_overlays - Flag used to turn on overlay checking
   1015  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1016  *                             return from the function
   1017  *
   1018  * Return:
   1019  * nfs_mntlist_t * - Returns a list of nfs mounts based on the
   1020  *                   parameters passed in.
   1021  */
   1022 nfs_mntlist_t *nfs_get_filtered_mount_list(char *resource, char *mountp,
   1023 	char *mntopts, char *time, boolean_t find_overlays,
   1024 	int *errp);
   1025 
   1026 /*
   1027  * NOTE: the caller of this function is responsible for freeing any
   1028  * memory allocated by calling nfs_free_mntinfo_list()
   1029  *
   1030  * Method: nfs_get_mounts_by_mntopt
   1031  *
   1032  * Description: Can be used to filter mounts by the mount options attribute.
   1033  *
   1034  * Parameters:
   1035  * char *mntopts - The mount options
   1036  * boolean_t find_overlays - Flag used to turn on overlay checking
   1037  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1038  *                             return from the function
   1039  *
   1040  * Return:
   1041  * nfs_mntlist_t * - Returns a list of nfs mounts based on the
   1042  *                   parameters passed in.
   1043  */
   1044 nfs_mntlist_t *nfs_get_mounts_by_mntopt(char *mntopt, boolean_t find_overlays,
   1045 	int *errp);
   1046 
   1047 /*
   1048  * NOTE: the caller of this function is responsible for freeing any
   1049  * memory allocated by calling nfs_free_mntinfo_list()
   1050  *
   1051  * Method: nfs_get_mount_list
   1052  *
   1053  * Description: Used to gather all NFS mounts and there associated
   1054  *              mount information.
   1055  *
   1056  * Parameters:
   1057  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1058  *                             return from the function
   1059  *
   1060  * Return:
   1061  * nfs_mntlist_t * - Returns a list of all nfs mounts.
   1062  */
   1063 nfs_mntlist_t *nfs_get_mount_list(int *);
   1064 
   1065 /*
   1066  * Netconfig (/etc/netconfig) interface method declarations
   1067  */
   1068 /*
   1069  * Method: netcfg_free_networkid_list
   1070  *
   1071  * Description: Used to free the network id list, which is an array of strings.
   1072  *
   1073  * Parameters:
   1074  * char **netlist - The array of strings containing the network id list
   1075  * int  num_elements - The number of elements in the network id list
   1076  *
   1077  */
   1078 void	netcfg_free_networkid_list(char **netlist, int num_elements);
   1079 
   1080 /*
   1081  * NOTE: the caller of this function is responsible for freeing any
   1082  * memory allocated by calling netcfg_free_networkid_list()
   1083  *
   1084  * Method: netcfg_get_networkid_list
   1085  *
   1086  * Description: Used to create the network id list.
   1087  *
   1088  * Parameters:
   1089  * int *num_elements - The number of elements in the network id list.
   1090  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1091  *                             return from the function
   1092  *
   1093  * Return:
   1094  * char    ** - Returns the netowk id list.
   1095  */
   1096 char	**netcfg_get_networkid_list(int *num_elements, int *errp);
   1097 
   1098 /*
   1099  * nfssec (/etc/nfssec.conf) interface method declarations
   1100  */
   1101 /*
   1102  * Method: nfssec_free_secmode_list
   1103  *
   1104  * Description: Used to free the NFS security mode list.
   1105  *
   1106  * Parameters:
   1107  * char **seclist - The array of strings containing the security mode list
   1108  * int num_elements - The number of elements in the list
   1109  *
   1110  */
   1111 void	nfssec_free_secmode_list(char **seclist, int num_elements);
   1112 
   1113 /*
   1114  * Method: nfssec_get_default_secmode
   1115  *
   1116  * Description: Used to retrieve the default security mode
   1117  *
   1118  * Parameters:
   1119  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1120  *                             return from the function
   1121  *
   1122  * Return:
   1123  * char * - Returns the name of the default security mode
   1124  */
   1125 char	*nfssec_get_default_secmode(int *errp);
   1126 
   1127 /*
   1128  * NOTE: the caller of this function is responsible for freeing any
   1129  * memory allocated by calling nfssec_free_secmode_list()
   1130  *
   1131  * Method: nfssec_get_nfs_secmode_list
   1132  *
   1133  * Description: Used to create the NFS security mode list.
   1134  *
   1135  * Parameters:
   1136  * int *num_elements - The number of elements in the security mode list
   1137  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1138  *                             return from the function
   1139  *
   1140  * Return:
   1141  * char ** - Returns the NFS security mode list
   1142  *
   1143  */
   1144 char	**nfssec_get_nfs_secmode_list(int *num_elements, int *errp);
   1145 
   1146 /*
   1147  * System information interface method declarations
   1148  */
   1149 /*
   1150  * Method: sys_get_hostname
   1151  *
   1152  * Description: Used to retrieve the name of the host
   1153  *
   1154  * Parameters:
   1155  * int *errp - error pointer - If an error occurs this will be non-zero upon
   1156  *                             return from the function
   1157  *
   1158  * Return:
   1159  * char * - Returns the name of the host system
   1160  */
   1161 char *sys_get_hostname(int *errp);
   1162 
   1163 
   1164 #ifdef __cplusplus
   1165 }
   1166 #endif
   1167 
   1168 #endif /* _LIBFSMGT_H */
   1169