1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate 
23*0Sstevel@tonic-gate /*
24*0Sstevel@tonic-gate  * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate  * This file contains functions that implement the cache menu commands.
31*0Sstevel@tonic-gate  */
32*0Sstevel@tonic-gate #include "global.h"
33*0Sstevel@tonic-gate #include <sys/time.h>
34*0Sstevel@tonic-gate #include <sys/resource.h>
35*0Sstevel@tonic-gate #include <sys/wait.h>
36*0Sstevel@tonic-gate #include <signal.h>
37*0Sstevel@tonic-gate #include <string.h>
38*0Sstevel@tonic-gate #include <sys/fcntl.h>
39*0Sstevel@tonic-gate #include <sys/stat.h>
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #include <sys/dklabel.h>
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #include "main.h"
44*0Sstevel@tonic-gate #include "analyze.h"
45*0Sstevel@tonic-gate #include "menu.h"
46*0Sstevel@tonic-gate #include "menu_cache.h"
47*0Sstevel@tonic-gate #include "param.h"
48*0Sstevel@tonic-gate #include "misc.h"
49*0Sstevel@tonic-gate #include "label.h"
50*0Sstevel@tonic-gate #include "startup.h"
51*0Sstevel@tonic-gate #include "partition.h"
52*0Sstevel@tonic-gate #include "prompts.h"
53*0Sstevel@tonic-gate #include "checkmount.h"
54*0Sstevel@tonic-gate #include "io.h"
55*0Sstevel@tonic-gate #include "ctlr_scsi.h"
56*0Sstevel@tonic-gate #include "auto_sense.h"
57*0Sstevel@tonic-gate #include "hardware_structs.h"
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate extern	struct menu_item menu_cache[];
60*0Sstevel@tonic-gate extern	struct menu_item menu_write_cache[];
61*0Sstevel@tonic-gate extern	struct menu_item menu_read_cache[];
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate int
65*0Sstevel@tonic-gate c_cache()
66*0Sstevel@tonic-gate {
67*0Sstevel@tonic-gate 	cur_menu++;
68*0Sstevel@tonic-gate 	last_menu = cur_menu;
69*0Sstevel@tonic-gate 	run_menu(menu_cache, "CACHE", "cache", 0);
70*0Sstevel@tonic-gate 	cur_menu--;
71*0Sstevel@tonic-gate 	return (0);
72*0Sstevel@tonic-gate }
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate int
75*0Sstevel@tonic-gate ca_write_cache()
76*0Sstevel@tonic-gate {
77*0Sstevel@tonic-gate 	cur_menu++;
78*0Sstevel@tonic-gate 	last_menu = cur_menu;
79*0Sstevel@tonic-gate 	run_menu(menu_write_cache, "WRITE_CACHE", "write_cache", 0);
80*0Sstevel@tonic-gate 	cur_menu--;
81*0Sstevel@tonic-gate 	return (0);
82*0Sstevel@tonic-gate }
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate int
85*0Sstevel@tonic-gate ca_read_cache()
86*0Sstevel@tonic-gate {
87*0Sstevel@tonic-gate 	cur_menu++;
88*0Sstevel@tonic-gate 	last_menu = cur_menu;
89*0Sstevel@tonic-gate 	run_menu(menu_read_cache, "READ_CACHE", "read_cache", 0);
90*0Sstevel@tonic-gate 	cur_menu--;
91*0Sstevel@tonic-gate 	return (0);
92*0Sstevel@tonic-gate }
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate int
95*0Sstevel@tonic-gate ca_write_display()
96*0Sstevel@tonic-gate {
97*0Sstevel@tonic-gate 	struct mode_cache		*page8;
98*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
99*0Sstevel@tonic-gate 	int				status;
100*0Sstevel@tonic-gate 	union {
101*0Sstevel@tonic-gate 		struct mode_cache	page8;
102*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
103*0Sstevel@tonic-gate 	} u_page8;
104*0Sstevel@tonic-gate 
105*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
108*0Sstevel@tonic-gate 			MODE_SENSE_PC_CURRENT, (caddr_t)page8,
109*0Sstevel@tonic-gate 			MAX_MODE_SENSE_SIZE, &header);
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate 	if (status == 0) {
112*0Sstevel@tonic-gate 		if (page8->wce) {
113*0Sstevel@tonic-gate 			fmt_print("Write Cache is enabled\n");
114*0Sstevel@tonic-gate 		} else {
115*0Sstevel@tonic-gate 			fmt_print("Write Cache is disabled\n");
116*0Sstevel@tonic-gate 		}
117*0Sstevel@tonic-gate 	} else {
118*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
119*0Sstevel@tonic-gate 	}
120*0Sstevel@tonic-gate 	return (0);
121*0Sstevel@tonic-gate }
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate int
124*0Sstevel@tonic-gate ca_write_enable()
125*0Sstevel@tonic-gate {
126*0Sstevel@tonic-gate 	struct mode_cache		*page8;
127*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
128*0Sstevel@tonic-gate 	int				status;
129*0Sstevel@tonic-gate 	int				length;
130*0Sstevel@tonic-gate 	int				sp_flags;
131*0Sstevel@tonic-gate 	union {
132*0Sstevel@tonic-gate 		struct mode_cache	page8;
133*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
134*0Sstevel@tonic-gate 	} u_page8;
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
139*0Sstevel@tonic-gate 			MODE_SENSE_PC_CHANGEABLE, (caddr_t)page8,
140*0Sstevel@tonic-gate 			MAX_MODE_SENSE_SIZE, &header);
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate 	if (status == 0) {
143*0Sstevel@tonic-gate 		if (page8->wce) {
144*0Sstevel@tonic-gate 			status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
145*0Sstevel@tonic-gate 				MODE_SENSE_PC_SAVED, (caddr_t)page8,
146*0Sstevel@tonic-gate 				MAX_MODE_SENSE_SIZE, &header);
147*0Sstevel@tonic-gate 			if (status != 0) {
148*0Sstevel@tonic-gate 				status = uscsi_mode_sense(cur_file,
149*0Sstevel@tonic-gate 				DAD_MODE_CACHE, MODE_SENSE_PC_CURRENT,
150*0Sstevel@tonic-gate 				(caddr_t)page8, MAX_MODE_SENSE_SIZE, &header);
151*0Sstevel@tonic-gate 			}
152*0Sstevel@tonic-gate 
153*0Sstevel@tonic-gate 			if (status == 0) {
154*0Sstevel@tonic-gate 				length = MODESENSE_PAGE_LEN(page8);
155*0Sstevel@tonic-gate 				sp_flags = MODE_SELECT_PF;
156*0Sstevel@tonic-gate 				if (page8->mode_page.ps) {
157*0Sstevel@tonic-gate 					sp_flags |= MODE_SELECT_SP;
158*0Sstevel@tonic-gate 				} else {
159*0Sstevel@tonic-gate 					err_print("\
160*0Sstevel@tonic-gate This setting is valid until next reset only. It is not saved permanently.\n");
161*0Sstevel@tonic-gate 				}
162*0Sstevel@tonic-gate 				page8->mode_page.ps = 0;
163*0Sstevel@tonic-gate 				page8->wce = 1;
164*0Sstevel@tonic-gate 				header.mode_header.length = 0;
165*0Sstevel@tonic-gate 				header.mode_header.device_specific = 0;
166*0Sstevel@tonic-gate 				status = uscsi_mode_select(cur_file,
167*0Sstevel@tonic-gate 					DAD_MODE_CACHE, sp_flags,
168*0Sstevel@tonic-gate 					(caddr_t)page8, length, &header);
169*0Sstevel@tonic-gate 				if (status != 0) {
170*0Sstevel@tonic-gate 					err_print("Mode select failed\n");
171*0Sstevel@tonic-gate 					return (0);
172*0Sstevel@tonic-gate 				}
173*0Sstevel@tonic-gate 			}
174*0Sstevel@tonic-gate 		} else {
175*0Sstevel@tonic-gate 			err_print("Write cache setting is not changeable\n");
176*0Sstevel@tonic-gate 		}
177*0Sstevel@tonic-gate 	}
178*0Sstevel@tonic-gate 	if (status != 0) {
179*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
180*0Sstevel@tonic-gate 	}
181*0Sstevel@tonic-gate 	return (0);
182*0Sstevel@tonic-gate }
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate int
185*0Sstevel@tonic-gate ca_write_disable()
186*0Sstevel@tonic-gate {
187*0Sstevel@tonic-gate 	struct mode_cache		*page8;
188*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
189*0Sstevel@tonic-gate 	int				status;
190*0Sstevel@tonic-gate 	int				length;
191*0Sstevel@tonic-gate 	int				sp_flags;
192*0Sstevel@tonic-gate 	union {
193*0Sstevel@tonic-gate 		struct mode_cache	page8;
194*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
195*0Sstevel@tonic-gate 	} u_page8;
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
200*0Sstevel@tonic-gate 			MODE_SENSE_PC_CHANGEABLE, (caddr_t)page8,
201*0Sstevel@tonic-gate 			MAX_MODE_SENSE_SIZE, &header);
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate 	if (status == 0) {
204*0Sstevel@tonic-gate 		if (page8->wce) {
205*0Sstevel@tonic-gate 			status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
206*0Sstevel@tonic-gate 				MODE_SENSE_PC_SAVED, (caddr_t)page8,
207*0Sstevel@tonic-gate 				MAX_MODE_SENSE_SIZE, &header);
208*0Sstevel@tonic-gate 			if (status != 0) {
209*0Sstevel@tonic-gate 				status = uscsi_mode_sense(cur_file,
210*0Sstevel@tonic-gate 				DAD_MODE_CACHE, MODE_SENSE_PC_CURRENT,
211*0Sstevel@tonic-gate 				(caddr_t)page8, MAX_MODE_SENSE_SIZE, &header);
212*0Sstevel@tonic-gate 			}
213*0Sstevel@tonic-gate 
214*0Sstevel@tonic-gate 			if (status == 0) {
215*0Sstevel@tonic-gate 				length = MODESENSE_PAGE_LEN(page8);
216*0Sstevel@tonic-gate 				sp_flags = MODE_SELECT_PF;
217*0Sstevel@tonic-gate 				if (page8->mode_page.ps) {
218*0Sstevel@tonic-gate 					sp_flags |= MODE_SELECT_SP;
219*0Sstevel@tonic-gate 				} else {
220*0Sstevel@tonic-gate 					err_print("\
221*0Sstevel@tonic-gate This setting is valid until next reset only. It is not saved permanently.\n");
222*0Sstevel@tonic-gate 				}
223*0Sstevel@tonic-gate 				page8->mode_page.ps = 0;
224*0Sstevel@tonic-gate 				page8->wce = 0;
225*0Sstevel@tonic-gate 				header.mode_header.length = 0;
226*0Sstevel@tonic-gate 				header.mode_header.device_specific = 0;
227*0Sstevel@tonic-gate 				status = uscsi_mode_select(cur_file,
228*0Sstevel@tonic-gate 					DAD_MODE_CACHE, sp_flags,
229*0Sstevel@tonic-gate 					(caddr_t)page8, length, &header);
230*0Sstevel@tonic-gate 				if (status != 0) {
231*0Sstevel@tonic-gate 					err_print("Mode select failed\n");
232*0Sstevel@tonic-gate 					return (0);
233*0Sstevel@tonic-gate 				}
234*0Sstevel@tonic-gate 			}
235*0Sstevel@tonic-gate 		} else {
236*0Sstevel@tonic-gate 			err_print("Write cache setting is not changeable\n");
237*0Sstevel@tonic-gate 		}
238*0Sstevel@tonic-gate 	}
239*0Sstevel@tonic-gate 	if (status != 0) {
240*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
241*0Sstevel@tonic-gate 	}
242*0Sstevel@tonic-gate 	return (0);
243*0Sstevel@tonic-gate }
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate int
246*0Sstevel@tonic-gate ca_read_display()
247*0Sstevel@tonic-gate {
248*0Sstevel@tonic-gate 	struct mode_cache		*page8;
249*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
250*0Sstevel@tonic-gate 	int				status;
251*0Sstevel@tonic-gate 	union {
252*0Sstevel@tonic-gate 		struct mode_cache	page8;
253*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
254*0Sstevel@tonic-gate 	} u_page8;
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
257*0Sstevel@tonic-gate 
258*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
259*0Sstevel@tonic-gate 			MODE_SENSE_PC_CURRENT, (caddr_t)page8,
260*0Sstevel@tonic-gate 			MAX_MODE_SENSE_SIZE, &header);
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate 	if (status == 0) {
263*0Sstevel@tonic-gate 		if (page8->rcd) {
264*0Sstevel@tonic-gate 			fmt_print("Read Cache is disabled\n");
265*0Sstevel@tonic-gate 		} else {
266*0Sstevel@tonic-gate 			fmt_print("Read Cache is enabled\n");
267*0Sstevel@tonic-gate 		}
268*0Sstevel@tonic-gate 	} else {
269*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
270*0Sstevel@tonic-gate 	}
271*0Sstevel@tonic-gate 	return (0);
272*0Sstevel@tonic-gate }
273*0Sstevel@tonic-gate 
274*0Sstevel@tonic-gate int
275*0Sstevel@tonic-gate ca_read_enable()
276*0Sstevel@tonic-gate {
277*0Sstevel@tonic-gate 	struct mode_cache		*page8;
278*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
279*0Sstevel@tonic-gate 	int				status;
280*0Sstevel@tonic-gate 	int				length;
281*0Sstevel@tonic-gate 	int				sp_flags;
282*0Sstevel@tonic-gate 	union {
283*0Sstevel@tonic-gate 		struct mode_cache	page8;
284*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
285*0Sstevel@tonic-gate 	} u_page8;
286*0Sstevel@tonic-gate 
287*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
288*0Sstevel@tonic-gate 
289*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
290*0Sstevel@tonic-gate 			MODE_SENSE_PC_CHANGEABLE, (caddr_t)page8,
291*0Sstevel@tonic-gate 			MAX_MODE_SENSE_SIZE, &header);
292*0Sstevel@tonic-gate 
293*0Sstevel@tonic-gate 	if (status == 0) {
294*0Sstevel@tonic-gate 		if (page8->rcd) {
295*0Sstevel@tonic-gate 			status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
296*0Sstevel@tonic-gate 				MODE_SENSE_PC_SAVED, (caddr_t)page8,
297*0Sstevel@tonic-gate 				MAX_MODE_SENSE_SIZE, &header);
298*0Sstevel@tonic-gate 			if (status != 0) {
299*0Sstevel@tonic-gate 				status = uscsi_mode_sense(cur_file,
300*0Sstevel@tonic-gate 				DAD_MODE_CACHE, MODE_SENSE_PC_CURRENT,
301*0Sstevel@tonic-gate 				(caddr_t)page8, MAX_MODE_SENSE_SIZE, &header);
302*0Sstevel@tonic-gate 			}
303*0Sstevel@tonic-gate 
304*0Sstevel@tonic-gate 			if (status == 0) {
305*0Sstevel@tonic-gate 				length = MODESENSE_PAGE_LEN(page8);
306*0Sstevel@tonic-gate 				sp_flags = MODE_SELECT_PF;
307*0Sstevel@tonic-gate 				if (page8->mode_page.ps) {
308*0Sstevel@tonic-gate 					sp_flags |= MODE_SELECT_SP;
309*0Sstevel@tonic-gate 				} else {
310*0Sstevel@tonic-gate 					err_print("\
311*0Sstevel@tonic-gate This setting is valid until next reset only. It is not saved permanently.\n");
312*0Sstevel@tonic-gate 				}
313*0Sstevel@tonic-gate 				page8->mode_page.ps = 0;
314*0Sstevel@tonic-gate 				page8->rcd = 0;
315*0Sstevel@tonic-gate 				header.mode_header.length = 0;
316*0Sstevel@tonic-gate 				header.mode_header.device_specific = 0;
317*0Sstevel@tonic-gate 				status = uscsi_mode_select(cur_file,
318*0Sstevel@tonic-gate 					DAD_MODE_CACHE, sp_flags,
319*0Sstevel@tonic-gate 					(caddr_t)page8, length, &header);
320*0Sstevel@tonic-gate 				if (status != 0) {
321*0Sstevel@tonic-gate 					err_print("Mode select failed\n");
322*0Sstevel@tonic-gate 					return (0);
323*0Sstevel@tonic-gate 				}
324*0Sstevel@tonic-gate 			}
325*0Sstevel@tonic-gate 		} else {
326*0Sstevel@tonic-gate 			err_print("Read cache setting is not changeable\n");
327*0Sstevel@tonic-gate 		}
328*0Sstevel@tonic-gate 	}
329*0Sstevel@tonic-gate 	if (status != 0) {
330*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
331*0Sstevel@tonic-gate 	}
332*0Sstevel@tonic-gate 	return (0);
333*0Sstevel@tonic-gate }
334*0Sstevel@tonic-gate 
335*0Sstevel@tonic-gate int
336*0Sstevel@tonic-gate ca_read_disable()
337*0Sstevel@tonic-gate {
338*0Sstevel@tonic-gate 	struct mode_cache		*page8;
339*0Sstevel@tonic-gate 	struct scsi_ms_header		header;
340*0Sstevel@tonic-gate 	int				status;
341*0Sstevel@tonic-gate 	int				length;
342*0Sstevel@tonic-gate 	int				sp_flags;
343*0Sstevel@tonic-gate 	union {
344*0Sstevel@tonic-gate 		struct mode_cache	page8;
345*0Sstevel@tonic-gate 		char			rawbuf[MAX_MODE_SENSE_SIZE];
346*0Sstevel@tonic-gate 	} u_page8;
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate 	page8 = &u_page8.page8;
349*0Sstevel@tonic-gate 
350*0Sstevel@tonic-gate 	status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
351*0Sstevel@tonic-gate 		MODE_SENSE_PC_CHANGEABLE, (caddr_t)page8,
352*0Sstevel@tonic-gate 		MAX_MODE_SENSE_SIZE, &header);
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate 	if (status == 0) {
355*0Sstevel@tonic-gate 		if (page8->rcd) {
356*0Sstevel@tonic-gate 			status = uscsi_mode_sense(cur_file, DAD_MODE_CACHE,
357*0Sstevel@tonic-gate 				MODE_SENSE_PC_SAVED, (caddr_t)page8,
358*0Sstevel@tonic-gate 				MAX_MODE_SENSE_SIZE, &header);
359*0Sstevel@tonic-gate 			if (status != 0) {
360*0Sstevel@tonic-gate 				status = uscsi_mode_sense(cur_file,
361*0Sstevel@tonic-gate 				DAD_MODE_CACHE, MODE_SENSE_PC_CURRENT,
362*0Sstevel@tonic-gate 				(caddr_t)page8, MAX_MODE_SENSE_SIZE, &header);
363*0Sstevel@tonic-gate 			}
364*0Sstevel@tonic-gate 
365*0Sstevel@tonic-gate 			if (status == 0) {
366*0Sstevel@tonic-gate 				length = MODESENSE_PAGE_LEN(page8);
367*0Sstevel@tonic-gate 				sp_flags = MODE_SELECT_PF;
368*0Sstevel@tonic-gate 				if (page8->mode_page.ps) {
369*0Sstevel@tonic-gate 					sp_flags |= MODE_SELECT_SP;
370*0Sstevel@tonic-gate 				} else {
371*0Sstevel@tonic-gate 					err_print("\
372*0Sstevel@tonic-gate This setting is valid until next reset only. It is not saved permanently.\n");
373*0Sstevel@tonic-gate 				}
374*0Sstevel@tonic-gate 				page8->mode_page.ps = 0;
375*0Sstevel@tonic-gate 				page8->rcd = 1;
376*0Sstevel@tonic-gate 				header.mode_header.length = 0;
377*0Sstevel@tonic-gate 				header.mode_header.device_specific = 0;
378*0Sstevel@tonic-gate 				status = uscsi_mode_select(cur_file,
379*0Sstevel@tonic-gate 					DAD_MODE_CACHE, sp_flags,
380*0Sstevel@tonic-gate 					(caddr_t)page8, length, &header);
381*0Sstevel@tonic-gate 				if (status != 0) {
382*0Sstevel@tonic-gate 					err_print("Mode select failed\n");
383*0Sstevel@tonic-gate 					return (0);
384*0Sstevel@tonic-gate 				}
385*0Sstevel@tonic-gate 			}
386*0Sstevel@tonic-gate 		} else {
387*0Sstevel@tonic-gate 			err_print("Read cache setting is not changeable\n");
388*0Sstevel@tonic-gate 		}
389*0Sstevel@tonic-gate 	}
390*0Sstevel@tonic-gate 	if (status != 0) {
391*0Sstevel@tonic-gate 		err_print("Mode sense failed.\n");
392*0Sstevel@tonic-gate 	}
393*0Sstevel@tonic-gate 	return (0);
394*0Sstevel@tonic-gate }
395