1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate * Traverses /etc/vfstab in order to find default mount information about
31*0Sstevel@tonic-gate * file systems on the current host.
32*0Sstevel@tonic-gate */
33*0Sstevel@tonic-gate #include <errno.h>
34*0Sstevel@tonic-gate #include <stdlib.h>
35*0Sstevel@tonic-gate #include <stdio.h>
36*0Sstevel@tonic-gate #include <sys/vfstab.h>
37*0Sstevel@tonic-gate #include <sys/types.h>
38*0Sstevel@tonic-gate #include <strings.h>
39*0Sstevel@tonic-gate #include <thread.h>
40*0Sstevel@tonic-gate #include <synch.h>
41*0Sstevel@tonic-gate #include "libfsmgt.h"
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate /*
44*0Sstevel@tonic-gate * Private constants
45*0Sstevel@tonic-gate */
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate static const char sepstr[] = "\t\n";
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate /*
50*0Sstevel@tonic-gate * Private variables
51*0Sstevel@tonic-gate */
52*0Sstevel@tonic-gate static mutex_t vfstab_lock = DEFAULTMUTEX;
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate /*
56*0Sstevel@tonic-gate * Private method declarations
57*0Sstevel@tonic-gate */
58*0Sstevel@tonic-gate static int cmp_fields(char *, char *, int);
59*0Sstevel@tonic-gate static fs_mntdefaults_t *create_mntdefaults_entry(struct vfstab vfstab_entry,
60*0Sstevel@tonic-gate int *errp);
61*0Sstevel@tonic-gate static struct vfstab *create_vfstab_filter(fs_mntdefaults_t *filter,
62*0Sstevel@tonic-gate int *errp);
63*0Sstevel@tonic-gate static void free_vfstab_entry(struct vfstab *vfstab_entry);
64*0Sstevel@tonic-gate static char *create_vfstab_entry_line(struct vfstab *, int *);
65*0Sstevel@tonic-gate static int vfstab_line_cmp(fs_mntdefaults_t *, struct vfstab *);
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate /*
68*0Sstevel@tonic-gate * Public methods
69*0Sstevel@tonic-gate */
70*0Sstevel@tonic-gate
fs_free_mntdefaults_list(fs_mntdefaults_t * headp)71*0Sstevel@tonic-gate void fs_free_mntdefaults_list(fs_mntdefaults_t *headp) {
72*0Sstevel@tonic-gate fs_mntdefaults_t *tmp;
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate while (headp != NULL) {
75*0Sstevel@tonic-gate tmp = headp->next;
76*0Sstevel@tonic-gate free(headp->resource);
77*0Sstevel@tonic-gate free(headp->fsckdevice);
78*0Sstevel@tonic-gate free(headp->mountp);
79*0Sstevel@tonic-gate free(headp->fstype);
80*0Sstevel@tonic-gate free(headp->fsckpass);
81*0Sstevel@tonic-gate free(headp->mountatboot);
82*0Sstevel@tonic-gate free(headp->mntopts);
83*0Sstevel@tonic-gate headp->next = NULL;
84*0Sstevel@tonic-gate free(headp);
85*0Sstevel@tonic-gate
86*0Sstevel@tonic-gate headp = tmp;
87*0Sstevel@tonic-gate }
88*0Sstevel@tonic-gate } /* fs_free_mntdefaults_list */
89*0Sstevel@tonic-gate
90*0Sstevel@tonic-gate /*
91*0Sstevel@tonic-gate * Filter by the fields that are filled in on the filter parameter.
92*0Sstevel@tonic-gate * Fields that aren't used in filtering the defaults will be NULL.
93*0Sstevel@tonic-gate */
fs_get_filtered_mount_defaults(fs_mntdefaults_t * filter,int * errp)94*0Sstevel@tonic-gate fs_mntdefaults_t *fs_get_filtered_mount_defaults(fs_mntdefaults_t *filter,
95*0Sstevel@tonic-gate int *errp) {
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gate fs_mntdefaults_t *newp;
98*0Sstevel@tonic-gate fs_mntdefaults_t *headp;
99*0Sstevel@tonic-gate fs_mntdefaults_t *tailp;
100*0Sstevel@tonic-gate FILE *fp;
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate headp = NULL;
103*0Sstevel@tonic-gate tailp = NULL;
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate
106*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) != NULL) {
107*0Sstevel@tonic-gate struct vfstab vfstab_entry;
108*0Sstevel@tonic-gate struct vfstab *search_entry;
109*0Sstevel@tonic-gate (void) mutex_lock(&vfstab_lock);
110*0Sstevel@tonic-gate search_entry = create_vfstab_filter(filter, errp);
111*0Sstevel@tonic-gate if (search_entry == NULL) {
112*0Sstevel@tonic-gate /*
113*0Sstevel@tonic-gate * Out of memory, the error pointer (errp) gets
114*0Sstevel@tonic-gate * set in create_vfstab_filter.
115*0Sstevel@tonic-gate */
116*0Sstevel@tonic-gate fs_free_mntdefaults_list(headp);
117*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
118*0Sstevel@tonic-gate (void) fclose(fp);
119*0Sstevel@tonic-gate return (NULL);
120*0Sstevel@tonic-gate }
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gate while (getvfsany(fp, &vfstab_entry, search_entry) == 0) {
123*0Sstevel@tonic-gate /*
124*0Sstevel@tonic-gate * Add to list to be returned
125*0Sstevel@tonic-gate */
126*0Sstevel@tonic-gate newp = create_mntdefaults_entry(vfstab_entry, errp);
127*0Sstevel@tonic-gate if (newp == NULL) {
128*0Sstevel@tonic-gate /*
129*0Sstevel@tonic-gate * Out of memory, the error pointer (errp)
130*0Sstevel@tonic-gate * gets set in create_mntdefaults_entry.
131*0Sstevel@tonic-gate */
132*0Sstevel@tonic-gate fs_free_mntdefaults_list(headp);
133*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
134*0Sstevel@tonic-gate (void) fclose(fp);
135*0Sstevel@tonic-gate return (NULL);
136*0Sstevel@tonic-gate }
137*0Sstevel@tonic-gate
138*0Sstevel@tonic-gate if (headp == NULL) {
139*0Sstevel@tonic-gate headp = newp;
140*0Sstevel@tonic-gate tailp = newp;
141*0Sstevel@tonic-gate } else {
142*0Sstevel@tonic-gate tailp->next = newp;
143*0Sstevel@tonic-gate tailp = newp;
144*0Sstevel@tonic-gate }
145*0Sstevel@tonic-gate }
146*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
147*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
148*0Sstevel@tonic-gate (void) fclose(fp);
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate } else {
151*0Sstevel@tonic-gate *errp = errno;
152*0Sstevel@tonic-gate } /* if ((fp = fopen(VFSTAB, "r")) != NULL) */
153*0Sstevel@tonic-gate
154*0Sstevel@tonic-gate return (headp);
155*0Sstevel@tonic-gate } /* fs_get_filtered_mount_defaults */
156*0Sstevel@tonic-gate
157*0Sstevel@tonic-gate
158*0Sstevel@tonic-gate fs_mntdefaults_t *
fs_get_mount_defaults(int * errp)159*0Sstevel@tonic-gate fs_get_mount_defaults(int *errp)
160*0Sstevel@tonic-gate {
161*0Sstevel@tonic-gate fs_mntdefaults_t *newp;
162*0Sstevel@tonic-gate fs_mntdefaults_t *headp;
163*0Sstevel@tonic-gate fs_mntdefaults_t *tailp;
164*0Sstevel@tonic-gate FILE *fp;
165*0Sstevel@tonic-gate
166*0Sstevel@tonic-gate headp = NULL;
167*0Sstevel@tonic-gate tailp = NULL;
168*0Sstevel@tonic-gate
169*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) != NULL) {
170*0Sstevel@tonic-gate struct vfstab vfstab_entry;
171*0Sstevel@tonic-gate (void) mutex_lock(&vfstab_lock);
172*0Sstevel@tonic-gate while (getvfsent(fp, &vfstab_entry) == 0) {
173*0Sstevel@tonic-gate /*
174*0Sstevel@tonic-gate * Add entry to list
175*0Sstevel@tonic-gate */
176*0Sstevel@tonic-gate newp = create_mntdefaults_entry(vfstab_entry, errp);
177*0Sstevel@tonic-gate
178*0Sstevel@tonic-gate if (newp == NULL) {
179*0Sstevel@tonic-gate /*
180*0Sstevel@tonic-gate * Out of memory, the error pointer (errp)
181*0Sstevel@tonic-gate * gets set in create_mntdefaults_entry.
182*0Sstevel@tonic-gate */
183*0Sstevel@tonic-gate (void) fclose(fp);
184*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
185*0Sstevel@tonic-gate fs_free_mntdefaults_list(headp);
186*0Sstevel@tonic-gate return (NULL);
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate
189*0Sstevel@tonic-gate if (headp == NULL) {
190*0Sstevel@tonic-gate headp = newp;
191*0Sstevel@tonic-gate tailp = newp;
192*0Sstevel@tonic-gate } else {
193*0Sstevel@tonic-gate tailp->next = newp;
194*0Sstevel@tonic-gate tailp = newp;
195*0Sstevel@tonic-gate }
196*0Sstevel@tonic-gate }
197*0Sstevel@tonic-gate (void) fclose(fp);
198*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
199*0Sstevel@tonic-gate } else {
200*0Sstevel@tonic-gate *errp = errno;
201*0Sstevel@tonic-gate } /* if ((fp = fopen(VFSTAB, "r")) != NULL) */
202*0Sstevel@tonic-gate
203*0Sstevel@tonic-gate /*
204*0Sstevel@tonic-gate * Caller must free the returned list
205*0Sstevel@tonic-gate */
206*0Sstevel@tonic-gate return (headp);
207*0Sstevel@tonic-gate
208*0Sstevel@tonic-gate } /* fs_get_mount_defaults */
209*0Sstevel@tonic-gate
210*0Sstevel@tonic-gate fs_mntdefaults_t *
fs_add_mount_default(fs_mntdefaults_t * newp,int * errp)211*0Sstevel@tonic-gate fs_add_mount_default(fs_mntdefaults_t *newp, int *errp) {
212*0Sstevel@tonic-gate
213*0Sstevel@tonic-gate FILE *fp;
214*0Sstevel@tonic-gate struct vfstab *new_entry;
215*0Sstevel@tonic-gate fs_mntdefaults_t *ret_val;
216*0Sstevel@tonic-gate
217*0Sstevel@tonic-gate new_entry = create_vfstab_filter(newp, errp);
218*0Sstevel@tonic-gate if (new_entry != NULL) {
219*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "a")) != NULL) {
220*0Sstevel@tonic-gate (void) mutex_lock(&vfstab_lock);
221*0Sstevel@tonic-gate putvfsent(fp, new_entry);
222*0Sstevel@tonic-gate free_vfstab_entry(new_entry);
223*0Sstevel@tonic-gate (void) fclose(fp);
224*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
225*0Sstevel@tonic-gate ret_val = fs_get_mount_defaults(errp);
226*0Sstevel@tonic-gate } else {
227*0Sstevel@tonic-gate *errp = errno;
228*0Sstevel@tonic-gate free_vfstab_entry(new_entry);
229*0Sstevel@tonic-gate ret_val = NULL;
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate } else {
232*0Sstevel@tonic-gate ret_val = NULL;
233*0Sstevel@tonic-gate }
234*0Sstevel@tonic-gate return (ret_val);
235*0Sstevel@tonic-gate } /* fs_add_mount_default */
236*0Sstevel@tonic-gate
237*0Sstevel@tonic-gate
238*0Sstevel@tonic-gate fs_mntdefaults_t *
fs_edit_mount_defaults(fs_mntdefaults_t * old_vfstab_ent,fs_mntdefaults_t * new_vfstab_ent,int * errp)239*0Sstevel@tonic-gate fs_edit_mount_defaults(
240*0Sstevel@tonic-gate fs_mntdefaults_t *old_vfstab_ent,
241*0Sstevel@tonic-gate fs_mntdefaults_t *new_vfstab_ent,
242*0Sstevel@tonic-gate int *errp)
243*0Sstevel@tonic-gate {
244*0Sstevel@tonic-gate FILE *fp;
245*0Sstevel@tonic-gate fs_mntdefaults_t *ret_val;
246*0Sstevel@tonic-gate char vfstab_line[VFS_LINE_MAX];
247*0Sstevel@tonic-gate char **temp_vfstab = NULL;
248*0Sstevel@tonic-gate char *new_line;
249*0Sstevel@tonic-gate struct vfstab vfstabp, *new_vfstab;
250*0Sstevel@tonic-gate int line_found = 0;
251*0Sstevel@tonic-gate
252*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) != NULL) {
253*0Sstevel@tonic-gate char *tmp;
254*0Sstevel@tonic-gate int count = 0;
255*0Sstevel@tonic-gate (void) mutex_lock(&vfstab_lock);
256*0Sstevel@tonic-gate while (fgets(vfstab_line, VFS_LINE_MAX, fp) != NULL) {
257*0Sstevel@tonic-gate char *charp;
258*0Sstevel@tonic-gate struct vfstab *vp;
259*0Sstevel@tonic-gate char *orig_line = strdup(vfstab_line);
260*0Sstevel@tonic-gate if (orig_line == NULL) {
261*0Sstevel@tonic-gate *errp = ENOMEM;
262*0Sstevel@tonic-gate (void) fclose(fp);
263*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
264*0Sstevel@tonic-gate return (NULL);
265*0Sstevel@tonic-gate }
266*0Sstevel@tonic-gate vp = &vfstabp;
267*0Sstevel@tonic-gate for (charp = vfstab_line;
268*0Sstevel@tonic-gate *charp == ' ' || *charp == '\t'; charp++);
269*0Sstevel@tonic-gate if (*charp == '#' || *charp == '\n') {
270*0Sstevel@tonic-gate /*
271*0Sstevel@tonic-gate * Write comments out to temp vfstab
272*0Sstevel@tonic-gate * image
273*0Sstevel@tonic-gate */
274*0Sstevel@tonic-gate if (!fileutil_add_string_to_array(
275*0Sstevel@tonic-gate &temp_vfstab, vfstab_line, &count, errp)) {
276*0Sstevel@tonic-gate ret_val = NULL;
277*0Sstevel@tonic-gate line_found = 0;
278*0Sstevel@tonic-gate break;
279*0Sstevel@tonic-gate }
280*0Sstevel@tonic-gate continue;
281*0Sstevel@tonic-gate }
282*0Sstevel@tonic-gate vp->vfs_special = (char *)strtok_r(
283*0Sstevel@tonic-gate vfstab_line, sepstr, &tmp);
284*0Sstevel@tonic-gate vp->vfs_fsckdev = (char *)strtok_r(
285*0Sstevel@tonic-gate NULL, sepstr, &tmp);
286*0Sstevel@tonic-gate vp->vfs_mountp = (char *)strtok_r(
287*0Sstevel@tonic-gate NULL, sepstr, &tmp);
288*0Sstevel@tonic-gate vp->vfs_fstype = (char *)strtok_r(
289*0Sstevel@tonic-gate NULL, sepstr, &tmp);
290*0Sstevel@tonic-gate vp->vfs_fsckpass = (char *)strtok_r(
291*0Sstevel@tonic-gate NULL, sepstr, &tmp);
292*0Sstevel@tonic-gate vp->vfs_automnt = (char *)strtok_r(
293*0Sstevel@tonic-gate NULL, sepstr, &tmp);
294*0Sstevel@tonic-gate vp->vfs_mntopts = (char *)strtok_r(
295*0Sstevel@tonic-gate NULL, sepstr, &tmp);
296*0Sstevel@tonic-gate if (strtok_r(NULL, sepstr, &tmp) != NULL) {
297*0Sstevel@tonic-gate /*
298*0Sstevel@tonic-gate * Invalid vfstab line.
299*0Sstevel@tonic-gate */
300*0Sstevel@tonic-gate *errp = EINVAL;
301*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
302*0Sstevel@tonic-gate (void) fclose(fp);
303*0Sstevel@tonic-gate return (NULL);
304*0Sstevel@tonic-gate }
305*0Sstevel@tonic-gate
306*0Sstevel@tonic-gate if (vfstab_line_cmp(old_vfstab_ent, vp)) {
307*0Sstevel@tonic-gate line_found = 1;
308*0Sstevel@tonic-gate new_vfstab =
309*0Sstevel@tonic-gate create_vfstab_filter(
310*0Sstevel@tonic-gate new_vfstab_ent, errp);
311*0Sstevel@tonic-gate new_line =
312*0Sstevel@tonic-gate create_vfstab_entry_line(new_vfstab, errp);
313*0Sstevel@tonic-gate if (!fileutil_add_string_to_array(
314*0Sstevel@tonic-gate &temp_vfstab, new_line, &count, errp)) {
315*0Sstevel@tonic-gate ret_val = NULL;
316*0Sstevel@tonic-gate line_found = 0;
317*0Sstevel@tonic-gate free(new_line);
318*0Sstevel@tonic-gate break;
319*0Sstevel@tonic-gate }
320*0Sstevel@tonic-gate free(new_line);
321*0Sstevel@tonic-gate } else {
322*0Sstevel@tonic-gate if (!fileutil_add_string_to_array(
323*0Sstevel@tonic-gate &temp_vfstab, orig_line, &count, errp)) {
324*0Sstevel@tonic-gate ret_val = NULL;
325*0Sstevel@tonic-gate line_found = 0;
326*0Sstevel@tonic-gate break;
327*0Sstevel@tonic-gate }
328*0Sstevel@tonic-gate }
329*0Sstevel@tonic-gate free(orig_line);
330*0Sstevel@tonic-gate }
331*0Sstevel@tonic-gate (void) fclose(fp);
332*0Sstevel@tonic-gate
333*0Sstevel@tonic-gate if (line_found && temp_vfstab != NULL) {
334*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "w")) != NULL) {
335*0Sstevel@tonic-gate int i;
336*0Sstevel@tonic-gate for (i = 0; i < count; i++) {
337*0Sstevel@tonic-gate fprintf(fp, "%s", temp_vfstab[i]);
338*0Sstevel@tonic-gate }
339*0Sstevel@tonic-gate (void) fclose(fp);
340*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
341*0Sstevel@tonic-gate ret_val = fs_get_mount_defaults(errp);
342*0Sstevel@tonic-gate fileutil_free_string_array(temp_vfstab, count);
343*0Sstevel@tonic-gate } else {
344*0Sstevel@tonic-gate *errp = errno;
345*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
346*0Sstevel@tonic-gate ret_val = NULL;
347*0Sstevel@tonic-gate }
348*0Sstevel@tonic-gate } else {
349*0Sstevel@tonic-gate *errp = errno;
350*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
351*0Sstevel@tonic-gate ret_val = NULL;
352*0Sstevel@tonic-gate }
353*0Sstevel@tonic-gate } else {
354*0Sstevel@tonic-gate *errp = errno;
355*0Sstevel@tonic-gate ret_val = NULL;
356*0Sstevel@tonic-gate }
357*0Sstevel@tonic-gate return (ret_val);
358*0Sstevel@tonic-gate } /* fs_edit_mount_defaults */
359*0Sstevel@tonic-gate
360*0Sstevel@tonic-gate fs_mntdefaults_t *
fs_del_mount_default_ent(fs_mntdefaults_t * old_vfstab_ent,int * errp)361*0Sstevel@tonic-gate fs_del_mount_default_ent(fs_mntdefaults_t *old_vfstab_ent, int *errp)
362*0Sstevel@tonic-gate {
363*0Sstevel@tonic-gate FILE *fp;
364*0Sstevel@tonic-gate fs_mntdefaults_t *ret_val;
365*0Sstevel@tonic-gate char vfstab_line[VFS_LINE_MAX];
366*0Sstevel@tonic-gate struct vfstab vfstabp;
367*0Sstevel@tonic-gate int line_found = 0;
368*0Sstevel@tonic-gate
369*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) != NULL) {
370*0Sstevel@tonic-gate struct vfstab *vp;
371*0Sstevel@tonic-gate char *tmp;
372*0Sstevel@tonic-gate char *charp;
373*0Sstevel@tonic-gate char *orig_line = NULL;
374*0Sstevel@tonic-gate char **temp_vfstab = NULL;
375*0Sstevel@tonic-gate int count = 0;
376*0Sstevel@tonic-gate vp = &vfstabp;
377*0Sstevel@tonic-gate (void) mutex_lock(&vfstab_lock);
378*0Sstevel@tonic-gate while (fgets(vfstab_line, VFS_LINE_MAX, fp) != NULL) {
379*0Sstevel@tonic-gate
380*0Sstevel@tonic-gate orig_line = strdup(vfstab_line);
381*0Sstevel@tonic-gate if (orig_line == NULL) {
382*0Sstevel@tonic-gate *errp = ENOMEM;
383*0Sstevel@tonic-gate (void) fclose(fp);
384*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
385*0Sstevel@tonic-gate return (NULL);
386*0Sstevel@tonic-gate }
387*0Sstevel@tonic-gate
388*0Sstevel@tonic-gate for (charp = vfstab_line;
389*0Sstevel@tonic-gate *charp == ' ' || *charp == '\t'; charp++);
390*0Sstevel@tonic-gate
391*0Sstevel@tonic-gate if (*charp == '#' || *charp == '\n') {
392*0Sstevel@tonic-gate /*
393*0Sstevel@tonic-gate * Write comments out to temp vfstab
394*0Sstevel@tonic-gate * image
395*0Sstevel@tonic-gate */
396*0Sstevel@tonic-gate if (!fileutil_add_string_to_array(
397*0Sstevel@tonic-gate &temp_vfstab, vfstab_line, &count, errp)) {
398*0Sstevel@tonic-gate ret_val = NULL;
399*0Sstevel@tonic-gate line_found = 0;
400*0Sstevel@tonic-gate free(orig_line);
401*0Sstevel@tonic-gate break;
402*0Sstevel@tonic-gate }
403*0Sstevel@tonic-gate continue;
404*0Sstevel@tonic-gate }
405*0Sstevel@tonic-gate
406*0Sstevel@tonic-gate vp->vfs_special = (char *)strtok_r(
407*0Sstevel@tonic-gate vfstab_line, sepstr, &tmp);
408*0Sstevel@tonic-gate vp->vfs_fsckdev = (char *)strtok_r(
409*0Sstevel@tonic-gate NULL, sepstr, &tmp);
410*0Sstevel@tonic-gate vp->vfs_mountp = (char *)strtok_r(
411*0Sstevel@tonic-gate NULL, sepstr, &tmp);
412*0Sstevel@tonic-gate vp->vfs_fstype = (char *)strtok_r(
413*0Sstevel@tonic-gate NULL, sepstr, &tmp);
414*0Sstevel@tonic-gate vp->vfs_fsckpass = (char *)strtok_r(
415*0Sstevel@tonic-gate NULL, sepstr, &tmp);
416*0Sstevel@tonic-gate vp->vfs_automnt = (char *)strtok_r(
417*0Sstevel@tonic-gate NULL, sepstr, &tmp);
418*0Sstevel@tonic-gate vp->vfs_mntopts = (char *)strtok_r(
419*0Sstevel@tonic-gate NULL, sepstr, &tmp);
420*0Sstevel@tonic-gate
421*0Sstevel@tonic-gate if (strtok_r(NULL, sepstr, &tmp) != NULL) {
422*0Sstevel@tonic-gate /*
423*0Sstevel@tonic-gate * Invalid vfstab line.
424*0Sstevel@tonic-gate */
425*0Sstevel@tonic-gate *errp = EINVAL;
426*0Sstevel@tonic-gate free(orig_line);
427*0Sstevel@tonic-gate (void) fclose(fp);
428*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
429*0Sstevel@tonic-gate return (NULL);
430*0Sstevel@tonic-gate }
431*0Sstevel@tonic-gate
432*0Sstevel@tonic-gate if (vfstab_line_cmp(old_vfstab_ent, vp)) {
433*0Sstevel@tonic-gate line_found = 1;
434*0Sstevel@tonic-gate } else {
435*0Sstevel@tonic-gate if (!fileutil_add_string_to_array(
436*0Sstevel@tonic-gate &temp_vfstab, orig_line, &count, errp)) {
437*0Sstevel@tonic-gate ret_val = NULL;
438*0Sstevel@tonic-gate line_found = 0;
439*0Sstevel@tonic-gate free(orig_line);
440*0Sstevel@tonic-gate break;
441*0Sstevel@tonic-gate }
442*0Sstevel@tonic-gate }
443*0Sstevel@tonic-gate free(orig_line);
444*0Sstevel@tonic-gate }
445*0Sstevel@tonic-gate
446*0Sstevel@tonic-gate (void) fclose(fp);
447*0Sstevel@tonic-gate
448*0Sstevel@tonic-gate if (line_found && temp_vfstab != NULL) {
449*0Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "w")) != NULL) {
450*0Sstevel@tonic-gate int i;
451*0Sstevel@tonic-gate for (i = 0; i < count; i++) {
452*0Sstevel@tonic-gate fprintf(fp, "%s", temp_vfstab[i]);
453*0Sstevel@tonic-gate }
454*0Sstevel@tonic-gate (void) fclose(fp);
455*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
456*0Sstevel@tonic-gate ret_val = fs_get_mount_defaults(errp);
457*0Sstevel@tonic-gate fileutil_free_string_array(temp_vfstab, count);
458*0Sstevel@tonic-gate } else {
459*0Sstevel@tonic-gate *errp = errno;
460*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
461*0Sstevel@tonic-gate fileutil_free_string_array(temp_vfstab, count);
462*0Sstevel@tonic-gate ret_val = NULL;
463*0Sstevel@tonic-gate }
464*0Sstevel@tonic-gate } else {
465*0Sstevel@tonic-gate (void) mutex_unlock(&vfstab_lock);
466*0Sstevel@tonic-gate if (temp_vfstab != NULL) {
467*0Sstevel@tonic-gate fileutil_free_string_array(temp_vfstab, count);
468*0Sstevel@tonic-gate }
469*0Sstevel@tonic-gate ret_val = NULL;
470*0Sstevel@tonic-gate }
471*0Sstevel@tonic-gate } else {
472*0Sstevel@tonic-gate *errp = errno;
473*0Sstevel@tonic-gate ret_val = NULL;
474*0Sstevel@tonic-gate }
475*0Sstevel@tonic-gate return (ret_val);
476*0Sstevel@tonic-gate }
477*0Sstevel@tonic-gate
478*0Sstevel@tonic-gate /*
479*0Sstevel@tonic-gate * Private methods
480*0Sstevel@tonic-gate */
481*0Sstevel@tonic-gate
482*0Sstevel@tonic-gate static fs_mntdefaults_t *
create_mntdefaults_entry(struct vfstab vfstab_entry,int * errp)483*0Sstevel@tonic-gate create_mntdefaults_entry(struct vfstab vfstab_entry, int *errp) {
484*0Sstevel@tonic-gate fs_mntdefaults_t *newp;
485*0Sstevel@tonic-gate
486*0Sstevel@tonic-gate newp = (fs_mntdefaults_t *)calloc((size_t)1,
487*0Sstevel@tonic-gate (size_t)sizeof (fs_mntdefaults_t));
488*0Sstevel@tonic-gate
489*0Sstevel@tonic-gate if (newp == NULL) {
490*0Sstevel@tonic-gate /*
491*0Sstevel@tonic-gate * Out of memory
492*0Sstevel@tonic-gate */
493*0Sstevel@tonic-gate *errp = errno;
494*0Sstevel@tonic-gate return (NULL);
495*0Sstevel@tonic-gate }
496*0Sstevel@tonic-gate
497*0Sstevel@tonic-gate
498*0Sstevel@tonic-gate if (vfstab_entry.vfs_special != NULL) {
499*0Sstevel@tonic-gate newp->resource = strdup(vfstab_entry.vfs_special);
500*0Sstevel@tonic-gate if (newp->resource == NULL) {
501*0Sstevel@tonic-gate /*
502*0Sstevel@tonic-gate * Out of memory
503*0Sstevel@tonic-gate */
504*0Sstevel@tonic-gate *errp = errno;
505*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
506*0Sstevel@tonic-gate return (NULL);
507*0Sstevel@tonic-gate }
508*0Sstevel@tonic-gate }
509*0Sstevel@tonic-gate
510*0Sstevel@tonic-gate
511*0Sstevel@tonic-gate if (vfstab_entry.vfs_fsckdev != NULL) {
512*0Sstevel@tonic-gate newp->fsckdevice = strdup(vfstab_entry.vfs_fsckdev);
513*0Sstevel@tonic-gate if (newp->fsckdevice == NULL) {
514*0Sstevel@tonic-gate /*
515*0Sstevel@tonic-gate * Out of memory
516*0Sstevel@tonic-gate */
517*0Sstevel@tonic-gate *errp = errno;
518*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
519*0Sstevel@tonic-gate return (NULL);
520*0Sstevel@tonic-gate }
521*0Sstevel@tonic-gate }
522*0Sstevel@tonic-gate
523*0Sstevel@tonic-gate if (vfstab_entry.vfs_mountp != NULL) {
524*0Sstevel@tonic-gate newp->mountp = strdup(vfstab_entry.vfs_mountp);
525*0Sstevel@tonic-gate if (newp->mountp == NULL) {
526*0Sstevel@tonic-gate /*
527*0Sstevel@tonic-gate * Out of memory
528*0Sstevel@tonic-gate */
529*0Sstevel@tonic-gate *errp = errno;
530*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
531*0Sstevel@tonic-gate return (NULL);
532*0Sstevel@tonic-gate }
533*0Sstevel@tonic-gate }
534*0Sstevel@tonic-gate
535*0Sstevel@tonic-gate if (vfstab_entry.vfs_fstype != NULL) {
536*0Sstevel@tonic-gate newp->fstype = strdup(vfstab_entry.vfs_fstype);
537*0Sstevel@tonic-gate if (newp->fstype == NULL) {
538*0Sstevel@tonic-gate /*
539*0Sstevel@tonic-gate * Out of memory
540*0Sstevel@tonic-gate */
541*0Sstevel@tonic-gate *errp = errno;
542*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
543*0Sstevel@tonic-gate return (NULL);
544*0Sstevel@tonic-gate }
545*0Sstevel@tonic-gate }
546*0Sstevel@tonic-gate
547*0Sstevel@tonic-gate if (vfstab_entry.vfs_fsckpass != NULL) {
548*0Sstevel@tonic-gate newp->fsckpass = strdup(vfstab_entry.vfs_fsckpass);
549*0Sstevel@tonic-gate if (newp->fsckpass == NULL) {
550*0Sstevel@tonic-gate /*
551*0Sstevel@tonic-gate * Out of memory
552*0Sstevel@tonic-gate */
553*0Sstevel@tonic-gate *errp = errno;
554*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
555*0Sstevel@tonic-gate return (NULL);
556*0Sstevel@tonic-gate }
557*0Sstevel@tonic-gate }
558*0Sstevel@tonic-gate
559*0Sstevel@tonic-gate if (vfstab_entry.vfs_automnt != NULL) {
560*0Sstevel@tonic-gate newp->mountatboot = strdup(vfstab_entry.vfs_automnt);
561*0Sstevel@tonic-gate if (newp->mountatboot == NULL) {
562*0Sstevel@tonic-gate /*
563*0Sstevel@tonic-gate * Out of memory
564*0Sstevel@tonic-gate */
565*0Sstevel@tonic-gate *errp = errno;
566*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
567*0Sstevel@tonic-gate return (NULL);
568*0Sstevel@tonic-gate }
569*0Sstevel@tonic-gate }
570*0Sstevel@tonic-gate
571*0Sstevel@tonic-gate if (vfstab_entry.vfs_mntopts != NULL) {
572*0Sstevel@tonic-gate newp->mntopts = strdup(vfstab_entry.vfs_mntopts);
573*0Sstevel@tonic-gate if (newp->mntopts == NULL) {
574*0Sstevel@tonic-gate /*
575*0Sstevel@tonic-gate * Out of memory
576*0Sstevel@tonic-gate */
577*0Sstevel@tonic-gate *errp = errno;
578*0Sstevel@tonic-gate fs_free_mntdefaults_list(newp);
579*0Sstevel@tonic-gate return (NULL);
580*0Sstevel@tonic-gate }
581*0Sstevel@tonic-gate }
582*0Sstevel@tonic-gate newp->next = NULL;
583*0Sstevel@tonic-gate
584*0Sstevel@tonic-gate return (newp);
585*0Sstevel@tonic-gate
586*0Sstevel@tonic-gate } /* create_mntdefaults_entry */
587*0Sstevel@tonic-gate
588*0Sstevel@tonic-gate static struct vfstab *
create_vfstab_filter(fs_mntdefaults_t * filter,int * errp)589*0Sstevel@tonic-gate create_vfstab_filter(fs_mntdefaults_t *filter, int *errp) {
590*0Sstevel@tonic-gate struct vfstab *search_entry;
591*0Sstevel@tonic-gate
592*0Sstevel@tonic-gate search_entry = (struct vfstab *)calloc((size_t)1,
593*0Sstevel@tonic-gate (size_t)sizeof (struct vfstab));
594*0Sstevel@tonic-gate if (search_entry == NULL) {
595*0Sstevel@tonic-gate /*
596*0Sstevel@tonic-gate * Out of memory
597*0Sstevel@tonic-gate */
598*0Sstevel@tonic-gate *errp = errno;
599*0Sstevel@tonic-gate return (NULL);
600*0Sstevel@tonic-gate }
601*0Sstevel@tonic-gate
602*0Sstevel@tonic-gate /*
603*0Sstevel@tonic-gate * Populate the filter criteria
604*0Sstevel@tonic-gate */
605*0Sstevel@tonic-gate if (filter->resource != NULL) {
606*0Sstevel@tonic-gate search_entry->vfs_special = strdup(filter->resource);
607*0Sstevel@tonic-gate if (search_entry->vfs_special == NULL) {
608*0Sstevel@tonic-gate /*
609*0Sstevel@tonic-gate * Out of memory
610*0Sstevel@tonic-gate */
611*0Sstevel@tonic-gate *errp = errno;
612*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
613*0Sstevel@tonic-gate return (NULL);
614*0Sstevel@tonic-gate }
615*0Sstevel@tonic-gate
616*0Sstevel@tonic-gate }
617*0Sstevel@tonic-gate
618*0Sstevel@tonic-gate if (filter->fsckdevice != NULL) {
619*0Sstevel@tonic-gate search_entry->vfs_fsckdev = strdup(filter->fsckdevice);
620*0Sstevel@tonic-gate if (search_entry->vfs_fsckdev == NULL) {
621*0Sstevel@tonic-gate /*
622*0Sstevel@tonic-gate * Out of memory
623*0Sstevel@tonic-gate */
624*0Sstevel@tonic-gate *errp = errno;
625*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
626*0Sstevel@tonic-gate return (NULL);
627*0Sstevel@tonic-gate }
628*0Sstevel@tonic-gate }
629*0Sstevel@tonic-gate
630*0Sstevel@tonic-gate if (filter->mountp != NULL) {
631*0Sstevel@tonic-gate search_entry->vfs_mountp = strdup(filter->mountp);
632*0Sstevel@tonic-gate if (search_entry->vfs_mountp == NULL) {
633*0Sstevel@tonic-gate /*
634*0Sstevel@tonic-gate * Out of memory
635*0Sstevel@tonic-gate */
636*0Sstevel@tonic-gate *errp = errno;
637*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
638*0Sstevel@tonic-gate return (NULL);
639*0Sstevel@tonic-gate }
640*0Sstevel@tonic-gate }
641*0Sstevel@tonic-gate
642*0Sstevel@tonic-gate if (filter->fstype != NULL) {
643*0Sstevel@tonic-gate search_entry->vfs_fstype = strdup(filter->fstype);
644*0Sstevel@tonic-gate if (search_entry->vfs_fstype == NULL) {
645*0Sstevel@tonic-gate /*
646*0Sstevel@tonic-gate * Out of memory
647*0Sstevel@tonic-gate */
648*0Sstevel@tonic-gate *errp = errno;
649*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
650*0Sstevel@tonic-gate return (NULL);
651*0Sstevel@tonic-gate }
652*0Sstevel@tonic-gate }
653*0Sstevel@tonic-gate
654*0Sstevel@tonic-gate if (filter->fsckpass != NULL) {
655*0Sstevel@tonic-gate search_entry->vfs_fsckpass = strdup(filter->fsckpass);
656*0Sstevel@tonic-gate if (search_entry->vfs_fsckpass == NULL) {
657*0Sstevel@tonic-gate /*
658*0Sstevel@tonic-gate * Out of memory
659*0Sstevel@tonic-gate */
660*0Sstevel@tonic-gate *errp = errno;
661*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
662*0Sstevel@tonic-gate return (NULL);
663*0Sstevel@tonic-gate }
664*0Sstevel@tonic-gate }
665*0Sstevel@tonic-gate
666*0Sstevel@tonic-gate if (filter->mountatboot != NULL) {
667*0Sstevel@tonic-gate search_entry->vfs_automnt = strdup(filter->mountatboot);
668*0Sstevel@tonic-gate if (search_entry->vfs_automnt == NULL) {
669*0Sstevel@tonic-gate /*
670*0Sstevel@tonic-gate * Out of memory
671*0Sstevel@tonic-gate */
672*0Sstevel@tonic-gate *errp = errno;
673*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
674*0Sstevel@tonic-gate return (NULL);
675*0Sstevel@tonic-gate }
676*0Sstevel@tonic-gate }
677*0Sstevel@tonic-gate
678*0Sstevel@tonic-gate if (filter->mntopts != NULL) {
679*0Sstevel@tonic-gate search_entry->vfs_mntopts = strdup(filter->mntopts);
680*0Sstevel@tonic-gate if (search_entry->vfs_mntopts == NULL) {
681*0Sstevel@tonic-gate /*
682*0Sstevel@tonic-gate * Out of memory
683*0Sstevel@tonic-gate */
684*0Sstevel@tonic-gate *errp = errno;
685*0Sstevel@tonic-gate free_vfstab_entry(search_entry);
686*0Sstevel@tonic-gate return (NULL);
687*0Sstevel@tonic-gate }
688*0Sstevel@tonic-gate }
689*0Sstevel@tonic-gate
690*0Sstevel@tonic-gate return (search_entry);
691*0Sstevel@tonic-gate } /* create_vfstab_filter */
692*0Sstevel@tonic-gate
free_vfstab_entry(struct vfstab * vfstab_entry)693*0Sstevel@tonic-gate static void free_vfstab_entry(struct vfstab *vfstab_entry) {
694*0Sstevel@tonic-gate
695*0Sstevel@tonic-gate free(vfstab_entry->vfs_special);
696*0Sstevel@tonic-gate free(vfstab_entry->vfs_fsckdev);
697*0Sstevel@tonic-gate free(vfstab_entry->vfs_mountp);
698*0Sstevel@tonic-gate free(vfstab_entry->vfs_fstype);
699*0Sstevel@tonic-gate free(vfstab_entry->vfs_fsckpass);
700*0Sstevel@tonic-gate free(vfstab_entry->vfs_automnt);
701*0Sstevel@tonic-gate free(vfstab_entry->vfs_mntopts);
702*0Sstevel@tonic-gate
703*0Sstevel@tonic-gate free(vfstab_entry);
704*0Sstevel@tonic-gate } /* free_vfstab_entry */
705*0Sstevel@tonic-gate
706*0Sstevel@tonic-gate static int
vfstab_line_cmp(fs_mntdefaults_t * mntdftp,struct vfstab * vp)707*0Sstevel@tonic-gate vfstab_line_cmp(fs_mntdefaults_t *mntdftp, struct vfstab *vp) {
708*0Sstevel@tonic-gate
709*0Sstevel@tonic-gate int ret_val = 1;
710*0Sstevel@tonic-gate
711*0Sstevel@tonic-gate ret_val = cmp_fields(mntdftp->resource, vp->vfs_special, ret_val);
712*0Sstevel@tonic-gate ret_val = cmp_fields(mntdftp->mountp, vp->vfs_mountp, ret_val);
713*0Sstevel@tonic-gate
714*0Sstevel@tonic-gate return (ret_val);
715*0Sstevel@tonic-gate } /* vfstab_line_cmp */
716*0Sstevel@tonic-gate
717*0Sstevel@tonic-gate /*
718*0Sstevel@tonic-gate * Helper function for comparing fields in a fs_mntdefaults_t to a
719*0Sstevel@tonic-gate * vfstab structure. Used in vfstab_line_cmp().
720*0Sstevel@tonic-gate */
721*0Sstevel@tonic-gate static int
cmp_fields(char * mntdflt_str,char * vfstab_str,int ret_val)722*0Sstevel@tonic-gate cmp_fields(char *mntdflt_str, char *vfstab_str, int ret_val) {
723*0Sstevel@tonic-gate if (ret_val != 0) {
724*0Sstevel@tonic-gate if (mntdflt_str != NULL && vfstab_str != NULL) {
725*0Sstevel@tonic-gate if (strcmp(mntdflt_str, vfstab_str) != 0) {
726*0Sstevel@tonic-gate ret_val = 0;
727*0Sstevel@tonic-gate }
728*0Sstevel@tonic-gate } else if (mntdflt_str == NULL || vfstab_str == NULL) {
729*0Sstevel@tonic-gate ret_val = 0;
730*0Sstevel@tonic-gate }
731*0Sstevel@tonic-gate }
732*0Sstevel@tonic-gate return (ret_val);
733*0Sstevel@tonic-gate } /* cmp_fields */
734*0Sstevel@tonic-gate
735*0Sstevel@tonic-gate /*
736*0Sstevel@tonic-gate * Helper fuction used by del_vfstab_ent() and edit_vfstab_ent() to
737*0Sstevel@tonic-gate * create a vfstab line for writing out to the vfstab file.
738*0Sstevel@tonic-gate */
739*0Sstevel@tonic-gate char *
create_vfstab_entry_line(struct vfstab * vfstab_ent,int * errp)740*0Sstevel@tonic-gate create_vfstab_entry_line(struct vfstab *vfstab_ent, int *errp) {
741*0Sstevel@tonic-gate char *line;
742*0Sstevel@tonic-gate int line_length;
743*0Sstevel@tonic-gate line_length = (
744*0Sstevel@tonic-gate (vfstab_ent->vfs_special ?
745*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_special) +1) : 2) +
746*0Sstevel@tonic-gate (vfstab_ent->vfs_fsckdev ?
747*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_fsckdev) +1) : 2) +
748*0Sstevel@tonic-gate (vfstab_ent->vfs_mountp ?
749*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_mountp) +1) : 2) +
750*0Sstevel@tonic-gate (vfstab_ent->vfs_fstype ?
751*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_fstype) +1) : 2) +
752*0Sstevel@tonic-gate (vfstab_ent->vfs_fsckpass ?
753*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_fsckpass) +1) : 2) +
754*0Sstevel@tonic-gate (vfstab_ent->vfs_automnt ?
755*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_automnt) +1) : 2) +
756*0Sstevel@tonic-gate (vfstab_ent->vfs_mntopts ?
757*0Sstevel@tonic-gate (strlen(vfstab_ent->vfs_mntopts) +1) : 2));
758*0Sstevel@tonic-gate line = (char *)malloc(line_length + 1);
759*0Sstevel@tonic-gate if (line != NULL) {
760*0Sstevel@tonic-gate sprintf(line, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
761*0Sstevel@tonic-gate vfstab_ent->vfs_special ? vfstab_ent->vfs_special : "-",
762*0Sstevel@tonic-gate vfstab_ent->vfs_fsckdev ? vfstab_ent->vfs_fsckdev : "-",
763*0Sstevel@tonic-gate vfstab_ent->vfs_mountp ? vfstab_ent->vfs_mountp : "-",
764*0Sstevel@tonic-gate vfstab_ent->vfs_fstype ? vfstab_ent->vfs_fstype : "-",
765*0Sstevel@tonic-gate vfstab_ent->vfs_fsckpass ? vfstab_ent->vfs_fsckpass : "-",
766*0Sstevel@tonic-gate vfstab_ent->vfs_automnt ? vfstab_ent->vfs_automnt : "-",
767*0Sstevel@tonic-gate vfstab_ent->vfs_mntopts ? vfstab_ent->vfs_mntopts : "-");
768*0Sstevel@tonic-gate } else {
769*0Sstevel@tonic-gate *errp = errno;
770*0Sstevel@tonic-gate }
771*0Sstevel@tonic-gate return (line);
772*0Sstevel@tonic-gate } /* create_vfstab_entry_line */
773