shithub: riscv

ref: 986886f2b8ab4a7e1b3d66e99934d8fdab537be9
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