17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ead1f93eSLiane Praza * Common Development and Distribution License (the "License"). 6ead1f93eSLiane Praza * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21ead1f93eSLiane Praza 227c478bd9Sstevel@tonic-gate /* 23ead1f93eSLiane Praza * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*ed159168SRichard PALO * 26*ed159168SRichard PALO * Copyright 2015 PALO, Richard 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <stdio.h> 307c478bd9Sstevel@tonic-gate #include <stdlib.h> 317c478bd9Sstevel@tonic-gate #include <string.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include "list.h" 347c478bd9Sstevel@tonic-gate #include "exception_list.h" 357c478bd9Sstevel@tonic-gate #include "arch.h" 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * This is global so that the protodir reading functions can rely on the 397c478bd9Sstevel@tonic-gate * exception list to weed out innocuous problems in the IHV gate. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate elem_list exception_list; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define FS " \t\n" 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate static int 467c478bd9Sstevel@tonic-gate parse_exception_line(char *line, elem_list *list) 477c478bd9Sstevel@tonic-gate { 487c478bd9Sstevel@tonic-gate char *name, *arch; 497c478bd9Sstevel@tonic-gate elem *e; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate if ((name = strtok(line, FS)) == NULL) { 527c478bd9Sstevel@tonic-gate /* don't complain; this is only a blank line */ 537c478bd9Sstevel@tonic-gate return (0); 547c478bd9Sstevel@tonic-gate } 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate if ((arch = strtok(NULL, FS)) == NULL) { 57ead1f93eSLiane Praza arch = "all"; 587c478bd9Sstevel@tonic-gate } 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate e = (elem *) malloc(sizeof (elem)); 61*ed159168SRichard PALO if (e == NULL) { 62*ed159168SRichard PALO perror("malloc"); 63*ed159168SRichard PALO exit(1); 64*ed159168SRichard PALO } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate e->inode = 0; 677c478bd9Sstevel@tonic-gate e->perm = 0; 687c478bd9Sstevel@tonic-gate e->ref_cnt = 0; 697c478bd9Sstevel@tonic-gate e->flag = 0; 707c478bd9Sstevel@tonic-gate e->major = 0; 717c478bd9Sstevel@tonic-gate e->minor = 0; 727c478bd9Sstevel@tonic-gate e->link_parent = NULL; 737c478bd9Sstevel@tonic-gate e->link_sib = NULL; 747c478bd9Sstevel@tonic-gate e->symsrc = NULL; 757c478bd9Sstevel@tonic-gate e->file_type = DIR_T; 767c478bd9Sstevel@tonic-gate 77*ed159168SRichard PALO while ((e->arch = assign_arch(arch)) == 0) { 78ead1f93eSLiane Praza if ((arch = strtok(NULL, FS)) == NULL) { 797c478bd9Sstevel@tonic-gate return (0); 807c478bd9Sstevel@tonic-gate } 81ead1f93eSLiane Praza } 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate (void) strcpy(e->name, name); 847c478bd9Sstevel@tonic-gate add_elem(list, e); 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate return (1); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate int 907c478bd9Sstevel@tonic-gate read_in_exceptions(const char *exception_file, int verbose) 917c478bd9Sstevel@tonic-gate { 927c478bd9Sstevel@tonic-gate FILE *except_fp; 937c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 947c478bd9Sstevel@tonic-gate int count = 0; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate exception_file = exception_file ? exception_file : EXCEPTION_FILE; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate if (verbose) { 997c478bd9Sstevel@tonic-gate (void) printf("reading in exceptions from %s...\n", 1007c478bd9Sstevel@tonic-gate exception_file); 1017c478bd9Sstevel@tonic-gate } 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate if ((except_fp = fopen(exception_file, "r")) == NULL) { 1047c478bd9Sstevel@tonic-gate perror(exception_file); 1057c478bd9Sstevel@tonic-gate return (0); 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate while (fgets(buf, BUFSIZ, except_fp)) { 1087c478bd9Sstevel@tonic-gate if (buf[0] != '#') /* allow for comments */ 1097c478bd9Sstevel@tonic-gate count += parse_exception_line(buf, &exception_list); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate if (verbose) 1127c478bd9Sstevel@tonic-gate (void) printf("read in %d exceptions...\n", count); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate return (count); 1157c478bd9Sstevel@tonic-gate } 116