/* * Method: nfssec_free_secmode_list * * Description: Frees the space allocated for the security mode list array. * * Parameters: * - char **seclist - the array to be freed. * - int num_elements - the number of elements in the array. * * Returns: * - Nothing */ void nfssec_free_secmode_list(char **seclist, int num_elements) { fileutil_free_string_array(seclist, num_elements); } /* nfssec_free_secmode_list */
static dfstab_entry_t * change_dfstab_ent( dfstab_entry_t *old_entry, dfstab_entry_t *new_entry, int *err) { FILE *fp; dfstab_entry_t *temp_list, *ret_val; char cmd[BUFSIZE]; char **temp_dfstab = NULL; int line_found = 0; if ((fp = fopen(DFSTAB, "r")) != NULL) { char *share_cmd; int count = 0; (void) mutex_lock(&dfstab_lock); while (fgets(cmd, BUFSIZE, fp) != NULL) { if ((share_cmd = fileutil_get_cmd_from_string(cmd)) == NULL) { if (!fileutil_add_string_to_array( &temp_dfstab, cmd, &count, err)) { ret_val = NULL; line_found = 0; break; } continue; } if ((temp_list = dfstab_line_to_dfstab_entry(share_cmd, err)) == NULL) { free(share_cmd); ret_val = NULL; break; } if (strcmp(old_entry->path, temp_list->path) == 0) { char *new_cmd = NULL; line_found = 1; if (new_entry != NULL && (new_cmd = create_share_cmd(new_entry, cmd, err)) != NULL) { if (!fileutil_add_string_to_array( &temp_dfstab, new_cmd, &count, err)) { ret_val = NULL; line_found = 0; free(share_cmd); free(new_cmd); break; } free(new_cmd); } } else { if (!fileutil_add_string_to_array( &temp_dfstab, cmd, &count, err)) { free(share_cmd); ret_val = NULL; line_found = 0; break; } } free_dfstab_list(temp_list); free(share_cmd); } fclose(fp); if (line_found && temp_dfstab != NULL) { if ((fp = fopen(DFSTAB, "w")) != NULL) { int i; for (i = 0; i < count; i++) { fprintf(fp, "%s", temp_dfstab[i]); } fclose(fp); (void) mutex_unlock(&dfstab_lock); ret_val = get_dfstab_ents(err); fileutil_free_string_array(temp_dfstab, count); } else { *err = errno; (void) mutex_unlock(&dfstab_lock); fileutil_free_string_array(temp_dfstab, count); ret_val = NULL; } } else { (void) mutex_unlock(&dfstab_lock); if (temp_dfstab != NULL) { fileutil_free_string_array(temp_dfstab, count); } ret_val = NULL; } } else { *err = errno; ret_val = NULL; } return (ret_val); } /* change_dfstab_ent */