1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <stdio.h> 30*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 31*7c478bd9Sstevel@tonic-gate #include <errno.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 33*7c478bd9Sstevel@tonic-gate #include <ctype.h> 34*7c478bd9Sstevel@tonic-gate #include <string.h> 35*7c478bd9Sstevel@tonic-gate #include <strings.h> 36*7c478bd9Sstevel@tonic-gate #include <thread.h> 37*7c478bd9Sstevel@tonic-gate #include <synch.h> 38*7c478bd9Sstevel@tonic-gate #include "libfsmgt.h" 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* 41*7c478bd9Sstevel@tonic-gate * Private datastructures. 42*7c478bd9Sstevel@tonic-gate */ 43*7c478bd9Sstevel@tonic-gate typedef struct dfstab_entry { 44*7c478bd9Sstevel@tonic-gate struct dfstab_entry *next; 45*7c478bd9Sstevel@tonic-gate char *path; 46*7c478bd9Sstevel@tonic-gate char *resource; 47*7c478bd9Sstevel@tonic-gate char *fstype; 48*7c478bd9Sstevel@tonic-gate char *options; 49*7c478bd9Sstevel@tonic-gate char *description; 50*7c478bd9Sstevel@tonic-gate } dfstab_entry_t; 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate static const char *whitespace = " \t"; 53*7c478bd9Sstevel@tonic-gate static mutex_t dfstab_lock = DEFAULTMUTEX; 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * Private functions 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate static dfstab_entry_t *get_dfstab_ents(int *); 59*7c478bd9Sstevel@tonic-gate static void free_dfstab_list(dfstab_entry_t *); 60*7c478bd9Sstevel@tonic-gate static dfstab_entry_t *dfstab_line_to_dfstab_entry(char *, int *); 61*7c478bd9Sstevel@tonic-gate static char *create_share_cmd(dfstab_entry_t *, char *, int *); 62*7c478bd9Sstevel@tonic-gate static dfstab_entry_t *change_dfstab_ent(dfstab_entry_t *, 63*7c478bd9Sstevel@tonic-gate dfstab_entry_t *, int *); 64*7c478bd9Sstevel@tonic-gate static void add_entry_to_dfstab(dfstab_entry_t *, int *); 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate static dfstab_entry_t * 68*7c478bd9Sstevel@tonic-gate get_dfstab_ents(int *err) 69*7c478bd9Sstevel@tonic-gate { 70*7c478bd9Sstevel@tonic-gate dfstab_entry_t *dfstablist, *headptr, *tailptr = NULL; 71*7c478bd9Sstevel@tonic-gate FILE *dfp; /* fp for dfs list */ 72*7c478bd9Sstevel@tonic-gate static char cmd[BUFSIZE]; 73*7c478bd9Sstevel@tonic-gate *err = 0; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate if ((dfp = fopen(DFSTAB, "r")) != NULL) { 76*7c478bd9Sstevel@tonic-gate char *share_cmd; 77*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&dfstab_lock); 78*7c478bd9Sstevel@tonic-gate while ((share_cmd = 79*7c478bd9Sstevel@tonic-gate fileutil_getline(dfp, cmd, BUFSIZE)) != NULL) { 80*7c478bd9Sstevel@tonic-gate if ((dfstablist = 81*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(share_cmd, err)) != 82*7c478bd9Sstevel@tonic-gate NULL) { 83*7c478bd9Sstevel@tonic-gate if (tailptr == NULL) { 84*7c478bd9Sstevel@tonic-gate headptr = dfstablist; 85*7c478bd9Sstevel@tonic-gate tailptr = dfstablist; 86*7c478bd9Sstevel@tonic-gate } else { 87*7c478bd9Sstevel@tonic-gate tailptr->next = dfstablist; 88*7c478bd9Sstevel@tonic-gate tailptr = dfstablist; 89*7c478bd9Sstevel@tonic-gate } 90*7c478bd9Sstevel@tonic-gate dfstablist = dfstablist->next; 91*7c478bd9Sstevel@tonic-gate } else { 92*7c478bd9Sstevel@tonic-gate free(share_cmd); 93*7c478bd9Sstevel@tonic-gate break; 94*7c478bd9Sstevel@tonic-gate } 95*7c478bd9Sstevel@tonic-gate free(share_cmd); 96*7c478bd9Sstevel@tonic-gate } 97*7c478bd9Sstevel@tonic-gate if (tailptr == NULL) { 98*7c478bd9Sstevel@tonic-gate headptr = tailptr; 99*7c478bd9Sstevel@tonic-gate } 100*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 101*7c478bd9Sstevel@tonic-gate fclose(dfp); 102*7c478bd9Sstevel@tonic-gate } else { 103*7c478bd9Sstevel@tonic-gate *err = errno; 104*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot open %s\n", cmd, DFSTAB); 105*7c478bd9Sstevel@tonic-gate headptr = NULL; 106*7c478bd9Sstevel@tonic-gate } 107*7c478bd9Sstevel@tonic-gate return (headptr); 108*7c478bd9Sstevel@tonic-gate } /* get_dfstab_ents */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate static void 111*7c478bd9Sstevel@tonic-gate add_entry_to_dfstab(dfstab_entry_t *list, int *err) 112*7c478bd9Sstevel@tonic-gate { 113*7c478bd9Sstevel@tonic-gate FILE *dfp; /* fp for dfs list */ 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate if ((dfp = fopen(DFSTAB, "a")) != NULL) { 116*7c478bd9Sstevel@tonic-gate char *share_cmd; 117*7c478bd9Sstevel@tonic-gate if ((share_cmd = create_share_cmd(list, NULL, err)) != NULL) { 118*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&dfstab_lock); 119*7c478bd9Sstevel@tonic-gate fprintf(dfp, "%s", share_cmd); 120*7c478bd9Sstevel@tonic-gate fclose(dfp); 121*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 122*7c478bd9Sstevel@tonic-gate free(share_cmd); 123*7c478bd9Sstevel@tonic-gate } else { 124*7c478bd9Sstevel@tonic-gate *err = errno; 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate } else { 127*7c478bd9Sstevel@tonic-gate *err = errno; 128*7c478bd9Sstevel@tonic-gate } 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate } /* add_entry_to_dfstab */ 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate static void 133*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstab_entry_t *headp) 134*7c478bd9Sstevel@tonic-gate { 135*7c478bd9Sstevel@tonic-gate dfstab_entry_t *tmp = headp; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate while (headp != NULL) { 138*7c478bd9Sstevel@tonic-gate tmp = headp->next; 139*7c478bd9Sstevel@tonic-gate if (headp->path != NULL) { 140*7c478bd9Sstevel@tonic-gate free(headp->path); 141*7c478bd9Sstevel@tonic-gate } 142*7c478bd9Sstevel@tonic-gate if (headp->resource != NULL) { 143*7c478bd9Sstevel@tonic-gate free(headp->resource); 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate if (headp->fstype != NULL) { 146*7c478bd9Sstevel@tonic-gate free(headp->fstype); 147*7c478bd9Sstevel@tonic-gate } 148*7c478bd9Sstevel@tonic-gate if (headp->options != NULL) { 149*7c478bd9Sstevel@tonic-gate free(headp->options); 150*7c478bd9Sstevel@tonic-gate } 151*7c478bd9Sstevel@tonic-gate if (headp->description != NULL) { 152*7c478bd9Sstevel@tonic-gate free(headp->description); 153*7c478bd9Sstevel@tonic-gate } 154*7c478bd9Sstevel@tonic-gate headp->next = NULL; 155*7c478bd9Sstevel@tonic-gate free(headp); 156*7c478bd9Sstevel@tonic-gate headp = tmp; 157*7c478bd9Sstevel@tonic-gate } 158*7c478bd9Sstevel@tonic-gate } /* free_dfstab_list */ 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate static char * 161*7c478bd9Sstevel@tonic-gate create_share_cmd(dfstab_entry_t *new_entry, char *temp_line, int *err) 162*7c478bd9Sstevel@tonic-gate { 163*7c478bd9Sstevel@tonic-gate char tempstr[BUFSIZE]; 164*7c478bd9Sstevel@tonic-gate char *cmd, *ret_val; 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate cmd = (char *)calloc((size_t)1, BUFSIZE); 167*7c478bd9Sstevel@tonic-gate if (cmd == NULL) { 168*7c478bd9Sstevel@tonic-gate *err = errno; 169*7c478bd9Sstevel@tonic-gate return (NULL); 170*7c478bd9Sstevel@tonic-gate } 171*7c478bd9Sstevel@tonic-gate sprintf(cmd, "share "); 172*7c478bd9Sstevel@tonic-gate if (new_entry->fstype) { 173*7c478bd9Sstevel@tonic-gate sprintf(tempstr, "-F %s ", new_entry->fstype); 174*7c478bd9Sstevel@tonic-gate strlcat(cmd, tempstr, BUFSIZE); 175*7c478bd9Sstevel@tonic-gate } 176*7c478bd9Sstevel@tonic-gate if (new_entry->options) { 177*7c478bd9Sstevel@tonic-gate sprintf(tempstr, "-o %s ", new_entry->options); 178*7c478bd9Sstevel@tonic-gate strlcat(cmd, tempstr, BUFSIZE); 179*7c478bd9Sstevel@tonic-gate } 180*7c478bd9Sstevel@tonic-gate if (new_entry->description) { 181*7c478bd9Sstevel@tonic-gate sprintf(tempstr, "-d %s ", 182*7c478bd9Sstevel@tonic-gate new_entry->description); 183*7c478bd9Sstevel@tonic-gate strlcat(cmd, tempstr, BUFSIZE); 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate sprintf(tempstr, "%s\n", new_entry->path); 186*7c478bd9Sstevel@tonic-gate strlcat(cmd, tempstr, BUFSIZE); 187*7c478bd9Sstevel@tonic-gate if (temp_line != NULL && strchr(temp_line, '#')) { 188*7c478bd9Sstevel@tonic-gate sprintf(tempstr, " %s", strchr(temp_line, '#')); 189*7c478bd9Sstevel@tonic-gate strlcat(cmd, tempstr, BUFSIZE); 190*7c478bd9Sstevel@tonic-gate } 191*7c478bd9Sstevel@tonic-gate ret_val = strdup(cmd); 192*7c478bd9Sstevel@tonic-gate free(cmd); 193*7c478bd9Sstevel@tonic-gate return (ret_val); 194*7c478bd9Sstevel@tonic-gate } /* create_share_cmd */ 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate /* 197*7c478bd9Sstevel@tonic-gate * dfstab_line_to_dfstab_entry - parses a line from dfstab and fills in 198*7c478bd9Sstevel@tonic-gate * the fields of a dfstab_entry_t structure 199*7c478bd9Sstevel@tonic-gate * Parameters: 200*7c478bd9Sstevel@tonic-gate * char *cmd - the share command or dfstab line to be parsed 201*7c478bd9Sstevel@tonic-gate * int *err - a pointer for returning any error codes encountered 202*7c478bd9Sstevel@tonic-gate */ 203*7c478bd9Sstevel@tonic-gate static dfstab_entry_t * 204*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(char *cmd, int *err) 205*7c478bd9Sstevel@tonic-gate { 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate dfstab_entry_t *dfstablist; 208*7c478bd9Sstevel@tonic-gate extern char *optarg; 209*7c478bd9Sstevel@tonic-gate extern int optind; 210*7c478bd9Sstevel@tonic-gate int c, argcount = 0; 211*7c478bd9Sstevel@tonic-gate char *temp_str; 212*7c478bd9Sstevel@tonic-gate char *arglist[LINESZ]; 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate c = 0; 215*7c478bd9Sstevel@tonic-gate optind = 1; 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate temp_str = strdup(cmd); 218*7c478bd9Sstevel@tonic-gate if (temp_str == NULL) { 219*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 220*7c478bd9Sstevel@tonic-gate return (NULL); 221*7c478bd9Sstevel@tonic-gate } 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate for (arglist[argcount] = strtok(temp_str, whitespace); 224*7c478bd9Sstevel@tonic-gate arglist[argcount] != NULL; /* CSTYLED */) { 225*7c478bd9Sstevel@tonic-gate arglist[++argcount] = strtok(NULL, whitespace); 226*7c478bd9Sstevel@tonic-gate } 227*7c478bd9Sstevel@tonic-gate argcount--; 228*7c478bd9Sstevel@tonic-gate dfstablist = 229*7c478bd9Sstevel@tonic-gate (dfstab_entry_t *)calloc((size_t)1, 230*7c478bd9Sstevel@tonic-gate sizeof (dfstab_entry_t)); 231*7c478bd9Sstevel@tonic-gate if (dfstablist == NULL) { 232*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 233*7c478bd9Sstevel@tonic-gate free(temp_str); 234*7c478bd9Sstevel@tonic-gate return (NULL); 235*7c478bd9Sstevel@tonic-gate } 236*7c478bd9Sstevel@tonic-gate while ((c = getopt(argcount, arglist, "F:d:o:")) != -1) { 237*7c478bd9Sstevel@tonic-gate switch (c) { 238*7c478bd9Sstevel@tonic-gate case 'F': 239*7c478bd9Sstevel@tonic-gate /* file system type */ 240*7c478bd9Sstevel@tonic-gate /* at most one -F */ 241*7c478bd9Sstevel@tonic-gate *err |= (dfstablist->fstype != NULL); 242*7c478bd9Sstevel@tonic-gate dfstablist->fstype = strdup(optarg); 243*7c478bd9Sstevel@tonic-gate if (dfstablist->fstype == NULL) { 244*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 245*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 246*7c478bd9Sstevel@tonic-gate free(temp_str); 247*7c478bd9Sstevel@tonic-gate return (NULL); 248*7c478bd9Sstevel@tonic-gate } 249*7c478bd9Sstevel@tonic-gate break; 250*7c478bd9Sstevel@tonic-gate case 'd': /* description */ 251*7c478bd9Sstevel@tonic-gate /* at most one -d */ 252*7c478bd9Sstevel@tonic-gate *err |= (dfstablist->description != NULL); 253*7c478bd9Sstevel@tonic-gate dfstablist->description = strdup(optarg); 254*7c478bd9Sstevel@tonic-gate if (dfstablist->description == NULL) { 255*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 256*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 257*7c478bd9Sstevel@tonic-gate free(temp_str); 258*7c478bd9Sstevel@tonic-gate return (NULL); 259*7c478bd9Sstevel@tonic-gate } 260*7c478bd9Sstevel@tonic-gate break; 261*7c478bd9Sstevel@tonic-gate case 'o': /* fs specific options */ 262*7c478bd9Sstevel@tonic-gate /* at most one - o */ 263*7c478bd9Sstevel@tonic-gate *err |= (dfstablist->options != NULL); 264*7c478bd9Sstevel@tonic-gate dfstablist->options = strdup(optarg); 265*7c478bd9Sstevel@tonic-gate if (dfstablist->options == NULL) { 266*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 267*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 268*7c478bd9Sstevel@tonic-gate free(temp_str); 269*7c478bd9Sstevel@tonic-gate return (NULL); 270*7c478bd9Sstevel@tonic-gate } 271*7c478bd9Sstevel@tonic-gate break; 272*7c478bd9Sstevel@tonic-gate case '?': 273*7c478bd9Sstevel@tonic-gate *err = 1; 274*7c478bd9Sstevel@tonic-gate break; 275*7c478bd9Sstevel@tonic-gate } 276*7c478bd9Sstevel@tonic-gate } 277*7c478bd9Sstevel@tonic-gate if (dfstablist->fstype == NULL) { 278*7c478bd9Sstevel@tonic-gate FILE *fp; 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate if ((fp = fopen(DFSTYPES, "r")) == NULL) { 281*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot open %s\n", 282*7c478bd9Sstevel@tonic-gate cmd, DFSTYPES); 283*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 284*7c478bd9Sstevel@tonic-gate free(temp_str); 285*7c478bd9Sstevel@tonic-gate return (NULL); 286*7c478bd9Sstevel@tonic-gate } 287*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&dfstab_lock); 288*7c478bd9Sstevel@tonic-gate dfstablist->fstype = strdup(fileutil_getfs(fp)); 289*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 290*7c478bd9Sstevel@tonic-gate fclose(fp); 291*7c478bd9Sstevel@tonic-gate } 292*7c478bd9Sstevel@tonic-gate dfstablist->path = strdup(arglist[argcount]); 293*7c478bd9Sstevel@tonic-gate if (dfstablist->path == NULL) { 294*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 295*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 296*7c478bd9Sstevel@tonic-gate free(temp_str); 297*7c478bd9Sstevel@tonic-gate return (NULL); 298*7c478bd9Sstevel@tonic-gate } 299*7c478bd9Sstevel@tonic-gate free(temp_str); 300*7c478bd9Sstevel@tonic-gate return (dfstablist); 301*7c478bd9Sstevel@tonic-gate } /* dfstab_line_to_dfstab_entry */ 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate static dfstab_entry_t * 304*7c478bd9Sstevel@tonic-gate change_dfstab_ent( 305*7c478bd9Sstevel@tonic-gate dfstab_entry_t *old_entry, 306*7c478bd9Sstevel@tonic-gate dfstab_entry_t *new_entry, 307*7c478bd9Sstevel@tonic-gate int *err) 308*7c478bd9Sstevel@tonic-gate { 309*7c478bd9Sstevel@tonic-gate 310*7c478bd9Sstevel@tonic-gate FILE *fp; 311*7c478bd9Sstevel@tonic-gate dfstab_entry_t *temp_list, *ret_val; 312*7c478bd9Sstevel@tonic-gate char cmd[BUFSIZE]; 313*7c478bd9Sstevel@tonic-gate char **temp_dfstab = NULL; 314*7c478bd9Sstevel@tonic-gate int line_found = 0; 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate if ((fp = fopen(DFSTAB, "r")) != NULL) { 317*7c478bd9Sstevel@tonic-gate char *share_cmd; 318*7c478bd9Sstevel@tonic-gate int count = 0; 319*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&dfstab_lock); 320*7c478bd9Sstevel@tonic-gate while (fgets(cmd, BUFSIZE, fp) != NULL) { 321*7c478bd9Sstevel@tonic-gate if ((share_cmd = 322*7c478bd9Sstevel@tonic-gate fileutil_get_cmd_from_string(cmd)) == NULL) { 323*7c478bd9Sstevel@tonic-gate if (!fileutil_add_string_to_array( 324*7c478bd9Sstevel@tonic-gate &temp_dfstab, cmd, &count, err)) { 325*7c478bd9Sstevel@tonic-gate ret_val = NULL; 326*7c478bd9Sstevel@tonic-gate line_found = 0; 327*7c478bd9Sstevel@tonic-gate break; 328*7c478bd9Sstevel@tonic-gate } 329*7c478bd9Sstevel@tonic-gate continue; 330*7c478bd9Sstevel@tonic-gate } 331*7c478bd9Sstevel@tonic-gate if ((temp_list = 332*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(share_cmd, err)) == 333*7c478bd9Sstevel@tonic-gate NULL) { 334*7c478bd9Sstevel@tonic-gate free(share_cmd); 335*7c478bd9Sstevel@tonic-gate ret_val = NULL; 336*7c478bd9Sstevel@tonic-gate break; 337*7c478bd9Sstevel@tonic-gate } 338*7c478bd9Sstevel@tonic-gate if (strcmp(old_entry->path, 339*7c478bd9Sstevel@tonic-gate temp_list->path) == 0) { 340*7c478bd9Sstevel@tonic-gate char *new_cmd = NULL; 341*7c478bd9Sstevel@tonic-gate line_found = 1; 342*7c478bd9Sstevel@tonic-gate if (new_entry != NULL && (new_cmd = 343*7c478bd9Sstevel@tonic-gate create_share_cmd(new_entry, cmd, 344*7c478bd9Sstevel@tonic-gate err)) != NULL) { 345*7c478bd9Sstevel@tonic-gate if (!fileutil_add_string_to_array( 346*7c478bd9Sstevel@tonic-gate &temp_dfstab, new_cmd, &count, 347*7c478bd9Sstevel@tonic-gate err)) { 348*7c478bd9Sstevel@tonic-gate ret_val = NULL; 349*7c478bd9Sstevel@tonic-gate line_found = 0; 350*7c478bd9Sstevel@tonic-gate free(share_cmd); 351*7c478bd9Sstevel@tonic-gate free(new_cmd); 352*7c478bd9Sstevel@tonic-gate break; 353*7c478bd9Sstevel@tonic-gate } 354*7c478bd9Sstevel@tonic-gate free(new_cmd); 355*7c478bd9Sstevel@tonic-gate } 356*7c478bd9Sstevel@tonic-gate } else { 357*7c478bd9Sstevel@tonic-gate if (!fileutil_add_string_to_array( 358*7c478bd9Sstevel@tonic-gate &temp_dfstab, cmd, &count, err)) { 359*7c478bd9Sstevel@tonic-gate free(share_cmd); 360*7c478bd9Sstevel@tonic-gate ret_val = NULL; 361*7c478bd9Sstevel@tonic-gate line_found = 0; 362*7c478bd9Sstevel@tonic-gate break; 363*7c478bd9Sstevel@tonic-gate } 364*7c478bd9Sstevel@tonic-gate } 365*7c478bd9Sstevel@tonic-gate free_dfstab_list(temp_list); 366*7c478bd9Sstevel@tonic-gate free(share_cmd); 367*7c478bd9Sstevel@tonic-gate } 368*7c478bd9Sstevel@tonic-gate fclose(fp); 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate if (line_found && temp_dfstab != NULL) { 371*7c478bd9Sstevel@tonic-gate if ((fp = fopen(DFSTAB, "w")) != NULL) { 372*7c478bd9Sstevel@tonic-gate int i; 373*7c478bd9Sstevel@tonic-gate for (i = 0; i < count; i++) { 374*7c478bd9Sstevel@tonic-gate fprintf(fp, "%s", temp_dfstab[i]); 375*7c478bd9Sstevel@tonic-gate } 376*7c478bd9Sstevel@tonic-gate fclose(fp); 377*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 378*7c478bd9Sstevel@tonic-gate ret_val = get_dfstab_ents(err); 379*7c478bd9Sstevel@tonic-gate fileutil_free_string_array(temp_dfstab, count); 380*7c478bd9Sstevel@tonic-gate } else { 381*7c478bd9Sstevel@tonic-gate *err = errno; 382*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 383*7c478bd9Sstevel@tonic-gate fileutil_free_string_array(temp_dfstab, count); 384*7c478bd9Sstevel@tonic-gate ret_val = NULL; 385*7c478bd9Sstevel@tonic-gate } 386*7c478bd9Sstevel@tonic-gate } else { 387*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 388*7c478bd9Sstevel@tonic-gate if (temp_dfstab != NULL) { 389*7c478bd9Sstevel@tonic-gate fileutil_free_string_array(temp_dfstab, count); 390*7c478bd9Sstevel@tonic-gate } 391*7c478bd9Sstevel@tonic-gate ret_val = NULL; 392*7c478bd9Sstevel@tonic-gate } 393*7c478bd9Sstevel@tonic-gate } else { 394*7c478bd9Sstevel@tonic-gate *err = errno; 395*7c478bd9Sstevel@tonic-gate ret_val = NULL; 396*7c478bd9Sstevel@tonic-gate } 397*7c478bd9Sstevel@tonic-gate return (ret_val); 398*7c478bd9Sstevel@tonic-gate } /* change_dfstab_ent */ 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate /* 401*7c478bd9Sstevel@tonic-gate * Public accessor functions. 402*7c478bd9Sstevel@tonic-gate */ 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate /* 405*7c478bd9Sstevel@tonic-gate * fs_add_DFStab_ent - adds an entry to dfstab and to the list of dfstab 406*7c478bd9Sstevel@tonic-gate * entries. Returns a pointer to the head of the dfstab entry list. 407*7c478bd9Sstevel@tonic-gate * Parameters: 408*7c478bd9Sstevel@tonic-gate * char *cmd - the same command to be added to dstab 409*7c478bd9Sstevel@tonic-gate * int *err - an error pointer for retruning any errors 410*7c478bd9Sstevel@tonic-gate */ 411*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 412*7c478bd9Sstevel@tonic-gate fs_add_DFStab_ent(char *cmd, int *err) 413*7c478bd9Sstevel@tonic-gate { 414*7c478bd9Sstevel@tonic-gate dfstab_entry_t *dfstab_ent; 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate dfstab_ent = dfstab_line_to_dfstab_entry(cmd, err); 417*7c478bd9Sstevel@tonic-gate if (dfstab_ent == NULL) { 418*7c478bd9Sstevel@tonic-gate *err = errno; 419*7c478bd9Sstevel@tonic-gate return (NULL); 420*7c478bd9Sstevel@tonic-gate } 421*7c478bd9Sstevel@tonic-gate add_entry_to_dfstab(dfstab_ent, err); 422*7c478bd9Sstevel@tonic-gate if (*err != 0) { 423*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstab_ent); 424*7c478bd9Sstevel@tonic-gate return (NULL); 425*7c478bd9Sstevel@tonic-gate } 426*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstab_ent); 427*7c478bd9Sstevel@tonic-gate return (get_dfstab_ents(err)); 428*7c478bd9Sstevel@tonic-gate } 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * set_DFStab_ent - adds an entry to dfstab and to the list of dfstab entries. 432*7c478bd9Sstevel@tonic-gate * returns a pointer to the head of the dfstab entry list. 433*7c478bd9Sstevel@tonic-gate */ 434*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 435*7c478bd9Sstevel@tonic-gate fs_set_DFStab_ent( 436*7c478bd9Sstevel@tonic-gate char *path, 437*7c478bd9Sstevel@tonic-gate char *fstype, 438*7c478bd9Sstevel@tonic-gate char *options, 439*7c478bd9Sstevel@tonic-gate char *description, 440*7c478bd9Sstevel@tonic-gate int *err) 441*7c478bd9Sstevel@tonic-gate { 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate dfstab_entry_t *new_entry; 444*7c478bd9Sstevel@tonic-gate new_entry = (dfstab_entry_t *)calloc((size_t)1, 445*7c478bd9Sstevel@tonic-gate sizeof (dfstab_entry_t)); 446*7c478bd9Sstevel@tonic-gate if (new_entry == NULL) { 447*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 448*7c478bd9Sstevel@tonic-gate return (NULL); 449*7c478bd9Sstevel@tonic-gate } 450*7c478bd9Sstevel@tonic-gate if (path != NULL) { 451*7c478bd9Sstevel@tonic-gate new_entry->path = strdup(path); 452*7c478bd9Sstevel@tonic-gate } else { 453*7c478bd9Sstevel@tonic-gate *err = EINVAL; 454*7c478bd9Sstevel@tonic-gate free_dfstab_list(new_entry); 455*7c478bd9Sstevel@tonic-gate return (NULL); 456*7c478bd9Sstevel@tonic-gate } 457*7c478bd9Sstevel@tonic-gate if (fstype != NULL) { 458*7c478bd9Sstevel@tonic-gate new_entry->fstype = strdup(fstype); 459*7c478bd9Sstevel@tonic-gate } else { 460*7c478bd9Sstevel@tonic-gate FILE *fp; 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate if ((fp = fopen(DFSTYPES, "r")) == NULL) { 463*7c478bd9Sstevel@tonic-gate /* change this to error handler */ 464*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "cannot open %s\n", 465*7c478bd9Sstevel@tonic-gate DFSTYPES); 466*7c478bd9Sstevel@tonic-gate free_dfstab_list(new_entry); 467*7c478bd9Sstevel@tonic-gate return (NULL); 468*7c478bd9Sstevel@tonic-gate } 469*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&dfstab_lock); 470*7c478bd9Sstevel@tonic-gate new_entry->fstype = strdup(fileutil_getfs(fp)); 471*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&dfstab_lock); 472*7c478bd9Sstevel@tonic-gate fclose(fp); 473*7c478bd9Sstevel@tonic-gate } 474*7c478bd9Sstevel@tonic-gate if (options != NULL) { 475*7c478bd9Sstevel@tonic-gate new_entry->options = strdup(options); 476*7c478bd9Sstevel@tonic-gate } 477*7c478bd9Sstevel@tonic-gate if (description != NULL) { 478*7c478bd9Sstevel@tonic-gate new_entry->description = strdup(description); 479*7c478bd9Sstevel@tonic-gate } 480*7c478bd9Sstevel@tonic-gate add_entry_to_dfstab(new_entry, err); 481*7c478bd9Sstevel@tonic-gate if (*err != 0) { 482*7c478bd9Sstevel@tonic-gate free_dfstab_list(new_entry); 483*7c478bd9Sstevel@tonic-gate return (NULL); 484*7c478bd9Sstevel@tonic-gate } 485*7c478bd9Sstevel@tonic-gate free_dfstab_list(new_entry); 486*7c478bd9Sstevel@tonic-gate return (get_dfstab_ents(err)); 487*7c478bd9Sstevel@tonic-gate } /* set_DFStab_ent */ 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate /* 490*7c478bd9Sstevel@tonic-gate * Accessor function for path element of dfstab entry. 491*7c478bd9Sstevel@tonic-gate */ 492*7c478bd9Sstevel@tonic-gate char * 493*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Path(void *entry) 494*7c478bd9Sstevel@tonic-gate { 495*7c478bd9Sstevel@tonic-gate dfstab_entry_t *entryptr = (dfstab_entry_t *)entry; 496*7c478bd9Sstevel@tonic-gate if (entryptr == NULL) { 497*7c478bd9Sstevel@tonic-gate return (NULL); 498*7c478bd9Sstevel@tonic-gate } 499*7c478bd9Sstevel@tonic-gate return (entryptr->path); 500*7c478bd9Sstevel@tonic-gate } /* get_DFStab_ent_Path */ 501*7c478bd9Sstevel@tonic-gate 502*7c478bd9Sstevel@tonic-gate /* 503*7c478bd9Sstevel@tonic-gate * Accessor function for fstype element of dfstab entry. 504*7c478bd9Sstevel@tonic-gate */ 505*7c478bd9Sstevel@tonic-gate char * 506*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Fstype(void *entry) 507*7c478bd9Sstevel@tonic-gate { 508*7c478bd9Sstevel@tonic-gate dfstab_entry_t *entryptr = (dfstab_entry_t *)entry; 509*7c478bd9Sstevel@tonic-gate if (entryptr == NULL) { 510*7c478bd9Sstevel@tonic-gate return (NULL); 511*7c478bd9Sstevel@tonic-gate } 512*7c478bd9Sstevel@tonic-gate return (entryptr->fstype); 513*7c478bd9Sstevel@tonic-gate } 514*7c478bd9Sstevel@tonic-gate 515*7c478bd9Sstevel@tonic-gate /* 516*7c478bd9Sstevel@tonic-gate * Accessor function for options element of dfstab entry. 517*7c478bd9Sstevel@tonic-gate */ 518*7c478bd9Sstevel@tonic-gate char * 519*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Options(void *entry) 520*7c478bd9Sstevel@tonic-gate { 521*7c478bd9Sstevel@tonic-gate dfstab_entry_t *entryptr = (dfstab_entry_t *)entry; 522*7c478bd9Sstevel@tonic-gate if (entryptr == NULL) { 523*7c478bd9Sstevel@tonic-gate return (NULL); 524*7c478bd9Sstevel@tonic-gate } 525*7c478bd9Sstevel@tonic-gate return (entryptr->options); 526*7c478bd9Sstevel@tonic-gate } 527*7c478bd9Sstevel@tonic-gate 528*7c478bd9Sstevel@tonic-gate /* 529*7c478bd9Sstevel@tonic-gate * Accessor function for description element of dfstab entry. 530*7c478bd9Sstevel@tonic-gate */ 531*7c478bd9Sstevel@tonic-gate char * 532*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Desc(void *entry) 533*7c478bd9Sstevel@tonic-gate { 534*7c478bd9Sstevel@tonic-gate dfstab_entry_t *entryptr = (dfstab_entry_t *)entry; 535*7c478bd9Sstevel@tonic-gate if (entryptr == NULL) { 536*7c478bd9Sstevel@tonic-gate return (NULL); 537*7c478bd9Sstevel@tonic-gate } 538*7c478bd9Sstevel@tonic-gate return (entryptr->description); 539*7c478bd9Sstevel@tonic-gate } 540*7c478bd9Sstevel@tonic-gate 541*7c478bd9Sstevel@tonic-gate /* 542*7c478bd9Sstevel@tonic-gate * Accessor function for resource element of dfstab entry. 543*7c478bd9Sstevel@tonic-gate */ 544*7c478bd9Sstevel@tonic-gate char * 545*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Res(void *entry) 546*7c478bd9Sstevel@tonic-gate { 547*7c478bd9Sstevel@tonic-gate dfstab_entry_t *entryptr = (dfstab_entry_t *)entry; 548*7c478bd9Sstevel@tonic-gate if (entryptr == NULL) { 549*7c478bd9Sstevel@tonic-gate return (NULL); 550*7c478bd9Sstevel@tonic-gate } 551*7c478bd9Sstevel@tonic-gate return (entryptr->resource); 552*7c478bd9Sstevel@tonic-gate } 553*7c478bd9Sstevel@tonic-gate 554*7c478bd9Sstevel@tonic-gate 555*7c478bd9Sstevel@tonic-gate /* 556*7c478bd9Sstevel@tonic-gate * Calls get_dfstab_ents to create the list of dfstab 557*7c478bd9Sstevel@tonic-gate * entries and returns that list. 558*7c478bd9Sstevel@tonic-gate */ 559*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 560*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ents(int *err) 561*7c478bd9Sstevel@tonic-gate { 562*7c478bd9Sstevel@tonic-gate dfstab_entry_t *list; 563*7c478bd9Sstevel@tonic-gate list = get_dfstab_ents(err); 564*7c478bd9Sstevel@tonic-gate return (list); 565*7c478bd9Sstevel@tonic-gate } 566*7c478bd9Sstevel@tonic-gate 567*7c478bd9Sstevel@tonic-gate /* 568*7c478bd9Sstevel@tonic-gate * Retrives and returns the next entry in the list. 569*7c478bd9Sstevel@tonic-gate */ 570*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 571*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Next(void *list) 572*7c478bd9Sstevel@tonic-gate { 573*7c478bd9Sstevel@tonic-gate dfstab_entry_t *listptr = (dfstab_entry_t *)list; 574*7c478bd9Sstevel@tonic-gate if (listptr == NULL) { 575*7c478bd9Sstevel@tonic-gate return (NULL); 576*7c478bd9Sstevel@tonic-gate } 577*7c478bd9Sstevel@tonic-gate return (listptr->next); 578*7c478bd9Sstevel@tonic-gate } 579*7c478bd9Sstevel@tonic-gate 580*7c478bd9Sstevel@tonic-gate /* 581*7c478bd9Sstevel@tonic-gate * Retrives and returns a share command based on the dfstab entry passed in. 582*7c478bd9Sstevel@tonic-gate */ 583*7c478bd9Sstevel@tonic-gate char * 584*7c478bd9Sstevel@tonic-gate fs_get_Dfstab_share_cmd(fs_dfstab_entry_t dfstab_ent, int *err) 585*7c478bd9Sstevel@tonic-gate { 586*7c478bd9Sstevel@tonic-gate char *share_cmd; 587*7c478bd9Sstevel@tonic-gate if (dfstab_ent == NULL) { 588*7c478bd9Sstevel@tonic-gate return (NULL); 589*7c478bd9Sstevel@tonic-gate } 590*7c478bd9Sstevel@tonic-gate share_cmd = create_share_cmd((dfstab_entry_t *)dfstab_ent, NULL, err); 591*7c478bd9Sstevel@tonic-gate return (share_cmd); 592*7c478bd9Sstevel@tonic-gate } /* fs_get_Dfstab_share_cmd */ 593*7c478bd9Sstevel@tonic-gate 594*7c478bd9Sstevel@tonic-gate /* 595*7c478bd9Sstevel@tonic-gate * edit_DFStab_ent - changes an entry in dfstab. 596*7c478bd9Sstevel@tonic-gate */ 597*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 598*7c478bd9Sstevel@tonic-gate fs_edit_DFStab_ent(char *old_cmd, char *new_cmd, int *err) 599*7c478bd9Sstevel@tonic-gate { 600*7c478bd9Sstevel@tonic-gate dfstab_entry_t *old_dfstabent, *new_dfstabent, *ret_val; 601*7c478bd9Sstevel@tonic-gate 602*7c478bd9Sstevel@tonic-gate if ((old_dfstabent = 603*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(old_cmd, err)) == NULL) { 604*7c478bd9Sstevel@tonic-gate return (NULL); 605*7c478bd9Sstevel@tonic-gate } 606*7c478bd9Sstevel@tonic-gate if ((new_dfstabent = 607*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(new_cmd, err)) == NULL) { 608*7c478bd9Sstevel@tonic-gate return (NULL); 609*7c478bd9Sstevel@tonic-gate } 610*7c478bd9Sstevel@tonic-gate if ((ret_val = 611*7c478bd9Sstevel@tonic-gate change_dfstab_ent(old_dfstabent, new_dfstabent, err)) == NULL) { 612*7c478bd9Sstevel@tonic-gate return (NULL); 613*7c478bd9Sstevel@tonic-gate } 614*7c478bd9Sstevel@tonic-gate free_dfstab_list(old_dfstabent); 615*7c478bd9Sstevel@tonic-gate free_dfstab_list(new_dfstabent); 616*7c478bd9Sstevel@tonic-gate return (ret_val); 617*7c478bd9Sstevel@tonic-gate } 618*7c478bd9Sstevel@tonic-gate 619*7c478bd9Sstevel@tonic-gate /* 620*7c478bd9Sstevel@tonic-gate * del_DFStab_ent - deletes an entry in dfstab. 621*7c478bd9Sstevel@tonic-gate */ 622*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 623*7c478bd9Sstevel@tonic-gate fs_del_DFStab_ent(char *del_cmd, int *err) 624*7c478bd9Sstevel@tonic-gate { 625*7c478bd9Sstevel@tonic-gate dfstab_entry_t *del_dfstabent, *ret_val; 626*7c478bd9Sstevel@tonic-gate 627*7c478bd9Sstevel@tonic-gate if ((del_dfstabent = 628*7c478bd9Sstevel@tonic-gate dfstab_line_to_dfstab_entry(del_cmd, err)) == NULL) { 629*7c478bd9Sstevel@tonic-gate return (NULL); 630*7c478bd9Sstevel@tonic-gate } 631*7c478bd9Sstevel@tonic-gate if ((ret_val = 632*7c478bd9Sstevel@tonic-gate change_dfstab_ent(del_dfstabent, NULL, err)) == NULL) { 633*7c478bd9Sstevel@tonic-gate return (NULL); 634*7c478bd9Sstevel@tonic-gate } 635*7c478bd9Sstevel@tonic-gate free_dfstab_list(del_dfstabent); 636*7c478bd9Sstevel@tonic-gate return (ret_val); 637*7c478bd9Sstevel@tonic-gate } 638*7c478bd9Sstevel@tonic-gate 639*7c478bd9Sstevel@tonic-gate /* 640*7c478bd9Sstevel@tonic-gate * del_All_DFStab_ents_with_Path - deletes all duplicate entries with 641*7c478bd9Sstevel@tonic-gate * the specified path. 642*7c478bd9Sstevel@tonic-gate */ 643*7c478bd9Sstevel@tonic-gate fs_dfstab_entry_t 644*7c478bd9Sstevel@tonic-gate fs_del_All_DFStab_ents_with_Path(char *path, int *err) 645*7c478bd9Sstevel@tonic-gate { 646*7c478bd9Sstevel@tonic-gate dfstab_entry_t del_dfstabent, *ret_val; 647*7c478bd9Sstevel@tonic-gate 648*7c478bd9Sstevel@tonic-gate if (path != NULL) { 649*7c478bd9Sstevel@tonic-gate if ((del_dfstabent.path = strdup(path)) != NULL) { 650*7c478bd9Sstevel@tonic-gate if ((ret_val = change_dfstab_ent(&del_dfstabent, 651*7c478bd9Sstevel@tonic-gate NULL, err)) == NULL) { 652*7c478bd9Sstevel@tonic-gate ret_val = NULL; 653*7c478bd9Sstevel@tonic-gate } 654*7c478bd9Sstevel@tonic-gate free(del_dfstabent.path); 655*7c478bd9Sstevel@tonic-gate } else { 656*7c478bd9Sstevel@tonic-gate *err = ENOMEM; 657*7c478bd9Sstevel@tonic-gate ret_val = NULL; 658*7c478bd9Sstevel@tonic-gate } 659*7c478bd9Sstevel@tonic-gate } else { 660*7c478bd9Sstevel@tonic-gate *err = EINVAL; 661*7c478bd9Sstevel@tonic-gate ret_val = NULL; 662*7c478bd9Sstevel@tonic-gate } 663*7c478bd9Sstevel@tonic-gate return (ret_val); 664*7c478bd9Sstevel@tonic-gate } 665*7c478bd9Sstevel@tonic-gate 666*7c478bd9Sstevel@tonic-gate 667*7c478bd9Sstevel@tonic-gate int 668*7c478bd9Sstevel@tonic-gate fs_check_for_duplicate_DFStab_paths(char *path, int *err) 669*7c478bd9Sstevel@tonic-gate { 670*7c478bd9Sstevel@tonic-gate dfstab_entry_t *dfstablist; 671*7c478bd9Sstevel@tonic-gate int count = 0; 672*7c478bd9Sstevel@tonic-gate 673*7c478bd9Sstevel@tonic-gate *err = 0; 674*7c478bd9Sstevel@tonic-gate if (path == NULL) { 675*7c478bd9Sstevel@tonic-gate count = -1; 676*7c478bd9Sstevel@tonic-gate } 677*7c478bd9Sstevel@tonic-gate dfstablist = get_dfstab_ents(err); 678*7c478bd9Sstevel@tonic-gate if (dfstablist != NULL) { 679*7c478bd9Sstevel@tonic-gate while (dfstablist != NULL) { 680*7c478bd9Sstevel@tonic-gate if (strcmp(dfstablist->path, path) == 0) { 681*7c478bd9Sstevel@tonic-gate count++; 682*7c478bd9Sstevel@tonic-gate } 683*7c478bd9Sstevel@tonic-gate dfstablist = dfstablist->next; 684*7c478bd9Sstevel@tonic-gate } 685*7c478bd9Sstevel@tonic-gate 686*7c478bd9Sstevel@tonic-gate free_dfstab_list(dfstablist); 687*7c478bd9Sstevel@tonic-gate } else { 688*7c478bd9Sstevel@tonic-gate if (err != 0) 689*7c478bd9Sstevel@tonic-gate count = *err; 690*7c478bd9Sstevel@tonic-gate else 691*7c478bd9Sstevel@tonic-gate count = 0; 692*7c478bd9Sstevel@tonic-gate } 693*7c478bd9Sstevel@tonic-gate return (count); 694*7c478bd9Sstevel@tonic-gate } 695*7c478bd9Sstevel@tonic-gate 696*7c478bd9Sstevel@tonic-gate void 697*7c478bd9Sstevel@tonic-gate fs_free_DFStab_ents(void *list) 698*7c478bd9Sstevel@tonic-gate { 699*7c478bd9Sstevel@tonic-gate dfstab_entry_t *headp = (dfstab_entry_t *)list; 700*7c478bd9Sstevel@tonic-gate free_dfstab_list(headp); 701*7c478bd9Sstevel@tonic-gate } 702*7c478bd9Sstevel@tonic-gate 703*7c478bd9Sstevel@tonic-gate /* 704*7c478bd9Sstevel@tonic-gate * used for debugging only 705*7c478bd9Sstevel@tonic-gate */ 706*7c478bd9Sstevel@tonic-gate void 707*7c478bd9Sstevel@tonic-gate fs_print_dfstab_entries(void *list) 708*7c478bd9Sstevel@tonic-gate { 709*7c478bd9Sstevel@tonic-gate while (list != NULL) { 710*7c478bd9Sstevel@tonic-gate 711*7c478bd9Sstevel@tonic-gate if (fs_get_DFStab_ent_Fstype(list) != NULL) 712*7c478bd9Sstevel@tonic-gate printf("fstype: %s", fs_get_DFStab_ent_Fstype(list)); 713*7c478bd9Sstevel@tonic-gate if (fs_get_DFStab_ent_Desc(list) != NULL) 714*7c478bd9Sstevel@tonic-gate printf(" description: %s", 715*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Desc(list)); 716*7c478bd9Sstevel@tonic-gate if (fs_get_DFStab_ent_Options(list) != NULL) 717*7c478bd9Sstevel@tonic-gate printf(" options: %s", 718*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Options(list)); 719*7c478bd9Sstevel@tonic-gate if (fs_get_DFStab_ent_Path(list) != NULL) 720*7c478bd9Sstevel@tonic-gate printf(" shared path is: %s\n", 721*7c478bd9Sstevel@tonic-gate fs_get_DFStab_ent_Path(list)); 722*7c478bd9Sstevel@tonic-gate list = (void *)fs_get_DFStab_ent_Next(list); 723*7c478bd9Sstevel@tonic-gate } 724*7c478bd9Sstevel@tonic-gate 725*7c478bd9Sstevel@tonic-gate } 726