shithub: riscv

ref: 2c6cc121339ade33ac5aa4b46356df1cd5469fbe
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