1*aecfc01dSrui zang - Sun Microsystems - Beijing China /* 2*aecfc01dSrui zang - Sun Microsystems - Beijing China * CDDL HEADER START 3*aecfc01dSrui zang - Sun Microsystems - Beijing China * 4*aecfc01dSrui zang - Sun Microsystems - Beijing China * The contents of this file are subject to the terms of the 5*aecfc01dSrui zang - Sun Microsystems - Beijing China * Common Development and Distribution License (the "License"). 6*aecfc01dSrui zang - Sun Microsystems - Beijing China * You may not use this file except in compliance with the License. 7*aecfc01dSrui zang - Sun Microsystems - Beijing China * 8*aecfc01dSrui zang - Sun Microsystems - Beijing China * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*aecfc01dSrui zang - Sun Microsystems - Beijing China * or http://www.opensolaris.org/os/licensing. 10*aecfc01dSrui zang - Sun Microsystems - Beijing China * See the License for the specific language governing permissions 11*aecfc01dSrui zang - Sun Microsystems - Beijing China * and limitations under the License. 12*aecfc01dSrui zang - Sun Microsystems - Beijing China * 13*aecfc01dSrui zang - Sun Microsystems - Beijing China * When distributing Covered Code, include this CDDL HEADER in each 14*aecfc01dSrui zang - Sun Microsystems - Beijing China * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*aecfc01dSrui zang - Sun Microsystems - Beijing China * If applicable, add the following below this CDDL HEADER, with the 16*aecfc01dSrui zang - Sun Microsystems - Beijing China * fields enclosed by brackets "[]" replaced with your own identifying 17*aecfc01dSrui zang - Sun Microsystems - Beijing China * information: Portions Copyright [yyyy] [name of copyright owner] 18*aecfc01dSrui zang - Sun Microsystems - Beijing China * 19*aecfc01dSrui zang - Sun Microsystems - Beijing China * CDDL HEADER END 20*aecfc01dSrui zang - Sun Microsystems - Beijing China */ 21*aecfc01dSrui zang - Sun Microsystems - Beijing China /* 22*aecfc01dSrui zang - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*aecfc01dSrui zang - Sun Microsystems - Beijing China * Use is subject to license terms. 24*aecfc01dSrui zang - Sun Microsystems - Beijing China */ 25*aecfc01dSrui zang - Sun Microsystems - Beijing China 26*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <sys/types.h> 27*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <sys/stat.h> 28*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <fcntl.h> 29*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <unistd.h> 30*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <stropts.h> 31*aecfc01dSrui zang - Sun Microsystems - Beijing China #include <sys/vt.h> 32*aecfc01dSrui zang - Sun Microsystems - Beijing China 33*aecfc01dSrui zang - Sun Microsystems - Beijing China /* 34*aecfc01dSrui zang - Sun Microsystems - Beijing China * return value: 35*aecfc01dSrui zang - Sun Microsystems - Beijing China * 0: disabled 36*aecfc01dSrui zang - Sun Microsystems - Beijing China * 1: enabled 37*aecfc01dSrui zang - Sun Microsystems - Beijing China * 2: An error occured 38*aecfc01dSrui zang - Sun Microsystems - Beijing China */ 39*aecfc01dSrui zang - Sun Microsystems - Beijing China int 40*aecfc01dSrui zang - Sun Microsystems - Beijing China main(void) 41*aecfc01dSrui zang - Sun Microsystems - Beijing China { 42*aecfc01dSrui zang - Sun Microsystems - Beijing China int result; 43*aecfc01dSrui zang - Sun Microsystems - Beijing China int fd; 44*aecfc01dSrui zang - Sun Microsystems - Beijing China 45*aecfc01dSrui zang - Sun Microsystems - Beijing China if ((fd = open("/dev/vt/0", O_RDONLY)) < 0) 46*aecfc01dSrui zang - Sun Microsystems - Beijing China return (2); 47*aecfc01dSrui zang - Sun Microsystems - Beijing China 48*aecfc01dSrui zang - Sun Microsystems - Beijing China if (ioctl(fd, VT_ENABLED, &result) != 0) { 49*aecfc01dSrui zang - Sun Microsystems - Beijing China (void) close(fd); 50*aecfc01dSrui zang - Sun Microsystems - Beijing China return (2); 51*aecfc01dSrui zang - Sun Microsystems - Beijing China } 52*aecfc01dSrui zang - Sun Microsystems - Beijing China 53*aecfc01dSrui zang - Sun Microsystems - Beijing China (void) close(fd); 54*aecfc01dSrui zang - Sun Microsystems - Beijing China 55*aecfc01dSrui zang - Sun Microsystems - Beijing China if (result == 0) 56*aecfc01dSrui zang - Sun Microsystems - Beijing China return (0); /* disabled */ 57*aecfc01dSrui zang - Sun Microsystems - Beijing China 58*aecfc01dSrui zang - Sun Microsystems - Beijing China return (1); /* enabled */ 59*aecfc01dSrui zang - Sun Microsystems - Beijing China } 60