github.com/MerlinKodo/gvisor@v0.0.0-20231110090155-957f62ecf90e/pkg/abi/linux/ioctl.go (about) 1 // Copyright 2018 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package linux 16 17 // ioctl(2) requests provided by asm-generic/ioctls.h 18 // 19 // These are ordered by request number (low byte). 20 const ( 21 TCGETS = 0x00005401 22 TCSETS = 0x00005402 23 TCSETSW = 0x00005403 24 TCSETSF = 0x00005404 25 TCSBRK = 0x00005409 26 TIOCEXCL = 0x0000540c 27 TIOCNXCL = 0x0000540d 28 TIOCSCTTY = 0x0000540e 29 TIOCGPGRP = 0x0000540f 30 TIOCSPGRP = 0x00005410 31 TIOCOUTQ = 0x00005411 32 TIOCSTI = 0x00005412 33 TIOCGWINSZ = 0x00005413 34 TIOCSWINSZ = 0x00005414 35 TIOCMGET = 0x00005415 36 TIOCMBIS = 0x00005416 37 TIOCMBIC = 0x00005417 38 TIOCMSET = 0x00005418 39 TIOCINQ = 0x0000541b 40 FIONREAD = TIOCINQ 41 FIONBIO = 0x00005421 42 TIOCSETD = 0x00005423 43 TIOCNOTTY = 0x00005422 44 TIOCGETD = 0x00005424 45 TCSBRKP = 0x00005425 46 TIOCSBRK = 0x00005427 47 TIOCCBRK = 0x00005428 48 TIOCGSID = 0x00005429 49 TIOCGPTN = 0x80045430 50 TIOCSPTLCK = 0x40045431 51 TIOCGDEV = 0x80045432 52 TIOCVHANGUP = 0x00005437 53 TCFLSH = 0x0000540b 54 TIOCCONS = 0x0000541d 55 TIOCSSERIAL = 0x0000541f 56 TIOCGEXCL = 0x80045440 57 TIOCGPTPEER = 0x80045441 58 TIOCGICOUNT = 0x0000545d 59 FIONCLEX = 0x00005450 60 FIOCLEX = 0x00005451 61 FIOASYNC = 0x00005452 62 FIOSETOWN = 0x00008901 63 SIOCSPGRP = 0x00008902 64 FIOGETOWN = 0x00008903 65 SIOCGPGRP = 0x00008904 66 ) 67 68 // ioctl(2) requests provided by uapi/linux/sockios.h 69 const ( 70 SIOCGIFNAME = 0x8910 71 SIOCGIFCONF = 0x8912 72 SIOCGIFFLAGS = 0x8913 73 SIOCGIFADDR = 0x8915 74 SIOCGIFDSTADDR = 0x8917 75 SIOCGIFBRDADDR = 0x8919 76 SIOCGIFNETMASK = 0x891b 77 SIOCGIFMETRIC = 0x891d 78 SIOCGIFMTU = 0x8921 79 SIOCGIFMEM = 0x891f 80 SIOCGIFHWADDR = 0x8927 81 SIOCGIFINDEX = 0x8933 82 SIOCGIFPFLAGS = 0x8935 83 SIOCGIFTXQLEN = 0x8942 84 SIOCETHTOOL = 0x8946 85 SIOCGMIIPHY = 0x8947 86 SIOCGMIIREG = 0x8948 87 SIOCGIFMAP = 0x8970 88 ) 89 90 // ioctl(2) requests provided by uapi/asm-generic/sockios.h 91 const ( 92 SIOCGSTAMP = 0x8906 93 ) 94 95 // ioctl(2) directions. Used to calculate requests number. 96 // Constants from asm-generic/ioctl.h. 97 const ( 98 IOC_NONE = 0 99 IOC_WRITE = 1 100 IOC_READ = 2 101 ) 102 103 // Constants from asm-generic/ioctl.h. 104 const ( 105 IOC_NRBITS = 8 106 IOC_TYPEBITS = 8 107 IOC_SIZEBITS = 14 108 IOC_DIRBITS = 2 109 110 IOC_NRSHIFT = 0 111 IOC_TYPESHIFT = IOC_NRSHIFT + IOC_NRBITS 112 IOC_SIZESHIFT = IOC_TYPESHIFT + IOC_TYPEBITS 113 IOC_DIRSHIFT = IOC_SIZESHIFT + IOC_SIZEBITS 114 ) 115 116 // IOC outputs the result of _IOC macro in include/uapi/asm-generic/ioctl.h. 117 func IOC(dir, typ, nr, size uint32) uint32 { 118 return uint32(dir)<<IOC_DIRSHIFT | typ<<IOC_TYPESHIFT | nr<<IOC_NRSHIFT | size<<IOC_SIZESHIFT 119 } 120 121 // IO outputs the result of _IO macro in include/uapi/asm-generic/ioctl.h. 122 func IO(typ, nr uint32) uint32 { 123 return IOC(IOC_NONE, typ, nr, 0) 124 } 125 126 // IOR outputs the result of _IOR macro in include/uapi/asm-generic/ioctl.h. 127 func IOR(typ, nr, size uint32) uint32 { 128 return IOC(IOC_READ, typ, nr, size) 129 } 130 131 // IOW outputs the result of _IOW macro in include/uapi/asm-generic/ioctl.h. 132 func IOW(typ, nr, size uint32) uint32 { 133 return IOC(IOC_WRITE, typ, nr, size) 134 } 135 136 // IOWR outputs the result of _IOWR macro in include/uapi/asm-generic/ioctl.h. 137 func IOWR(typ, nr, size uint32) uint32 { 138 return IOC(IOC_READ|IOC_WRITE, typ, nr, size) 139 } 140 141 // IOC_NR outputs the result of IOC_NR macro in 142 // include/uapi/asm-generic/ioctl.h. 143 func IOC_NR(nr uint32) uint32 { 144 return (nr >> IOC_NRSHIFT) & ((1 << IOC_NRBITS) - 1) 145 } 146 147 // IOC_SIZE outputs the result of IOC_SIZE macro in 148 // include/uapi/asm-generic/ioctl.h. 149 func IOC_SIZE(nr uint32) uint32 { 150 return (nr >> IOC_SIZESHIFT) & ((1 << IOC_SIZEBITS) - 1) 151 } 152 153 // Kcov ioctls from include/uapi/linux/kcov.h. 154 var ( 155 KCOV_INIT_TRACE = IOR('c', 1, 8) 156 KCOV_ENABLE = IO('c', 100) 157 KCOV_DISABLE = IO('c', 101) 158 ) 159 160 // Kcov trace types from include/uapi/linux/kcov.h. 161 const ( 162 KCOV_TRACE_PC = 0 163 KCOV_TRACE_CMP = 1 164 ) 165 166 // Kcov state constants from include/uapi/linux/kcov.h. 167 const ( 168 KCOV_MODE_DISABLED = 0 169 KCOV_MODE_INIT = 1 170 KCOV_MODE_TRACE_PC = 2 171 KCOV_MODE_TRACE_CMP = 3 172 )