Re: [PATCH/RFC v3] allow userspace to modify scsi command filter on per device basis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 26, 2008 at 7:36 AM, FUJITA Tomonori
<fujita.tomonori@xxxxxxxxxxxxx> wrote:
>> Jens can we add merge this for .27 or does anyone still has objections?
>
> I think that this patch makes sg's permission stricter. So this could
> break the existing user-space applications.

Yes, it seems to have broken a simple routine I had to retrieve the
disk serial number from /dev/sg0.  Works fine if I run the ioctl on
/dev/sda.

Can we consider this a regression or am I doing something wrong?  The
following returns 2 on post-2.6.26 mainline and 0 otherwise.

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

int scsi_get_serial(int fd, void *buf, size_t buf_len)
{
        unsigned char inq_cmd[] = {INQUIRY, 1, 0x80, 0, buf_len, 0};
        unsigned char sense[32];
        struct sg_io_hdr io_hdr;

        memset(&io_hdr, 0, sizeof(io_hdr));
        io_hdr.interface_id = 'S';
        io_hdr.cmdp = inq_cmd;
        io_hdr.cmd_len = sizeof(inq_cmd);
        io_hdr.dxferp = buf;
        io_hdr.dxfer_len = buf_len;
        io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
        io_hdr.sbp = sense;
        io_hdr.mx_sb_len = sizeof(sense);
        io_hdr.timeout = 5000;

        return ioctl(fd, SG_IO, &io_hdr);
}

int main(void)
{
        char buf[255];
        int fd;
        int ret;

        fd = open("/dev/sda", O_RDONLY);
        ret = scsi_get_serial(fd, buf, sizeof(buf));
        if (ret != 0)
                return 1;
        fd = open("/dev/sg0", O_RDONLY);
        ret = scsi_get_serial(fd, buf, sizeof(buf));
        if (ret != 0)
                return 2;

        return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux