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 5*ead1f93eSLiane Praza * Common Development and Distribution License (the "License"). 6*ead1f93eSLiane 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 */ 21*ead1f93eSLiane Praza 227c478bd9Sstevel@tonic-gate /* 23*ead1f93eSLiane Praza * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #include <stdio.h> 287c478bd9Sstevel@tonic-gate #include <stdlib.h> 297c478bd9Sstevel@tonic-gate #include <string.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include "list.h" 327c478bd9Sstevel@tonic-gate #include "exception_list.h" 337c478bd9Sstevel@tonic-gate #include "arch.h" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * This is global so that the protodir reading functions can rely on the 377c478bd9Sstevel@tonic-gate * exception list to weed out innocuous problems in the IHV gate. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate elem_list exception_list; 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define FS " \t\n" 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate static int 447c478bd9Sstevel@tonic-gate parse_exception_line(char *line, elem_list *list) 457c478bd9Sstevel@tonic-gate { 467c478bd9Sstevel@tonic-gate char *name, *arch; 477c478bd9Sstevel@tonic-gate elem *e; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate if ((name = strtok(line, FS)) == NULL) { 507c478bd9Sstevel@tonic-gate /* don't complain; this is only a blank line */ 517c478bd9Sstevel@tonic-gate return (0); 527c478bd9Sstevel@tonic-gate } 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate if ((arch = strtok(NULL, FS)) == NULL) { 55*ead1f93eSLiane Praza arch = "all"; 567c478bd9Sstevel@tonic-gate } 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate e = (elem *) malloc(sizeof (elem)); 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate e->inode = 0; 617c478bd9Sstevel@tonic-gate e->perm = 0; 627c478bd9Sstevel@tonic-gate e->ref_cnt = 0; 637c478bd9Sstevel@tonic-gate e->flag = 0; 647c478bd9Sstevel@tonic-gate e->major = 0; 657c478bd9Sstevel@tonic-gate e->minor = 0; 667c478bd9Sstevel@tonic-gate e->link_parent = NULL; 677c478bd9Sstevel@tonic-gate e->link_sib = NULL; 687c478bd9Sstevel@tonic-gate e->symsrc = NULL; 697c478bd9Sstevel@tonic-gate e->file_type = DIR_T; 707c478bd9Sstevel@tonic-gate 71*ead1f93eSLiane Praza while ((e->arch = assign_arch(arch)) == NULL) { 72*ead1f93eSLiane Praza if ((arch = strtok(NULL, FS)) == NULL) { 73*ead1f93eSLiane Praza return (0); 74*ead1f93eSLiane Praza } 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate (void) strcpy(e->name, name); 787c478bd9Sstevel@tonic-gate add_elem(list, e); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate return (1); 817c478bd9Sstevel@tonic-gate } 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate int 847c478bd9Sstevel@tonic-gate read_in_exceptions(const char *exception_file, int verbose) 857c478bd9Sstevel@tonic-gate { 867c478bd9Sstevel@tonic-gate FILE *except_fp; 877c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 887c478bd9Sstevel@tonic-gate int count = 0; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate exception_file = exception_file ? exception_file : EXCEPTION_FILE; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate if (verbose) { 937c478bd9Sstevel@tonic-gate (void) printf("reading in exceptions from %s...\n", 947c478bd9Sstevel@tonic-gate exception_file); 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate if ((except_fp = fopen(exception_file, "r")) == NULL) { 987c478bd9Sstevel@tonic-gate perror(exception_file); 997c478bd9Sstevel@tonic-gate return (0); 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate while (fgets(buf, BUFSIZ, except_fp)) { 1027c478bd9Sstevel@tonic-gate if (buf[0] != '#') /* allow for comments */ 1037c478bd9Sstevel@tonic-gate count += parse_exception_line(buf, &exception_list); 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate if (verbose) 1067c478bd9Sstevel@tonic-gate (void) printf("read in %d exceptions...\n", count); 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate return (count); 1097c478bd9Sstevel@tonic-gate } 110