bs_sheepdog.c: fix an unsafe strncpy() call

The strncpy() call doesn't take a null terminator into account. On
some environment, it conflicts with __builtin___strncpy_chk() and gcc
warns.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Add an array that describes which opcodes are supported

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG
only supports a subset and lacks the following opcodes:
            WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16
            WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to
process and which commands should fail with invalid op code and allows
SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different
backends and where some backends only support a subset of the commands

Changed by FUJITA Tomonori:

- use ARRAY_SIZE()
- use Linux bitmap functions
- put the supported ops array into struct backingstore_template

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
REPORT SUPPORTED OPCODES: Only return opcodes supported by the backend.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
use NR_SCSI_OPCODES definition

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: fix gcc warning at sd_open()

This fixes the following warning at sd_open function, which happens
because gcc isn't always perfect with determining whether a variable
is used uninitialized:

cc -c -DUSE_SIGNALFD -DUSE_TIMERFD -D_GNU_SOURCE -I. -g -O2
-fno-strict-aliasing -Wall -Wstrict-prototypes -fPIC DTGT_VERSION=\"\"
--DBSDIR=\"/lib/tgt/backing-store\" bs_sheepdog.c o bs_sheepdog.o
bs_sheepdog.c: In function 'sd_open':
bs_sheepdog.c:920: warning: 'saveptr' may be used uninitialized in
this function

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: fix length modifier of eprintf in read_write_object()

On 32-bit environments, the sheepdog driver causes the following
compile warning because "%lx" is used for uint64_t type variables:

cc -c -DUSE_SIGNALFD -DUSE_TIMERFD -D_GNU_SOURCE -I. -g -O2
-fno-strict-aliasing -Wall -Wstrict-prototypes -fPIC
-DTGT_VERSION=\"\" -DBSDIR=\"/lib/tgt/backing-store\" bs_sheepdog.c -o
bs_sheepdog.o
bs_sheepdog.c: In function 'read_write_object':
bs_sheepdog.c:682: warning: format '%lx' expects type 'long unsigned
int', but argument 5 has type 'uint64_t'
bs_sheepdog.c:682: warning: format '%lx' expects type 'long unsigned
int', but argument 6 has type 'uint64_t'

This fixes the issue by using PRIx64 length modifier instead of "%lx".

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>