2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBFSMGT_H
2N/A#define _LIBFSMGT_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <stdio.h>
2N/A#include <sys/param.h>
2N/A#include <nfs/nfs_sec.h>
2N/A#include <sys/utsname.h>
2N/A
2N/A#define DFSTYPES "/etc/dfs/fstypes" /* dfs list */
2N/A#define DFSTAB "/etc/dfs/dfstab" /* dfs list */
2N/A#define BUFSIZE 65536
2N/A#define LINESZ 2048
2N/A
2N/Atypedef void *fs_dfstab_entry_t;
2N/A
2N/A/*
2N/A * Public data type declarations
2N/A */
2N/A
2N/A/*
2N/A * Represents a list of the /etc/vfstab entries
2N/A */
2N/Atypedef struct mount_default_list {
2N/A struct mount_default_list *next;
2N/A char *resource;
2N/A char *fsckdevice;
2N/A char *mountp;
2N/A char *fstype;
2N/A char *fsckpass;
2N/A char *mountatboot;
2N/A char *mntopts;
2N/A} fs_mntdefaults_t;
2N/A
2N/A/*
2N/A * Represents a list of /etc/mnttab entries
2N/A */
2N/Atypedef struct mount_list {
2N/A struct mount_list *next;
2N/A char *resource;
2N/A char *mountp;
2N/A char *fstype;
2N/A char *mntopts;
2N/A char *time;
2N/A uint_t major;
2N/A uint_t minor;
2N/A boolean_t overlayed;
2N/A} fs_mntlist_t;
2N/A
2N/A/*
2N/A * Represents a /etc/dfs/sharetab entry
2N/A */
2N/Atypedef struct share_list {
2N/A struct share_list *next;
2N/A char *path;
2N/A char *resource;
2N/A char *fstype;
2N/A char *options;
2N/A char *description;
2N/A} fs_sharelist_t;
2N/A
2N/A/*
2N/A * Represents a list of /etc/mnttab entries with associated
2N/A * information from kstat.
2N/A */
2N/Atypedef struct nfs_mntlist {
2N/A struct nfs_mntlist *next;
2N/A char nml_curpath[MAXPATHLEN]; /* current path on */
2N/A /* server */
2N/A char nml_curserver[SYS_NMLN]; /* current server */
2N/A char **nml_failoverlist; /* The list of servers */
2N/A /* and corresponding */
2N/A /* paths for failover. */
2N/A char *nml_fstype; /* filesystem type */
2N/A char *nml_mntopts; /* mount options */
2N/A char *nml_mountp; /* mount point */
2N/A char *nml_resource; /* mnttab.mnt_special */
2N/A char nml_proto[KNC_STRSIZE]; /* transfer protocol */
2N/A char *nml_securitymode; /* security mode name */
2N/A char *nml_time; /* time mounted */
2N/A int nml_failovercount; /* number of failover servers */
2N/A int nml_retrans; /* times to retry request */
2N/A int nml_timeo; /* inital timeout in 10th sec */
2N/A ulong_t nml_fsid; /* filesystem ID */
2N/A uint_t nml_acdirmax; /* max time to hold cached dir attr */
2N/A uint_t nml_acdirmin; /* min time to hold cached dir attr */
2N/A uint_t nml_acregmax; /* max time to hold cached file attr */
2N/A uint_t nml_acregmin; /* min time to hold cached file attr */
2N/A uint32_t nml_curread; /* current read size */
2N/A uint32_t nml_curwrite; /* current write size */
2N/A uint32_t nml_vers; /* nfs version */
2N/A boolean_t nml_directio; /* force direct IO */
2N/A boolean_t nml_grpid; /* group id inherited from parent */
2N/A boolean_t nml_hard; /* hard or soft mount */
2N/A boolean_t nml_intr; /* Key board intrupts */
2N/A boolean_t nml_noac; /* no ata and attribute caching */
2N/A boolean_t nml_nocto; /* no close-to-open consistency */
2N/A boolean_t nml_overlayed; /* Is filesystem overlayed */
2N/A boolean_t nml_xattr; /* allow extended attributes */
2N/A} nfs_mntlist_t;
2N/A
2N/A/*
2N/A * Command execution interface method declarations
2N/A */
2N/A
2N/A/*
2N/A * Method: cmd_execute_command
2N/A *
2N/A * Description: Executes the command passed into the function as if it was
2N/A * the input to a shell and returns the separated stdout and stderr messages
2N/A * which can be accessed by the client via the returned file descriptors using
2N/A * the cmd_retrieve_string method or one of their own methods.
2N/A *
2N/A * Parameters:
2N/A * char * - The command to execute. Expected in the format of a shell command.
2N/A * int * - Upon return from the function, this is the file descriptor that can
2N/A * be used to access the output from the command to stdout.
2N/A * int * - Upon return from the function, this is the file descriptor that can
2N/A * be used to access the output from the command to stderr.
2N/A *
2N/A * Return:
2N/A * Returns 0 (zero).
2N/A * Supposed to be the integer representing the exit value of the command
2N/A * executed, but due to the way blocking on file descriptors works, it will
2N/A * only return a 0 (zero) value. The reason: The producer, in this case the
2N/A * command being executed, will block when a certain amount of data is written
2N/A * to the file descriptor and will not be able to write any more data until the
2N/A * consumer reads from the file descriptor so since we are not reading in the
2N/A * data from the file descriptors in this method and we are allowing the client
2N/A * do what they want with the data we can't wait until the command is finished
2N/A * executing to get the return value.
2N/A */
2N/Aint cmd_execute_command(char *cmd, int *output_filedes, int *error_filedes);
2N/A
2N/A/*
2N/A * Method: cmd_execute_command_and_retrieve_string
2N/A *
2N/A * Description: Executes the command passed into the function as if it was the
2N/A * input to a shell and returns the output to stderr and stdout as a string as
2N/A * it would appear in the shell (stdout and stderr are mixed).
2N/A *
2N/A * Parameters:
2N/A * char * - The command to execute. Expected in the format of a shell command.
2N/A * int * - Upon return from the function, this should be used to determine if an
2N/A * error occurred in the execution of the command and the retrieval of
2N/A * output data from the command.
2N/A * data from the command.
2N/A *
2N/A * Return:
2N/A * The output to stdout and stderr created by the execution of the passed in
2N/A * command.
2N/A */
2N/Achar *cmd_execute_command_and_retrieve_string(char *cmd, int *errp);
2N/A
2N/A/*
2N/A * Method: cmd_retrieve_string
2N/A *
2N/A * Description: Retrieves the data from the passed in file descriptor and
2N/A * returns it to the caller in the form of a string.
2N/A *
2N/A * Parameters:
2N/A * int - The file descriptor to be read from.
2N/A * int * - Upon return from the function, this should be the used to determine
2N/A * if an error occurred in the retrieval of the data from the file
2N/A * descriptor.
2N/A * A non-zero value represents the occurrence of an error.
2N/A *
2N/A * Return:
2N/A * The data from the file descriptor in the form of a string.
2N/A * NOTE: The caller must free the space allocated (with calloc) for the return
2N/A * value using free().
2N/A */
2N/Achar *cmd_retrieve_string(int filedes, int *errp);
2N/A
2N/A/*
2N/A * File interface method declarations
2N/A */
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fileutil_free_string_array()
2N/A *
2N/A * Method: fileutil_add_string_to_array
2N/A *
2N/A * Description: Adds one line to the file image string array
2N/A *
2N/A * Parameters:
2N/A * char ***string_array - pointer array of strings holding the lines
2N/A * for the new file
2N/A * char *line - the line to be added to the new file
2N/A * int *count - the number of elements in the string array
2N/A * int *err - error pointer for returning any errors encountered
2N/A *
2N/A * Return:
2N/A * B_TRUE on success, B_FALSE on failure.
2N/A *
2N/A * Note:
2N/A * On success string_array is set to the new array of strings. On failure
2N/A * string_array is unchanged.
2N/A */
2N/Aboolean_t fileutil_add_string_to_array(char ***, char *, int *, int *);
2N/A
2N/A/*
2N/A * Method: fileutil_free_string_array
2N/A *
2N/A * Description: Frees the space allocated to a string array.
2N/A *
2N/A * Parameters:
2N/A * char ** - is the array to be freed
2N/A * int - the number of elements in the array
2N/A */
2N/Avoid fileutil_free_string_array(char **, int);
2N/A
2N/A/*
2N/A * Method: fileutil_get_cmd_from_string
2N/A *
2N/A * Description: Returns a string containing a line with all comments and
2N/A * trailing white space removed.
2N/A *
2N/A * Parameters:
2N/A * char *input_stringp - the line to remove all coments and trailing white
2N/A * space.
2N/A *
2N/A * Note: The memory allocated for the returned string must be freed by the
2N/A * caller of fileutil_get_cmd_from_string().
2N/A */
2N/Achar *fileutil_get_cmd_from_string(char *input_stringp);
2N/A
2N/A/*
2N/A * Method: fileutil_get_first_column_data
2N/A *
2N/A * Description: Returns a string array which is filled with the data in the
2N/A * first column of the lines in a table formatted file.
2N/A * Examples of table formatted files include: /etc/netcofig, /etc/nfssec.conf
2N/A *
2N/A * Parameters:
2N/A * FILE* - The file pointer of the table formatted file to get data from.
2N/A * int* - will be filled with the number of elements in the array that is passed
2N/A * back.
2N/A * int* - error pointer. If an error occurs this will be non-zero upon return
2N/A * the function.
2N/A *
2N/A * Returns:
2N/A * Two-dimensional array of characters (string array). Each element in the
2N/A * array is the first column data of each row in the table.
2N/A */
2N/Achar **fileutil_get_first_column_data(FILE *, int *, int *);
2N/A
2N/A/*
2N/A * Method: fileutil_getfs
2N/A *
2N/A * Description: Convenience function for retrieving the default remote file
2N/A * system type from /etc/dfs/fstypes.
2N/A *
2N/A * Parameters:
2N/A * FILE * - The /etc/dfs/fstypes file pointer.
2N/A *
2N/A * Return:
2N/A * The default remote filesystem type.
2N/A */
2N/Achar *fileutil_getfs(FILE *);
2N/A
2N/A/*
2N/A * Method: fileutil_getline
2N/A *
2N/A * Description: Convenience function for retrieving the next line from a file.
2N/A * Commented lines are not returned and comments at the end of
2N/A * a line are removed.
2N/A *
2N/A * Parameters:
2N/A * FILE * - The file pointer to a file that has been opened for reading.
2N/A * char * - The line retrived from the file will be placed in this string.
2N/A * int * - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function.
2N/A *
2N/A * Return:
2N/A * If successfull the line retrieved from the file will be returned.
2N/A * Otherwise NULL be be returned.
2N/A */
2N/Achar *fileutil_getline(FILE *, char *, int);
2N/A
2N/A/*
2N/A * Mount defaults (/etc/vfstab) interface method declarations
2N/A */
2N/A/*
2N/A * Method: fs_add_mount_default
2N/A *
2N/A * Description: Adds an entry to vfstab based on the fs_mntdefaults_t
2N/A * structure that is passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_mntdefaults_t *newp - The structure containing the mount information
2N/A * to be placed in vfstab.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function.
2N/A *
2N/A * Return:
2N/A * If successful a pointer to a list containing all the present vfstab
2N/A * entries is returned. On failure NULL is returned.
2N/A */
2N/Afs_mntdefaults_t *fs_add_mount_default(fs_mntdefaults_t *, int *);
2N/A
2N/A/*
2N/A * Method: fs_check_for_duplicate_DFStab_paths
2N/A *
2N/A * Description: Checks dfstab for duplicate paths and returns the number of
2N/A * times the path passed in was encountered. The functon is used to help make
2N/A * sure a path is only listed in dfstab once.
2N/A *
2N/A * Parameters:
2N/A * char *path - the path to check for
2N/A * int *err - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function.
2N/A *
2N/A * Return:
2N/A * The number of times the specified path is encountered in dfstab.
2N/A */
2N/Aint fs_check_for_duplicate_DFStab_paths(char *path, int *err);
2N/A
2N/A/*
2N/A * Method: fs_del_mount_default_ent
2N/A *
2N/A * Description: Deletes the specified vfstab entry from the vfstab file.
2N/A *
2N/A * Parameters:
2N/A * fs_mntdefaults_t *old_vfstab_ent - The mount information that corresponds
2N/A * to the vfstab entry to be deleted.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function.
2N/A *
2N/A * Return:
2N/A * If successful a pointer to a list containing all the changed vfstab
2N/A * entries is returned. On failure NULL is returned.
2N/A */
2N/Afs_mntdefaults_t *fs_del_mount_default_ent(fs_mntdefaults_t *, int *);
2N/A
2N/A/*
2N/A * Method: fs_edit_mount_defaults
2N/A *
2N/A * Description: Edits the specified vfstab entry with the new mount
2N/A * information passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_mntdefaults_t *old_vfstab_ent - The old vfstab entry that is to be edited.
2N/A * fs_mntdefaults_t *new_vfstab_ent - The new vfstab entry information.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A */
2N/Afs_mntdefaults_t *fs_edit_mount_defaults(fs_mntdefaults_t *,
2N/A fs_mntdefaults_t *, int *);
2N/A
2N/A/*
2N/A * Method: fs_free_mntdefaults_list
2N/A *
2N/A * Description: Frees the memory used when a fs_mntdefaults_t structure
2N/A * is populated.
2N/A *
2N/A * Parameters:
2N/A * fs_mntdefaults_t *headp - The pointer to the first element in the list
2N/A * of mntdefault structures.
2N/A */
2N/Avoid fs_free_mntdefaults_list(fs_mntdefaults_t *headp);
2N/A
2N/A
2N/A/*
2N/A * Method: fs_get_filtered_mount_defaults
2N/A *
2N/A * Description: Retrieves vfstab entries based in the fields in the
2N/A * fs_mntdefaults_t structure passed in. The fields that are not to
2N/A * be used in the filter will be set to NULL.
2N/A *
2N/A * Parameters:
2N/A * fs_mntdefaults_t *filter - The structure containing the fields to be
2N/A * used for the filter.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * The list of all vfstab entries meeting the filter criteria are returned.
2N/A * On failure NULL is returned.
2N/A */
2N/Afs_mntdefaults_t *fs_get_filtered_mount_defaults(
2N/A fs_mntdefaults_t *filter, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_mount_defaults
2N/A *
2N/A * Description: Retrieves vfstab entries and returns a list of
2N/A * fs_mntdefaults_t structures.
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * fs_mntdefaults_t * - Returns a list of all vfstab entries.
2N/A */
2N/Afs_mntdefaults_t *fs_get_mount_defaults(int *errp);
2N/A
2N/A/*
2N/A * Mount (/etc/mnttab) interface method declarations
2N/A */
2N/A/*
2N/A * Method: fs_free_mount_list
2N/A *
2N/A * Description: Frees the mount list created when retrieving mnttab entries.
2N/A *
2N/A * Parameters:
2N/A * fs_mntlist_t *headp - The mount list to be freed.
2N/A */
2N/Avoid fs_free_mount_list(fs_mntlist_t *mnt_list);
2N/A
2N/A/*
2N/A * Method: fs_get_availablesize
2N/A *
2N/A * Description: Calculates the total size available on the filesystem.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point to use for gathering the stat information
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * The total size available on the filesystem.
2N/A */
2N/Aunsigned long long fs_get_availablesize(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_avail_for_nonsuperuser_size
2N/A *
2N/A * Description: Calculates the available space on the filesystem for
2N/A * nonsuperusers.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * The available space for nonsuperusers.
2N/A * On failure NULL is returned.
2N/A */
2N/Aunsigned long long fs_get_avail_for_nonsuperuser_size(char *mntpnt,
2N/A int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_blocksize
2N/A *
2N/A * Description: Retrieves the preferred filesystem block size.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the preferred filesystem block size.
2N/A * On failure NULL is returned.
2N/A */
2N/A
2N/Aunsigned long long fs_get_blocksize(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_filtered_mount_list
2N/A *
2N/A * Description: Can be used to filter mounts only by the following mount
2N/A * attributes or a mixture of them:
2N/A * 1.) resource
2N/A * 2.) mount point
2N/A * 3.) mount option string
2N/A * 4.) time mounted
2N/A *
2N/A * Parameters:
2N/A * char *resource - The name of the resource to be mounted
2N/A * char *mountp - The pathname of the directory on which the filesystem
2N/A * is mounted
2N/A * char *mntopts - The mount options
2N/A * char *time - The time at which the filesystem was mounted
2N/A * boolean_t find_overlays - Flag used to turn on overlay checking
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * The list of all mnttab entries meeting the filter criteria are returned.
2N/A * On failure NULL is returned.
2N/A */
2N/Afs_mntlist_t *fs_get_filtered_mount_list(char *resource,
2N/A char *mountp, char *fstype, char *mntopts,
2N/A char *time, boolean_t find_overlays,
2N/A int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_fragsize
2N/A *
2N/A * Description: Determines the fundamental filesystem block size.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the fundamental filesystem block size.
2N/A * On failure NULL is returned.
2N/A */
2N/Aunsigned long fs_get_fragsize(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_maxfilenamelen
2N/A *
2N/A * Description: Determines the maximum file name length for the filesystem.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the maximum file name length for the specified filesystem.
2N/A * On failure NULL is returned.
2N/A */
2N/Aunsigned long fs_get_maxfilenamelen(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_mounts_by_mntopt
2N/A *
2N/A * Description: Returns only mounts with the specified mount option set.
2N/A *
2N/A * Parameters:
2N/A * char *mntopt - The mount option used for filtering mounts
2N/A * boolean_t find_overlays - Flag used to turn on overlay checking
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the list of all mnttab entries with the matching mount option.
2N/A * On failure NULL is returned.
2N/A */
2N/Afs_mntlist_t *fs_get_mounts_by_mntopt(char *mntopt,
2N/A boolean_t find_overlays, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_mount_list
2N/A *
2N/A * Description: Returns a list of all mounts in mnttab
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem
2N/A * boolean_t find_overlays - Flag used to turn on overlay checking
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the list of all mounts and associated mount information for mounts
2N/A * listed in mnttab. On failure NULL is returned.
2N/A */
2N/Afs_mntlist_t *fs_get_mount_list(boolean_t find_overlays, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_totalsize
2N/A *
2N/A * Description: Determines the total size of the filesystem using the
2N/A * total number of blocks and the block size.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the total size of the filesystem.
2N/A * On failure NULL is returned.
2N/A */
2N/Aunsigned long long fs_get_totalsize(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_get_usedsize
2N/A *
2N/A * Description: Calculates the size of the used portion of the filesystem.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the size of the the used portion of the filesystem.
2N/A * On failure NULL is returned.
2N/A */
2N/Aunsigned long long fs_get_usedsize(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_is_readonly
2N/A *
2N/A * Description: Checks the filesystem flags to see if the filesystem is
2N/A * readonly.
2N/A *
2N/A * Parameters:
2N/A * char *mntpnt - The mount point for the filesystem
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns B_TRUE if the readonly flag is set and B_FALSE if not.
2N/A * On error the error pointer is set to errno.
2N/A */
2N/Aboolean_t fs_is_readonly(char *mntpnt, int *errp);
2N/A
2N/A/*
2N/A * Method: fs_parse_optlist_for_option
2N/A *
2N/A * Description:
2N/A * This method will parse the given comma delimited option list (optlist) for
2N/A * the option passed into the function. If the option (opt) to search for
2N/A * is one that sets a value such as onerror=, the value to the right of the "="
2N/A * character will be returned from the function. This function expects the
2N/A * opt parameter to have the "=" character appended when searching for options
2N/A * which set a value.
2N/A *
2N/A * Parameters:
2N/A * char *optlist - The option string to be parsed
2N/A * char *opt - The option to search for
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the option as found in the option list.
2N/A * If the option is not found NULL is returned.
2N/A * On error NULL is returned and the error pointer is set to errno.
2N/A */
2N/Achar *fs_parse_optlist_for_option(char *optlist, char *opt,
2N/A int *errp);
2N/A
2N/A/*
2N/A * Share (/etc/dfs/sharetab) interface method declarations
2N/A */
2N/A/*
2N/A * Method: fs_free_share_list
2N/A *
2N/A * Description: Used to free populated fs_sharelist_t structures
2N/A *
2N/A * Parameters:
2N/A * fs_sharelist_t *headp - the pointer to the first element in the list.
2N/A */
2N/Avoid fs_free_share_list(fs_sharelist_t *share_list);
2N/A
2N/A/*
2N/A * Method: fs_get_share_list
2N/A *
2N/A * Description: Gets a list of the shares on the system from /etc/dfs/sharetab
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns a list of fs_sharelist_t structures containing all of the shares
2N/A * from sharetab.
2N/A * On error NULL is returned and errp is set to errno.
2N/A */
2N/Afs_sharelist_t *fs_get_share_list(int *errp);
2N/A
2N/A/*
2N/A * Method: fs_parse_opts_for_sec_modes
2N/A *
2N/A * Description: Parses the option string for security modes and returns
2N/A * an array of strings containing all modes.
2N/A *
2N/A * Parameters:
2N/A * char * - options string to be parsed.
2N/A * int * - count of the number of modes found.
2N/A * int * - error code.
2N/A *
2N/A * Return:
2N/A * Returns an array of string containing all security opts listed in the
2N/A * passed in option string. On error NULL is returned.
2N/A */
2N/Achar **fs_parse_opts_for_sec_modes(char *, int *, int *);
2N/A
2N/A/*
2N/A * Method: fs_create_array_from_accesslist
2N/A *
2N/A * Description: Takes the colon separated access list parses the list
2N/A * into an array containing all the elements of the list.
2N/A * The array created is returned and count is set to the
2N/A * number of elements in the array.
2N/A *
2N/A * Parameters:
2N/A * char *access_list - The string containing the colon sperated access list.
2N/A * int *count - Will contain the number of elements in the array.
2N/A * int *err - any errors encountered.
2N/A */
2N/Achar **fs_create_array_from_accesslist(char *access_list, int *count, int *err);
2N/A
2N/A/*
2N/A * FS dfstab (/etc/dfs/dfstab) interface method declarations
2N/A */
2N/A
2N/A/*
2N/A * Method: fs_add_DFStab_ent
2N/A *
2N/A * Description: Adds an entry to dfstab and to the list of dfstab
2N/A * entries. Returns a pointer to the head of the dfstab entry list.
2N/A *
2N/A * Parameters:
2N/A * char *cmd - the share command to be added to dfstab
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the pointer to the updated dfstab entry list.
2N/A */
2N/Afs_dfstab_entry_t fs_add_DFStab_ent(char *, int *);
2N/A
2N/A/*
2N/A * Method: fs_del_DFStab_ent
2N/A *
2N/A * Description: Deletes an entry from dfstab and from the list of
2N/A * dfstab entries.
2N/A *
2N/A * Parameters:
2N/A * char *del_cmd - The share command to be removed
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the pointer to the updated dfstab entry list.
2N/A */
2N/Afs_dfstab_entry_t fs_del_DFStab_ent(char *, int *);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fs_free_DFStab_ents()
2N/A *
2N/A * Method: fs_edit_DFStab_ent
2N/A *
2N/A * Description: Changes the specified line in dfstab to match the second
2N/A * string passed in.
2N/A *
2N/A * Parameters:
2N/A * char *old_cmd - The share command that will be changed.
2N/A * char *new_cmd - The share command that will replace old_cmd.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the pointer to the updated dfstab entry list.
2N/A */
2N/Afs_dfstab_entry_t fs_edit_DFStab_ent(char *, char *, int *);
2N/A
2N/A/*
2N/A * Method: fs_free_DFStab_ents
2N/A *
2N/A * Description: Frees the dfstab entry list.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t list - The pointer to the dfstab entry list.
2N/A */
2N/Avoid fs_free_DFStab_ents(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fs_free_DFStab_ents()
2N/A *
2N/A * Method: fs_get_DFStab_ents
2N/A *
2N/A * Description: Retrieves the dfstab entry list.
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the pointer to the dfstab entry list.
2N/A * If NULL is returned and errp is 0 then dfstab has no entries. If errp is
2N/A * not 0 there was an error and the value of errp is set to the errno
2N/A * value for that error.
2N/A */
2N/Afs_dfstab_entry_t fs_get_DFStab_ents(int *err);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fs_free_DFStab_ents()
2N/A *
2N/A * Method: fs_get_DFStab_ent_Desc
2N/A *
2N/A * Description: Retrieves the description information for the present
2N/A * dfstab entry.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - the dfstab entry to retrieve the description from.
2N/A *
2N/A * Return:
2N/A * The string containing the description for the dfstab entry.
2N/A * If the description is not set NULL is returned.
2N/A *
2N/A * Note: the description is an optional share option and a return value of
2N/A * NULL is not an error but indicates that the description was not set.
2N/A */
2N/Achar *fs_get_DFStab_ent_Desc(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_DFStab_ent_Fstype
2N/A *
2N/A * Description: Retrieves the filesystem type information from the dfstab
2N/A * entry passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - the dfstab entry to retrieve the fstype from.
2N/A *
2N/A * Return:
2N/A * The string containing the filesystem type.
2N/A *
2N/A * Note: if fstype is not set in the dfstab entry the default fstype is
2N/A * returned.
2N/A */
2N/Achar *fs_get_DFStab_ent_Fstype(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_DFStab_ent_Next
2N/A *
2N/A * Description: Retrieves the next entry in the dfstab entry list.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - The dfstab entry pointer to get the next
2N/A * pointer from.
2N/A *
2N/A * Return:
2N/A * Returns the next dfstab entry.
2N/A * A return value of NULL indicates the end of the dfstab entry list.
2N/A */
2N/Afs_dfstab_entry_t fs_get_DFStab_ent_Next(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_DFStab_ent_Options
2N/A *
2N/A * Description: Retrieves the share options from the dfstab
2N/A * entry passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - The dfstab entry to retrieve the share
2N/A * options from.
2N/A *
2N/A * Return:
2N/A * Returns the string containing the share options.
2N/A * A NULL value indicates that no options were specified in the dfstab entry.
2N/A */
2N/Achar *fs_get_DFStab_ent_Options(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_DFStab_ent_Path
2N/A *
2N/A * Description: Retrieves the path information from the dfstab
2N/A * entry passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - the dfstab entry to retrieve the path from.
2N/A *
2N/A * Return:
2N/A * Returns the string containing the path.
2N/A * A NULL value indecates that no path information is available for the
2N/A * dfstab entry. A NULL value here is an error and indicates an invalid
2N/A * dfstab entry.
2N/A */
2N/Achar *fs_get_DFStab_ent_Path(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_DFStab_ent_Res
2N/A *
2N/A * Description: Retrieves the resource information from the dfstab entry
2N/A * passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - the dfstab entry to retrieve the resource
2N/A * information from.
2N/A *
2N/A * Return:
2N/A * Returns the string containing the path.
2N/A * A NULL value indecates that no resource information is available for the
2N/A * dfstab entry.
2N/A */
2N/Achar *fs_get_DFStab_ent_Res(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * Method: fs_get_Dfstab_share_cmd
2N/A *
2N/A * Description: Retrieves the share command that corresponds to the
2N/A * dfstab entry passed in.
2N/A *
2N/A * Parameters:
2N/A * fs_dfstab_entry_t entry - The dfstab entry that will be used to create
2N/A * a share command.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns the string containing the share command.
2N/A * A NULL value indicates an error occured and errp will be non zero.
2N/A */
2N/Achar *fs_get_Dfstab_share_cmd(fs_dfstab_entry_t, int *);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fs_free_DFStab_ents()
2N/A *
2N/A * Method: fs_set_DFStab_ent
2N/A *
2N/A * Description: Used to add entries into dfstab
2N/A *
2N/A * Parameters:
2N/A * char *path - The path for the dfstab entry
2N/A * char *fstype - The filesystem type for the share
2N/A * char *options - The share options to be used for the dfstab entry
2N/A * char *description - The description for the share
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * Returns a pointer to the begining of the dfstab entry list
2N/A * Failure returns NULL
2N/A */
2N/Afs_dfstab_entry_t fs_set_DFStab_ent(char *, char *, char *, char *, int *);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling fs_free_DFStab_ents()
2N/A *
2N/A * Method: fs_del_All_DFStab_ents_with_Path
2N/A *
2N/A * Description: Removes all dfstab entries with the specified path.
2N/A *
2N/A * Parameters:
2N/A * char *path - The path to checked for removal from dfstab.
2N/A * int *err - error pointer.
2N/A *
2N/A * Return: returns a pointer to the nfs list of dfstab entries.
2N/A */
2N/Afs_dfstab_entry_t fs_del_All_DFStab_ents_with_Path(char *, int *);
2N/A
2N/A/*
2N/A * Debuging functions
2N/A */
2N/Avoid fs_print_dfstab_entries(fs_dfstab_entry_t);
2N/A
2N/A/*
2N/A * NFS mount interface method declarations
2N/A */
2N/A/*
2N/A * Method: nfs_free_mntinfo_list
2N/A *
2N/A * Description: Used to free the network id list, which is an array of strings.
2N/A *
2N/A * Parameters:
2N/A * nfs_mntlist_t *mountinfo_list - The list of mounts and associated mount
2N/A * information
2N/A *
2N/A */
2N/Avoid nfs_free_mntinfo_list(nfs_mntlist_t *);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling nfs_free_mntinfo_list()
2N/A *
2N/A * Method: nfs_get_filtered_mount_list
2N/A *
2N/A * Description: Can be used to filter nfs mounts only by the following mount
2N/A * attributes or a mixture of them:
2N/A * 1.) resource
2N/A * 2.) mount point
2N/A * 3.) mount option string
2N/A * 4.) time mounted
2N/A *
2N/A * NULL must be passed into the options that are not being used in the filter.
2N/A *
2N/A * Parameters:
2N/A * char *resource - The name of the resource to be mounted
2N/A * char *mountp - The pathname of the directory on which the filesystem
2N/A * is mounted
2N/A * char *mntopts - The mount options
2N/A * char *time - The time at which the filesystem was mounted
2N/A * boolean_t find_overlays - Flag used to turn on overlay checking
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * nfs_mntlist_t * - Returns a list of nfs mounts based on the
2N/A * parameters passed in.
2N/A */
2N/Anfs_mntlist_t *nfs_get_filtered_mount_list(char *resource, char *mountp,
2N/A char *mntopts, char *time, boolean_t find_overlays,
2N/A int *errp);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling nfs_free_mntinfo_list()
2N/A *
2N/A * Method: nfs_get_mounts_by_mntopt
2N/A *
2N/A * Description: Can be used to filter mounts by the mount options attribute.
2N/A *
2N/A * Parameters:
2N/A * char *mntopts - The mount options
2N/A * boolean_t find_overlays - Flag used to turn on overlay checking
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * nfs_mntlist_t * - Returns a list of nfs mounts based on the
2N/A * parameters passed in.
2N/A */
2N/Anfs_mntlist_t *nfs_get_mounts_by_mntopt(char *mntopt, boolean_t find_overlays,
2N/A int *errp);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling nfs_free_mntinfo_list()
2N/A *
2N/A * Method: nfs_get_mount_list
2N/A *
2N/A * Description: Used to gather all NFS mounts and there associated
2N/A * mount information.
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * nfs_mntlist_t * - Returns a list of all nfs mounts.
2N/A */
2N/Anfs_mntlist_t *nfs_get_mount_list(int *);
2N/A
2N/A/*
2N/A * Netconfig (/etc/netconfig) interface method declarations
2N/A */
2N/A/*
2N/A * Method: netcfg_free_networkid_list
2N/A *
2N/A * Description: Used to free the network id list, which is an array of strings.
2N/A *
2N/A * Parameters:
2N/A * char **netlist - The array of strings containing the network id list
2N/A * int num_elements - The number of elements in the network id list
2N/A *
2N/A */
2N/Avoid netcfg_free_networkid_list(char **netlist, int num_elements);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling netcfg_free_networkid_list()
2N/A *
2N/A * Method: netcfg_get_networkid_list
2N/A *
2N/A * Description: Used to create the network id list.
2N/A *
2N/A * Parameters:
2N/A * int *num_elements - The number of elements in the network id list.
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * char ** - Returns the netowk id list.
2N/A */
2N/Achar **netcfg_get_networkid_list(int *num_elements, int *errp);
2N/A
2N/A/*
2N/A * nfssec (/etc/nfssec.conf) interface method declarations
2N/A */
2N/A/*
2N/A * Method: nfssec_free_secmode_list
2N/A *
2N/A * Description: Used to free the NFS security mode list.
2N/A *
2N/A * Parameters:
2N/A * char **seclist - The array of strings containing the security mode list
2N/A * int num_elements - The number of elements in the list
2N/A *
2N/A */
2N/Avoid nfssec_free_secmode_list(char **seclist, int num_elements);
2N/A
2N/A/*
2N/A * Method: nfssec_get_default_secmode
2N/A *
2N/A * Description: Used to retrieve the default security mode
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * char * - Returns the name of the default security mode
2N/A */
2N/Achar *nfssec_get_default_secmode(int *errp);
2N/A
2N/A/*
2N/A * NOTE: the caller of this function is responsible for freeing any
2N/A * memory allocated by calling nfssec_free_secmode_list()
2N/A *
2N/A * Method: nfssec_get_nfs_secmode_list
2N/A *
2N/A * Description: Used to create the NFS security mode list.
2N/A *
2N/A * Parameters:
2N/A * int *num_elements - The number of elements in the security mode list
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * char ** - Returns the NFS security mode list
2N/A *
2N/A */
2N/Achar **nfssec_get_nfs_secmode_list(int *num_elements, int *errp);
2N/A
2N/A/*
2N/A * System information interface method declarations
2N/A */
2N/A/*
2N/A * Method: sys_get_hostname
2N/A *
2N/A * Description: Used to retrieve the name of the host
2N/A *
2N/A * Parameters:
2N/A * int *errp - error pointer - If an error occurs this will be non-zero upon
2N/A * return from the function
2N/A *
2N/A * Return:
2N/A * char * - Returns the name of the host system
2N/A */
2N/Achar *sys_get_hostname(int *errp);
2N/A
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBFSMGT_H */