On Wed, Jul 05, 2017 at 10:06:49AM +0100, Chris Clayton wrote:
> I'll do this  and send dmesg(?) output as soon as I've got scsi_logging_level 
> installed.

Hi Chris,

does this reproducer work (i.e. output FAIL) for you?

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <scsi/sg.h>

int main(int argc, char **argv)
{
        int fd;
        int rc;
        int rsz = 131072;
        int tout = 10800000;
        char buf[42] = { 0 };

        if (argc != 2) {
                printf("usage: %s /dev/sgX\n", argv[0]);
                return 1;
        }

        fd = open(argv[1], O_RDWR);
        if (fd < 0) {
                perror("open");
                return 1;
        }

        rc = ioctl(fd, SG_SET_RESERVED_SIZE, &rsz);
        if (rc < 0) {
                perror("ioctl SG_SET_RESERVED_SIZE");
                goto out_close;
        }

        rc = ioctl(fd, SG_SET_TIMEOUT, &tout);
        if (rc < 0) {
                perror("ioctl SG_SET_TIMEOUT");
                goto out_close;
        }

        buf[4] = 'H';
        rc = write(fd, &buf, sizeof(buf));
        if (rc < 0) {
                perror("write");
                if (errno == EINVAL)
                        printf("FAIL\n");
                goto out_close;
        }

        printf("PASS\n");

out_close:
        close(fd);
}

-- 
Johannes Thumshirn                                          Storage
jthumsh...@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

Reply via email to