⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_fstatus.c

📁 对SCSI设备 直接存取的通用库
💻 C
字号:
/*  sc_fstatus -- print status/error message to stderr  Copyright (C) 1996 Dieter Baron and Armin Obersteiner  This file is part of libscsi, a library for direct scsi device access  The authors can be contacted at	<dillo@giga.or.at>	<armin.obersteiner@giga.or.at>  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include <stdio.h>#include <errno.h>#include <scsi/scsi.h>static char *sc__err[] = {    "good",    "timeout",    "busy",    "check condition"};static int sc__err_max = sizeof(sc__err)/sizeof(sc__err[0]);    static char *sc__skey[] = {    /* 0 */ "no sense",	    "recovered error",	    "not ready",	    "medium error",    /* 4 */ "hardware error",	    "illegal request",	    "unit attention",	    "data protect",    /* 8 */ "blank check",	    "vendor specivic",	    "copy aborted",	    "aborted command",    /* c */ "equal",	    "volume overflow",	    "miscompare"};static int sc__skey_max = sizeof(sc__skey)/sizeof(sc__skey[0]);#if 0static char *sc__scode[] = {    /* 0 */ ""};	    static int sc__scode_max = sizeof(sc__scode)/sizeof(sc__scode[0]);#endif#define FPRE	(fprintf(f, "%s%s%s: ", \			 (prg ? prg : ""), (prg ? ": " : ""), \			 msg))intsc_fstatus(SCSI *s, FILE *f, char *prg, char *msg, int vlevel){    if (msg == NULL)	msg = "sc_send";	        switch (s->sense.status) {    case -1:	FPRE;	fprintf(f, "%s\n", strerror(errno));	break;	    case 1:    case 2:	FPRE;	fprintf(f, "%s\n", sc__err[s->sense.status]);	break;    case 0:	if (s->sense.data.skey == 0)	    return;	/* fallthru */    case 3:	FPRE;	if (s->sense.len < 2)	    fprintf(f, "sense error\n");	else {	    if (s->sense.data.skey > sc__skey_max)		fprintf(f, "unknown sense key %d", s->sense.data.skey);	    else {		fprintf(f, "%s", sc__skey[s->sense.data.skey]);		if (vlevel & 2)		    fprintf(f, "<%02x>", s->sense.data.skey);	    }	    if (s->sense.len >= 12) {#if 0		if (s->sense.data[2] > sc__scode_max)		    fprintf(f, "/unknown sense code %02x",			    s->sense.data[12]);		else {		    fprintf(f, "%s", sc__scode[s->sense.data[12]]);		    if (vlevel & 1)			fprintf(f, "<%02x>",				s->sense.data[12]);		}#endif		fprintf(f, "/%02x", s->sense.data.asc);	    }	    if (s->sense.len >= 13 && s->sense.data.asq)		fprintf(f, "/%0x2", s->sense.data.asq);	    fprintf(f, "\n");	}    }        if (s->sense.len && (vlevel & 1)) {	int i;	fprintf(f, " sense:\t");	for (i=0; i<s->sense.len; i++) {	    fprintf(f, "%02x ", ((u_char *)&s->sense.data)[i]);	    if (i%16==15 && i<s->sense.len-1)		fprintf(f, "\n\t");	}	fprintf(f, "\n");    }    return ferror(f);}	    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -