[PATCH] ioctl: implement NBD_* ioctl decoding

Elvira Khabirova lineprinter at altlinux.org
Sat Sep 22 09:52:29 UTC 2018


On Fri, 21 Sep 2018 22:39:29 +0200, Eugene Syromiatnikov <esyr at redhat.com> wrote:
> On Fri, Sep 21, 2018 at 04:42:50PM +0200, Elvira Khabirova wrote:
> > +	ioctl(-1, NBD_SET_FLAGS, 0);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, 0) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_HAS_FLAGS);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_HAS_FLAGS) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_READ_ONLY);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_READ_ONLY) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_FLUSH);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_FLUSH) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_FUA);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_FUA) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM) = -1 EBADF (%m)\n");
> > +	ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_CAN_MULTI_CONN);
> > +	printf("ioctl(-1, NBD_SET_FLAGS, NBD_FLAG_CAN_MULTI_CONN) = -1 EBADF (%m)\n");  
> 
> It is probably worth checking various flag combinations, including bits
> for which there are no constants defined, in order to avoid situation like
> v4.21~159.

Could you elaborate?

> ioctl(_IO(0xab, 0)) and ioctl(_IO(0xab, 11)) decoding is also probably worth
> checking.

ioctl(_IO(0xab, 0)) is NBD_SET_SOCK.

> NBD_MAGIC is probably worth adding to xlat/fsmagic.in. I'm not sure,
> however, as it's a private definition. (Funnily enough,
> Documentation/process/magic-number.rst mentions that it is declared
> under the name LO_MAGIC in the file "include/linux/nbd.h" which is not
> true at all.)

NBD_MAGIC is not an fsmagic; nbd does not care about filesystems.


More information about the Strace-devel mailing list