shithub: riscv

ref: 15140dcce2b1670af6f4d78ddb5cf52444107aee
dir: /sys/src/cmd/nusb/disk/mkscsierrs/

View raw version
#!/bin/rc

cat <<EOF
#include <u.h>
#include <libc.h>

typedef struct Err Err;
struct Err
{
	int n;
	char *s;
};

static Err scsierrs[] = {
EOF

grep '^[0-9a-c][0-9a-c][0-9a-c][0-9a-c][ 	]' /sys/lib/scsicodes |
	sed -e 's/^(....) (.*)/	{0x\1,	"\2"},\n/'
cat <<EOF
};

char*
scsierrmsg(int n)
{
	int i;

	for(i = 0; i < nelem(scsierrs); i++)
		if(scsierrs[i].n == n)
			return scsierrs[i].s;
	return "scsi error";
}
EOF