8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libfsmgt / common / libfsmgt.h
blobd8f6e103e44eea0df8eb537ab003501551ca4be7
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _LIBFSMGT_H
28 #define _LIBFSMGT_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <stdio.h>
37 #include <sys/param.h>
38 #include <nfs/nfs_sec.h>
39 #include <sys/utsname.h>
41 #define DFSTYPES "/etc/dfs/fstypes" /* dfs list */
42 #define DFSTAB "/etc/dfs/dfstab" /* dfs list */
43 #define BUFSIZE 65536
44 #define LINESZ 2048
46 typedef void *fs_dfstab_entry_t;
49 * Public data type declarations
53 * Represents a list of the /etc/vfstab entries
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;
67 * Represents a list of /etc/mnttab entries
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;
82 * Represents a /etc/dfs/sharetab entry
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;
94 * Represents a list of /etc/mnttab entries with associated
95 * information from kstat.
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;
134 * Command execution interface method declarations
138 * Method: cmd_execute_command
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.
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.
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.
164 int cmd_execute_command(char *cmd, int *output_filedes, int *error_filedes);
167 * Method: cmd_execute_command_and_retrieve_string
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).
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.
180 * Return:
181 * The output to stdout and stderr created by the execution of the passed in
182 * command.
184 char *cmd_execute_command_and_retrieve_string(char *cmd, int *errp);
187 * Method: cmd_retrieve_string
189 * Description: Retrieves the data from the passed in file descriptor and
190 * returns it to the caller in the form of a string.
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.
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().
204 char *cmd_retrieve_string(int filedes, int *errp);
207 * File interface method declarations
211 * NOTE: the caller of this function is responsible for freeing any
212 * memory allocated by calling fileutil_free_string_array()
214 * Method: fileutil_add_string_to_array
216 * Description: Adds one line to the file image string array
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
225 * Return:
226 * B_TRUE on success, B_FALSE on failure.
228 * Note:
229 * On success string_array is set to the new array of strings. On failure
230 * string_array is unchanged.
232 boolean_t fileutil_add_string_to_array(char ***, char *, int *, int *);
235 * Method: fileutil_free_string_array
237 * Description: Frees the space allocated to a string array.
239 * Parameters:
240 * char ** - is the array to be freed
241 * int - the number of elements in the array
243 void fileutil_free_string_array(char **, int);
246 * Method: fileutil_get_cmd_from_string
248 * Description: Returns a string containing a line with all comments and
249 * trailing white space removed.
251 * Parameters:
252 * char *input_stringp - the line to remove all coments and trailing white
253 * space.
255 * Note: The memory allocated for the returned string must be freed by the
256 * caller of fileutil_get_cmd_from_string().
258 char *fileutil_get_cmd_from_string(char *input_stringp);
261 * Method: fileutil_get_first_column_data
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
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.
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.
278 char **fileutil_get_first_column_data(FILE *, int *, int *);
281 * Method: fileutil_getfs
283 * Description: Convenience function for retrieving the default remote file
284 * system type from /etc/dfs/fstypes.
286 * Parameters:
287 * FILE * - The /etc/dfs/fstypes file pointer.
289 * Return:
290 * The default remote filesystem type.
292 char *fileutil_getfs(FILE *);
295 * Method: fileutil_getline
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.
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.
307 * Return:
308 * If successfull the line retrieved from the file will be returned.
309 * Otherwise NULL be be returned.
311 char *fileutil_getline(FILE *, char *, int);
314 * Mount defaults (/etc/vfstab) interface method declarations
317 * Method: fs_add_mount_default
319 * Description: Adds an entry to vfstab based on the fs_mntdefaults_t
320 * structure that is passed in.
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.
328 * Return:
329 * If successful a pointer to a list containing all the present vfstab
330 * entries is returned. On failure NULL is returned.
332 fs_mntdefaults_t *fs_add_mount_default(fs_mntdefaults_t *, int *);
335 * Method: fs_check_for_duplicate_DFStab_paths
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.
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.
346 * Return:
347 * The number of times the specified path is encountered in dfstab.
349 int fs_check_for_duplicate_DFStab_paths(char *path, int *err);
352 * Method: fs_del_mount_default_ent
354 * Description: Deletes the specified vfstab entry from the vfstab file.
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.
362 * Return:
363 * If successful a pointer to a list containing all the changed vfstab
364 * entries is returned. On failure NULL is returned.
366 fs_mntdefaults_t *fs_del_mount_default_ent(fs_mntdefaults_t *, int *);
369 * Method: fs_edit_mount_defaults
371 * Description: Edits the specified vfstab entry with the new mount
372 * information passed in.
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
380 * Return:
382 fs_mntdefaults_t *fs_edit_mount_defaults(fs_mntdefaults_t *,
383 fs_mntdefaults_t *, int *);
386 * Method: fs_free_mntdefaults_list
388 * Description: Frees the memory used when a fs_mntdefaults_t structure
389 * is populated.
391 * Parameters:
392 * fs_mntdefaults_t *headp - The pointer to the first element in the list
393 * of mntdefault structures.
395 void fs_free_mntdefaults_list(fs_mntdefaults_t *headp);
399 * Method: fs_get_filtered_mount_defaults
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.
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
411 * Return:
412 * The list of all vfstab entries meeting the filter criteria are returned.
413 * On failure NULL is returned.
415 fs_mntdefaults_t *fs_get_filtered_mount_defaults(
416 fs_mntdefaults_t *filter, int *errp);
419 * Method: fs_get_mount_defaults
421 * Description: Retrieves vfstab entries and returns a list of
422 * fs_mntdefaults_t structures.
424 * Parameters:
425 * int *errp - error pointer - If an error occurs this will be non-zero upon
426 * return from the function
428 * Return:
429 * fs_mntdefaults_t * - Returns a list of all vfstab entries.
431 fs_mntdefaults_t *fs_get_mount_defaults(int *errp);
434 * Mount (/etc/mnttab) interface method declarations
437 * Method: fs_free_mount_list
439 * Description: Frees the mount list created when retrieving mnttab entries.
441 * Parameters:
442 * fs_mntlist_t *headp - The mount list to be freed.
444 void fs_free_mount_list(fs_mntlist_t *mnt_list);
447 * Method: fs_get_availablesize
449 * Description: Calculates the total size available on the filesystem.
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
456 * Return:
457 * The total size available on the filesystem.
459 unsigned long long fs_get_availablesize(char *mntpnt, int *errp);
462 * Method: fs_get_avail_for_nonsuperuser_size
464 * Description: Calculates the available space on the filesystem for
465 * nonsuperusers.
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
472 * Return:
473 * The available space for nonsuperusers.
474 * On failure NULL is returned.
476 unsigned long long fs_get_avail_for_nonsuperuser_size(char *mntpnt,
477 int *errp);
480 * Method: fs_get_blocksize
482 * Description: Retrieves the preferred filesystem block size.
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
489 * Return:
490 * Returns the preferred filesystem block size.
491 * On failure NULL is returned.
494 unsigned long long fs_get_blocksize(char *mntpnt, int *errp);
497 * Method: fs_get_filtered_mount_list
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
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
516 * Return:
517 * The list of all mnttab entries meeting the filter criteria are returned.
518 * On failure NULL is returned.
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);
526 * Method: fs_get_fragsize
528 * Description: Determines the fundamental filesystem block size.
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
535 * Return:
536 * Returns the fundamental filesystem block size.
537 * On failure NULL is returned.
539 unsigned long fs_get_fragsize(char *mntpnt, int *errp);
542 * Method: fs_get_maxfilenamelen
544 * Description: Determines the maximum file name length for the filesystem.
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
551 * Return:
552 * Returns the maximum file name length for the specified filesystem.
553 * On failure NULL is returned.
555 unsigned long fs_get_maxfilenamelen(char *mntpnt, int *errp);
558 * Method: fs_get_mounts_by_mntopt
560 * Description: Returns only mounts with the specified mount option set.
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
568 * Return:
569 * Returns the list of all mnttab entries with the matching mount option.
570 * On failure NULL is returned.
572 fs_mntlist_t *fs_get_mounts_by_mntopt(char *mntopt,
573 boolean_t find_overlays, int *errp);
576 * Method: fs_get_mount_list
578 * Description: Returns a list of all mounts in mnttab
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
586 * Return:
587 * Returns the list of all mounts and associated mount information for mounts
588 * listed in mnttab. On failure NULL is returned.
590 fs_mntlist_t *fs_get_mount_list(boolean_t find_overlays, int *errp);
593 * Method: fs_get_totalsize
595 * Description: Determines the total size of the filesystem using the
596 * total number of blocks and the block size.
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
603 * Return:
604 * Returns the total size of the filesystem.
605 * On failure NULL is returned.
607 unsigned long long fs_get_totalsize(char *mntpnt, int *errp);
610 * Method: fs_get_usedsize
612 * Description: Calculates the size of the used portion of the filesystem.
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
619 * Return:
620 * Returns the size of the the used portion of the filesystem.
621 * On failure NULL is returned.
623 unsigned long long fs_get_usedsize(char *mntpnt, int *errp);
626 * Method: fs_is_readonly
628 * Description: Checks the filesystem flags to see if the filesystem is
629 * readonly.
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
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.
640 boolean_t fs_is_readonly(char *mntpnt, int *errp);
643 * Method: fs_parse_optlist_for_option
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.
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
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.
664 char *fs_parse_optlist_for_option(char *optlist, char *opt,
665 int *errp);
668 * Share (/etc/dfs/sharetab) interface method declarations
671 * Method: fs_free_share_list
673 * Description: Used to free populated fs_sharelist_t structures
675 * Parameters:
676 * fs_sharelist_t *headp - the pointer to the first element in the list.
678 void fs_free_share_list(fs_sharelist_t *share_list);
681 * Method: fs_get_share_list
683 * Description: Gets a list of the shares on the system from /etc/dfs/sharetab
685 * Parameters:
686 * int *errp - error pointer - If an error occurs this will be non-zero upon
687 * return from the function
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.
694 fs_sharelist_t *fs_get_share_list(int *errp);
697 * Method: fs_parse_opts_for_sec_modes
699 * Description: Parses the option string for security modes and returns
700 * an array of strings containing all modes.
702 * Parameters:
703 * char * - options string to be parsed.
704 * int * - count of the number of modes found.
705 * int * - error code.
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.
711 char **fs_parse_opts_for_sec_modes(char *, int *, int *);
714 * Method: fs_create_array_from_accesslist
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.
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.
726 char **fs_create_array_from_accesslist(char *access_list, int *count, int *err);
729 * FS dfstab (/etc/dfs/dfstab) interface method declarations
733 * Method: fs_add_DFStab_ent
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.
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
743 * Return:
744 * Returns the pointer to the updated dfstab entry list.
746 fs_dfstab_entry_t fs_add_DFStab_ent(char *, int *);
749 * Method: fs_del_DFStab_ent
751 * Description: Deletes an entry from dfstab and from the list of
752 * dfstab entries.
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
759 * Return:
760 * Returns the pointer to the updated dfstab entry list.
762 fs_dfstab_entry_t fs_del_DFStab_ent(char *, int *);
765 * NOTE: the caller of this function is responsible for freeing any
766 * memory allocated by calling fs_free_DFStab_ents()
768 * Method: fs_edit_DFStab_ent
770 * Description: Changes the specified line in dfstab to match the second
771 * string passed in.
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
779 * Return:
780 * Returns the pointer to the updated dfstab entry list.
782 fs_dfstab_entry_t fs_edit_DFStab_ent(char *, char *, int *);
785 * Method: fs_free_DFStab_ents
787 * Description: Frees the dfstab entry list.
789 * Parameters:
790 * fs_dfstab_entry_t list - The pointer to the dfstab entry list.
792 void fs_free_DFStab_ents(fs_dfstab_entry_t);
795 * NOTE: the caller of this function is responsible for freeing any
796 * memory allocated by calling fs_free_DFStab_ents()
798 * Method: fs_get_DFStab_ents
800 * Description: Retrieves the dfstab entry list.
802 * Parameters:
803 * int *errp - error pointer - If an error occurs this will be non-zero upon
804 * return from the function
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.
812 fs_dfstab_entry_t fs_get_DFStab_ents(int *err);
815 * NOTE: the caller of this function is responsible for freeing any
816 * memory allocated by calling fs_free_DFStab_ents()
818 * Method: fs_get_DFStab_ent_Desc
820 * Description: Retrieves the description information for the present
821 * dfstab entry.
823 * Parameters:
824 * fs_dfstab_entry_t entry - the dfstab entry to retrieve the description from.
826 * Return:
827 * The string containing the description for the dfstab entry.
828 * If the description is not set NULL is returned.
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.
833 char *fs_get_DFStab_ent_Desc(fs_dfstab_entry_t);
836 * Method: fs_get_DFStab_ent_Fstype
838 * Description: Retrieves the filesystem type information from the dfstab
839 * entry passed in.
841 * Parameters:
842 * fs_dfstab_entry_t entry - the dfstab entry to retrieve the fstype from.
844 * Return:
845 * The string containing the filesystem type.
847 * Note: if fstype is not set in the dfstab entry the default fstype is
848 * returned.
850 char *fs_get_DFStab_ent_Fstype(fs_dfstab_entry_t);
853 * Method: fs_get_DFStab_ent_Next
855 * Description: Retrieves the next entry in the dfstab entry list.
857 * Parameters:
858 * fs_dfstab_entry_t entry - The dfstab entry pointer to get the next
859 * pointer from.
861 * Return:
862 * Returns the next dfstab entry.
863 * A return value of NULL indicates the end of the dfstab entry list.
865 fs_dfstab_entry_t fs_get_DFStab_ent_Next(fs_dfstab_entry_t);
868 * Method: fs_get_DFStab_ent_Options
870 * Description: Retrieves the share options from the dfstab
871 * entry passed in.
873 * Parameters:
874 * fs_dfstab_entry_t entry - The dfstab entry to retrieve the share
875 * options from.
877 * Return:
878 * Returns the string containing the share options.
879 * A NULL value indicates that no options were specified in the dfstab entry.
881 char *fs_get_DFStab_ent_Options(fs_dfstab_entry_t);
884 * Method: fs_get_DFStab_ent_Path
886 * Description: Retrieves the path information from the dfstab
887 * entry passed in.
889 * Parameters:
890 * fs_dfstab_entry_t entry - the dfstab entry to retrieve the path from.
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.
898 char *fs_get_DFStab_ent_Path(fs_dfstab_entry_t);
901 * Method: fs_get_DFStab_ent_Res
903 * Description: Retrieves the resource information from the dfstab entry
904 * passed in.
906 * Parameters:
907 * fs_dfstab_entry_t entry - the dfstab entry to retrieve the resource
908 * information from.
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.
915 char *fs_get_DFStab_ent_Res(fs_dfstab_entry_t);
918 * Method: fs_get_Dfstab_share_cmd
920 * Description: Retrieves the share command that corresponds to the
921 * dfstab entry passed in.
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
929 * Return:
930 * Returns the string containing the share command.
931 * A NULL value indicates an error occured and errp will be non zero.
933 char *fs_get_Dfstab_share_cmd(fs_dfstab_entry_t, int *);
936 * NOTE: the caller of this function is responsible for freeing any
937 * memory allocated by calling fs_free_DFStab_ents()
939 * Method: fs_set_DFStab_ent
941 * Description: Used to add entries into dfstab
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
951 * Return:
952 * Returns a pointer to the begining of the dfstab entry list
953 * Failure returns NULL
955 fs_dfstab_entry_t fs_set_DFStab_ent(char *, char *, char *, char *, int *);
958 * NOTE: the caller of this function is responsible for freeing any
959 * memory allocated by calling fs_free_DFStab_ents()
961 * Method: fs_del_All_DFStab_ents_with_Path
963 * Description: Removes all dfstab entries with the specified path.
965 * Parameters:
966 * char *path - The path to checked for removal from dfstab.
967 * int *err - error pointer.
969 * Return: returns a pointer to the nfs list of dfstab entries.
971 fs_dfstab_entry_t fs_del_All_DFStab_ents_with_Path(char *, int *);
974 * Debuging functions
976 void fs_print_dfstab_entries(fs_dfstab_entry_t);
979 * NFS mount interface method declarations
982 * Method: nfs_free_mntinfo_list
984 * Description: Used to free the network id list, which is an array of strings.
986 * Parameters:
987 * nfs_mntlist_t *mountinfo_list - The list of mounts and associated mount
988 * information
991 void nfs_free_mntinfo_list(nfs_mntlist_t *);
994 * NOTE: the caller of this function is responsible for freeing any
995 * memory allocated by calling nfs_free_mntinfo_list()
997 * Method: nfs_get_filtered_mount_list
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
1006 * NULL must be passed into the options that are not being used in the filter.
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
1018 * Return:
1019 * nfs_mntlist_t * - Returns a list of nfs mounts based on the
1020 * parameters passed in.
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);
1027 * NOTE: the caller of this function is responsible for freeing any
1028 * memory allocated by calling nfs_free_mntinfo_list()
1030 * Method: nfs_get_mounts_by_mntopt
1032 * Description: Can be used to filter mounts by the mount options attribute.
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
1040 * Return:
1041 * nfs_mntlist_t * - Returns a list of nfs mounts based on the
1042 * parameters passed in.
1044 nfs_mntlist_t *nfs_get_mounts_by_mntopt(char *mntopt, boolean_t find_overlays,
1045 int *errp);
1048 * NOTE: the caller of this function is responsible for freeing any
1049 * memory allocated by calling nfs_free_mntinfo_list()
1051 * Method: nfs_get_mount_list
1053 * Description: Used to gather all NFS mounts and there associated
1054 * mount information.
1056 * Parameters:
1057 * int *errp - error pointer - If an error occurs this will be non-zero upon
1058 * return from the function
1060 * Return:
1061 * nfs_mntlist_t * - Returns a list of all nfs mounts.
1063 nfs_mntlist_t *nfs_get_mount_list(int *);
1066 * Netconfig (/etc/netconfig) interface method declarations
1069 * Method: netcfg_free_networkid_list
1071 * Description: Used to free the network id list, which is an array of strings.
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
1078 void netcfg_free_networkid_list(char **netlist, int num_elements);
1081 * NOTE: the caller of this function is responsible for freeing any
1082 * memory allocated by calling netcfg_free_networkid_list()
1084 * Method: netcfg_get_networkid_list
1086 * Description: Used to create the network id list.
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
1093 * Return:
1094 * char ** - Returns the netowk id list.
1096 char **netcfg_get_networkid_list(int *num_elements, int *errp);
1099 * nfssec (/etc/nfssec.conf) interface method declarations
1102 * Method: nfssec_free_secmode_list
1104 * Description: Used to free the NFS security mode list.
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
1111 void nfssec_free_secmode_list(char **seclist, int num_elements);
1114 * Method: nfssec_get_default_secmode
1116 * Description: Used to retrieve the default security mode
1118 * Parameters:
1119 * int *errp - error pointer - If an error occurs this will be non-zero upon
1120 * return from the function
1122 * Return:
1123 * char * - Returns the name of the default security mode
1125 char *nfssec_get_default_secmode(int *errp);
1128 * NOTE: the caller of this function is responsible for freeing any
1129 * memory allocated by calling nfssec_free_secmode_list()
1131 * Method: nfssec_get_nfs_secmode_list
1133 * Description: Used to create the NFS security mode list.
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
1140 * Return:
1141 * char ** - Returns the NFS security mode list
1144 char **nfssec_get_nfs_secmode_list(int *num_elements, int *errp);
1147 * System information interface method declarations
1150 * Method: sys_get_hostname
1152 * Description: Used to retrieve the name of the host
1154 * Parameters:
1155 * int *errp - error pointer - If an error occurs this will be non-zero upon
1156 * return from the function
1158 * Return:
1159 * char * - Returns the name of the host system
1161 char *sys_get_hostname(int *errp);
1164 #ifdef __cplusplus
1166 #endif
1168 #endif /* _LIBFSMGT_H */