shithub: riscv

ref: 61f4c085c402af665b436f6d010d61107551d8a3
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