changeset 5016:40ae92b9e799

6563082 kbd -s issues ioctl when default accepted
author vn210641
date Mon, 10 Sep 2007 04:12:38 -0700
parents f9115056d6bb
children 3e669302a3e8
files usr/src/cmd/kbd/kbd.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/kbd/kbd.c	Sun Sep 09 21:41:12 2007 -0700
+++ b/usr/src/cmd/kbd/kbd.c	Mon Sep 10 04:12:38 2007 -0700
@@ -85,7 +85,7 @@
 static int default_layout_number = 0;
 
 static void reset(int);
-static void get_type(int);
+static int get_type(int);
 static void get_layout(int);
 static void kbd_defaults(int);
 static void usage(void);
@@ -224,7 +224,7 @@
 	}
 
 	if (tflag)
-		get_type(kbd);
+		(void) get_type(kbd);
 
 	if (lflag)
 		get_layout(kbd);
@@ -305,6 +305,14 @@
 	int layout_num;
 	int error = 1;
 
+	/* layout setting is possible only for USB type keyboards */
+	if (get_type(kbd) != KB_USB) {
+		(void) fprintf(stderr, "The -s option does not apply for this"
+			" keyboard type.\n"
+			"Only USB/PS2 type keyboards support this option.\n");
+		return (error);
+	}
+
 	/* get the language info from the layouts file */
 	if (get_layouts() != 0)
 		return (error);
@@ -424,7 +432,7 @@
 /*
  * this routine gets the type of the keyboard being used
  */
-static void
+static int
 get_type(int kbd)
 {
 	int kbd_type;
@@ -460,6 +468,7 @@
 		(void) printf("Unknown keyboard type\n");
 		break;
 	}
+	return (kbd_type);
 }
 
 /*