1799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin/* 2799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * This file is part of ioctl_block strace test. 3799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 4799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org> 539bac055674d23770b9a724221b728e443196ea7Elliott Hughes * Copyright (c) 2016-2017 The strace developers. 6799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * All rights reserved. 7799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 8799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * Redistribution and use in source and binary forms, with or without 9799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * modification, are permitted provided that the following conditions 10799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * are met: 11799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 1. Redistributions of source code must retain the above copyright 12799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * notice, this list of conditions and the following disclaimer. 13799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 2. Redistributions in binary form must reproduce the above copyright 14799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * notice, this list of conditions and the following disclaimer in the 15799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * documentation and/or other materials provided with the distribution. 16799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 3. The name of the author may not be used to endorse or promote products 17799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * derived from this software without specific prior written permission. 18799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * 19799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin */ 30799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 31799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include "tests.h" 32799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <errno.h> 33799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <inttypes.h> 34799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <stdio.h> 35799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <string.h> 36799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <sys/ioctl.h> 37799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <linux/fs.h> 38799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include <linux/blkpg.h> 39799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef HAVE_STRUCT_BLK_USER_TRACE_SETUP 40799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin# include <linux/blktrace_api.h> 41799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 42799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#include "xlat.h" 43799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 44799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levinstatic const unsigned int magic = 0xdeadbeef; 45d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesstatic const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL; 46799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 47799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levinstatic struct xlat block_argless[] = { 48799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin XLAT(BLKRRPART), 49799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin XLAT(BLKFLSBUF), 50799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKTRACESTART 51799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin XLAT(BLKTRACESTART), 52799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 53799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKTRACESTOP 54799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin XLAT(BLKTRACESTOP), 55799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 56799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKTRACETEARDOWN 57799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin XLAT(BLKTRACETEARDOWN), 58799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 59799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin}; 60799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 61dc75b01004a0588c1eb3bc26d7248a6e473b2cddElliott Hughes#define TEST_NULL_ARG(cmd) \ 62dc75b01004a0588c1eb3bc26d7248a6e473b2cddElliott Hughes do { \ 63dc75b01004a0588c1eb3bc26d7248a6e473b2cddElliott Hughes ioctl(-1, cmd, 0); \ 64dc75b01004a0588c1eb3bc26d7248a6e473b2cddElliott Hughes printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", #cmd); \ 65dc75b01004a0588c1eb3bc26d7248a6e473b2cddElliott Hughes } while (0) 66799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 67799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levinint 68799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levinmain(void) 69799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin{ 70799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKBSZGET); 71799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKBSZSET); 72799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKFRAGET); 73799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKGETSIZE); 74799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKGETSIZE64); 75799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKPG); 76799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKRAGET); 77799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKROGET); 78799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKROSET); 79799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKSECTGET); 80799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKSECTGET); 81799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKSSZGET); 82799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKALIGNOFF 83799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKALIGNOFF); 84799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 85799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKDISCARD 86799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKDISCARD); 87799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 88799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKDISCARDZEROES 89799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKDISCARDZEROES); 90799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 91799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKIOMIN 92799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKIOMIN); 93799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 94799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKIOOPT 95799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKIOOPT); 96799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 97799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKPBSZGET 98799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKPBSZGET); 99799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 100799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKROTATIONAL 101799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKROTATIONAL); 102799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 103799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKSECDISCARD 104799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKSECDISCARD); 105799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 106799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKZEROOUT 107799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKZEROOUT); 108799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 109799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#if defined BLKTRACESETUP && defined HAVE_STRUCT_BLK_USER_TRACE_SETUP 110799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin TEST_NULL_ARG(BLKTRACESETUP); 111799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 112799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 113799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKRASET, lmagic); 114799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKRASET, %lu) = -1 EBADF (%m)\n", lmagic); 115799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 116799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKFRASET, lmagic); 117799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKFRASET, %lu) = -1 EBADF (%m)\n", lmagic); 118799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 11939bac055674d23770b9a724221b728e443196ea7Elliott Hughes TAIL_ALLOC_OBJECT_CONST_PTR(int, val_int); 120799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin *val_int = magic; 121799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 122799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKROSET, val_int); 123799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKROSET, [%d]) = -1 EBADF (%m)\n", *val_int); 124799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 125799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKBSZSET, val_int); 126799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKBSZSET, [%d]) = -1 EBADF (%m)\n", *val_int); 127799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 128799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin uint64_t *pair_int64 = tail_alloc(sizeof(*pair_int64) * 2); 129d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes pair_int64[0] = 0xdeadbeefbadc0dedULL; 130d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes pair_int64[1] = 0xfacefeedcafef00dULL; 131799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 132799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKDISCARD 133799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKDISCARD, pair_int64); 134799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKDISCARD, [%" PRIu64 ", %" PRIu64 "])" 135799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin " = -1 EBADF (%m)\n", pair_int64[0], pair_int64[1]); 136799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 137799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 138799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKSECDISCARD 139799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKSECDISCARD, pair_int64); 140799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKSECDISCARD, [%" PRIu64 ", %" PRIu64 "])" 141799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin " = -1 EBADF (%m)\n", pair_int64[0], pair_int64[1]); 142799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 143799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 144799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#ifdef BLKZEROOUT 145799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKZEROOUT, pair_int64); 146799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKZEROOUT, [%" PRIu64 ", %" PRIu64 "])" 147799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin " = -1 EBADF (%m)\n", pair_int64[0], pair_int64[1]); 148799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 149799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 15039bac055674d23770b9a724221b728e443196ea7Elliott Hughes TAIL_ALLOC_OBJECT_CONST_PTR(struct blkpg_ioctl_arg, blkpg); 151799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->op = 3; 152799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->flags = 0xdeadbeef; 153799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->datalen = 0xbadc0ded; 154d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes blkpg->data = (void *) (unsigned long) 0xcafef00dfffffeedULL; 155799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 156799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKPG, blkpg); 157799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKPG, {%s, flags=%d, datalen=%d" 158799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ", data=%#lx}) = -1 EBADF (%m)\n", 159799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin "BLKPG_RESIZE_PARTITION", blkpg->flags, blkpg->datalen, 160799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin (unsigned long) blkpg->data); 161799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 16239bac055674d23770b9a724221b728e443196ea7Elliott Hughes TAIL_ALLOC_OBJECT_CONST_PTR(struct blkpg_partition, bp); 163d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes bp->start = 0xfac1fed2dad3bef4ULL; 164d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes bp->length = 0xfac5fed6dad7bef8ULL; 165799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin bp->pno = magic; 166799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin memset(bp->devname, 'A', sizeof(bp->devname)); 167799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin memset(bp->volname, 'B', sizeof(bp->volname)); 168799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->op = 1; 169799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->data = bp; 170799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 171799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKPG, blkpg); 172799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKPG, {%s, flags=%d, datalen=%d" 173799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ", data={start=%lld, length=%lld, pno=%d" 174799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ", devname=\"%.*s\", volname=\"%.*s\"}})" 175799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin " = -1 EBADF (%m)\n", 176799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin "BLKPG_ADD_PARTITION", 177799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin blkpg->flags, blkpg->datalen, 178799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin bp->start, bp->length, bp->pno, 179799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin (int) sizeof(bp->devname) - 1, bp->devname, 180799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin (int) sizeof(bp->volname) - 1, bp->volname); 181799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 182799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#if defined BLKTRACESETUP && defined HAVE_STRUCT_BLK_USER_TRACE_SETUP 18339bac055674d23770b9a724221b728e443196ea7Elliott Hughes TAIL_ALLOC_OBJECT_CONST_PTR(struct blk_user_trace_setup, buts); 184d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes fill_memory(buts, sizeof(*buts)); 185799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 186799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, BLKTRACESETUP, buts); 187799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, BLKTRACESETUP, {act_mask=%hu, buf_size=%u, buf_nr=%u" 188799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%u})" 189799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin " = -1 EBADF (%m)\n", 190799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin buts->act_mask, buts->buf_size, buts->buf_nr, 191799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin buts->start_lba, buts->end_lba, buts->pid); 192799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin#endif 193799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 194799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin unsigned int i; 195799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin for (i = 0; i < ARRAY_SIZE(block_argless); ++i) { 196799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, (unsigned long) block_argless[i].val, lmagic); 197799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, %s) = -1 EBADF (%m)\n", block_argless[i].str); 198799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin } 199799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 200799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin ioctl(-1, _IOC(_IOC_READ, 0x12, 0xfe, 0xff), lmagic); 201799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n", 202799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin "_IOC(_IOC_READ, 0x12, 0xfe, 0xff)", lmagic); 203799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin 204799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin puts("+++ exited with 0 +++"); 205799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin return 0; 206799b22a27d8d0a2d449b4de1aa937c6834272390Dmitry V. Levin} 207