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