static BOOL Nonblocking_Mode(SOCKET sock) { // Set non-blocking mode. Return TRUE if no error. #ifdef FIONBIO long mode = 1; return !IOCTL(sock, FIONBIO, &mode); #else int flags; flags = fcntl(sock, F_GETFL, 0); flags |= O_NONBLOCK; //else flags &= ~O_NONBLOCK; fcntl(sock, F_SETFL, flags); return TRUE; #endif }
/* * monitor the connection to the host and make sure you know when * something is there */ static Error datafromhost (int dxfd, Pointer arg) { int b; /* if the pipe is closed, set the status */ if ((IOCTL(dxfd, FIONREAD, (char *)&b) < 0) || (b <= 0)) { host_status = HOST_CLOSED; return OK; } host_status = HOST_DATAREADY; return OK; }
static void sig_winch(int sig){ WINSTRUCT win; int omask; /* 920910 avoid SIGWINCH to be lost? signal(SIGWINCH,SIG_IGN); */ omask = sigsetmask(~(sigmask(SIGINT)|sigmask(SIGQUIT))); IOCTL(0,GETWINCOM,&win); if( init_win.ROWS != win.ROWS || init_win.COLS != win.COLS ){ set_termcapn("li",win.ROWS); set_termcapn("co",win.COLS); tcapInit(1); init_win = win; win_expand(win.ROWS); } fprintf(stderr,"WINCH: [%d] WINSIZE->%d\n",getpid(),win.ROWS); sigsetmask(omask); signal(SIGWINCH,sig_winch); }
int v4l2_dqbuf_input(enc_context_p ctx) { struct v4l2_buffer dqbuf; struct v4l2_plane planes[VIDEO_MAX_PLANES]; memset(&dqbuf, 0, sizeof(dqbuf)); memset(&planes, 0, sizeof(planes)); dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; dqbuf.memory = V4L2_MEMORY_MMAP; dqbuf.m.planes = planes; dqbuf.length = 3; while (IOCTL(VIDIOC_DQBUF, &dqbuf) != 0) { if (errno == EAGAIN) { usleep(1000); continue; } PRINT("ioctl() failed: VIDIOC_DQBUF"); return -1; } return 0; }
unicap_status_t buffer_mgr_dequeue_all (buffer_mgr_t mgr ) { int i; unicap_status_t status = STATUS_SUCCESS; BUFFER_MGR_LOCK (mgr); for (i=0; i < mgr->num_buffers; i++) { if (mgr->buffers[i].queued) { if( IOCTL( mgr->fd, VIDIOC_DQBUF, &mgr->buffers[i].v4l2_buffer ) < 0 ) { TRACE( "VIDIOC_DQBUF ioctl failed: %s\n", strerror( errno ) ); status = STATUS_FAILURE; } else { mgr->buffers[i].queued = 0; } } } BUFFER_MGR_UNLOCK (mgr); return status; }
static int set_winsize(int fd,int row){ int col; WINSTRUCT winsize; if( NO_TTY ) return 0; if( WIN_CHANGED == 0 ){ WIN_CHANGED = 1; IOCTL(fd,GETWINCOM,&init_win); if( init_win.ROWS == 0 ){ init_win.ROWS = getcapn("li"); init_win.COLS = getcapn("co"); } } if(row < 0) row = 0; col = getcapn("co"); if(col < 0) col = 0; winsize.ROWS = row; winsize.COLS = col; SETWINSIZE(CURTTY_FD,&winsize); return 1; }
unicap_status_t buffer_mgr_dequeue( buffer_mgr_t mgr, unicap_data_buffer_t **buffer ) { struct v4l2_buffer v4l2_buffer; unicap_status_t status = STATUS_SUCCESS; int i; *buffer = NULL; memset (&v4l2_buffer, 0x0, sizeof (v4l2_buffer)); v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2_buffer.memory = V4L2_MEMORY_MMAP; BUFFER_MGR_LOCK (mgr); if( IOCTL( mgr->fd, VIDIOC_DQBUF, &v4l2_buffer ) < 0 ) { TRACE( "VIDIOC_DQBUF ioctl failed: %s\n", strerror( errno ) ); status = STATUS_FAILURE; } else { for (i = 0; i < mgr->num_buffers; i++ ) { if (mgr->buffers[i].v4l2_buffer.index == v4l2_buffer.index ) { mgr->buffers[i].queued = 0; mgr->buffers[i].data_buffer.buffer_size = v4l2_buffer.bytesused; memcpy( &mgr->buffers[i].data_buffer.fill_time, &v4l2_buffer.timestamp, sizeof( struct timeval ) ); *buffer = &mgr->buffers[i].data_buffer; break; } } } if (!*buffer) { TRACE ("VIDIOC_DQBUF returned a buffer that is not in the pool (%d) !?!?!?", v4l2_buffer.index ); status = STATUS_FAILURE; } BUFFER_MGR_UNLOCK (mgr); return status; }
/* nbytes = MG_NET_RECV(socket, variable [, MAXIMUM_BYTES=b]) Reads the raw data available on the socket and returns a BYTE array in variable. The maximum number of bytes to read can be specified by the MAXIMUM_BYTES keyword. The default is to read all the data available on the socket. Note: no byteswapping is performed. */ static IDL_VPTR IDL_CDECL mg_net_recv(int argc, IDL_VPTR argv[], char *argk) { IDL_LONG i, iRet, err; int len; IDL_VPTR vpPlainArgs[2], vpTmp; char *pbuffer; static IDL_LONG iMax; static IDL_KW_PAR kw_pars[] = { IDL_KW_FAST_SCAN, { "MAXIMUM_BYTES", IDL_TYP_LONG, 1, IDL_KW_ZERO, 0, IDL_CHARA(iMax) }, { NULL } }; IDL_KWCleanup(IDL_KW_MARK); IDL_KWGetParams(argc, argv, argk, kw_pars, vpPlainArgs, 1); i = IDL_LongScalar(vpPlainArgs[0]); if ((i < 0) || (i >= MAX_SOCKETS)) return (IDL_GettmpLong(-1)); if (net_list[i].iState != NET_IO) return (IDL_GettmpLong(-1)); IDL_EXCLUDE_EXPR(vpPlainArgs[1]); err = IOCTL(net_list[i].socket, FIONREAD, &len); if (err != 0) { iRet = -1; goto err; } if (iMax) len = IDL_MIN(iMax, len); pbuffer = (char *) IDL_MakeTempVector(IDL_TYP_BYTE, len, IDL_ARR_INI_NOP, &vpTmp); IDL_VarCopy(vpTmp, vpPlainArgs[1]); iRet = recv(net_list[i].socket, pbuffer, len, 0); err: IDL_KWCleanup(IDL_KW_CLEAN); return(IDL_GettmpLong(iRet)); }
static sock * New(int Socket) { sock * pSock = (sock *) malloc(sizeof(sock)); // // Make the socket non-blocking. // { unsigned long IsNonBlocking = 1; IOCTL(Socket, FIONBIO, &IsNonBlocking); } pSock->m_Socket = Socket; pSock->m_Closed = false; pSock->m_ConnectPrimed = false; pSock->m_pSendData = NULL; pSock->m_BytesReceived = 0; pSock->m_pReceiveBuffer = (char *) malloc(RECEIVE_BUFFER_SIZE); oosmos_SubscriberListInit(pSock->m_ClosedEvent); return pSock; }
#include "trinity.h" // ARRAY_SIZE #include "arch.h" // page_size #include "random.h" #include "sanitise.h" #include "ioctls.h" #ifndef SCSI_IOCTL_GET_PCI #define SCSI_IOCTL_GET_PCI 0x5387 #endif #ifndef SG_GET_ACCESS_COUNT #define SG_GET_ACCESS_COUNT 0x2289 #endif static const struct ioctl scsi_ioctls[] = { IOCTL(SCSI_IOCTL_GET_IDLUN), IOCTL(SCSI_IOCTL_TAGGED_ENABLE), IOCTL(SCSI_IOCTL_TAGGED_DISABLE), IOCTL(SCSI_IOCTL_PROBE_HOST), IOCTL(SCSI_IOCTL_GET_BUS_NUMBER), IOCTL(SCSI_IOCTL_GET_PCI), IOCTL(SCSI_IOCTL_SEND_COMMAND), IOCTL(SCSI_IOCTL_TEST_UNIT_READY), IOCTL(SCSI_IOCTL_BENCHMARK_COMMAND), IOCTL(SCSI_IOCTL_SYNC), IOCTL(SCSI_IOCTL_START_UNIT), IOCTL(SCSI_IOCTL_STOP_UNIT), IOCTL(SCSI_IOCTL_DOORLOCK), IOCTL(SCSI_IOCTL_DOORUNLOCK), IOCTL(SG_EMULATED_HOST),
#include "config.h" #ifdef USE_VHOST #include <linux/vhost.h> #include "trinity.h" #include "ioctls.h" static const struct ioctl vhost_ioctls[] = { IOCTL(VHOST_GET_FEATURES), IOCTL(VHOST_SET_FEATURES), IOCTL(VHOST_SET_OWNER), IOCTL(VHOST_RESET_OWNER), IOCTL(VHOST_SET_MEM_TABLE), IOCTL(VHOST_SET_LOG_BASE), IOCTL(VHOST_SET_LOG_FD), IOCTL(VHOST_SET_VRING_NUM), IOCTL(VHOST_SET_VRING_ADDR), IOCTL(VHOST_SET_VRING_BASE), IOCTL(VHOST_GET_VRING_BASE), IOCTL(VHOST_SET_VRING_KICK), IOCTL(VHOST_SET_VRING_CALL), IOCTL(VHOST_SET_VRING_ERR), IOCTL(VHOST_NET_SET_BACKEND), #ifdef VHOST_SCSI_SET_ENDPOINT IOCTL(VHOST_SCSI_SET_ENDPOINT), #endif #ifdef VHOST_SCSI_CLEAR_ENDPOINT IOCTL(VHOST_SCSI_CLEAR_ENDPOINT), #endif #ifdef VHOST_SCSI_GET_ABI_VERSION
int tunctl_main(int argc UNUSED_PARAM, char **argv) { struct ifreq ifr; int fd; const char *opt_name = "tap%d"; const char *opt_device = "/dev/net/tun"; #if ENABLE_FEATURE_TUNCTL_UG const char *opt_user, *opt_group; long user = -1, group = -1; #endif unsigned opts; enum { OPT_f = 1 << 0, // control device name (/dev/net/tun) OPT_t = 1 << 1, // create named interface OPT_d = 1 << 2, // delete named interface #if ENABLE_FEATURE_TUNCTL_UG OPT_u = 1 << 3, // set new interface owner OPT_g = 1 << 4, // set new interface group OPT_b = 1 << 5, // brief output #endif }; opt_complementary = "=0:t--d:d--t"; // no arguments; t ^ d opts = getopt32(argv, "f:t:d:" IF_FEATURE_TUNCTL_UG("u:g:b"), &opt_device, &opt_name, &opt_name IF_FEATURE_TUNCTL_UG(, &opt_user, &opt_group)); // select device memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; strncpy_IFNAMSIZ(ifr.ifr_name, opt_name); // open device fd = xopen(opt_device, O_RDWR); IOCTL(fd, TUNSETIFF, (void *)&ifr); // delete? if (opts & OPT_d) { IOCTL(fd, TUNSETPERSIST, (void *)(uintptr_t)0); printf("Set '%s' nonpersistent\n", ifr.ifr_name); return EXIT_SUCCESS; } // create #if ENABLE_FEATURE_TUNCTL_UG if (opts & OPT_g) { group = xgroup2gid(opt_group); IOCTL(fd, TUNSETGROUP, (void *)(uintptr_t)group); } else user = geteuid(); if (opts & OPT_u) user = xuname2uid(opt_user); IOCTL(fd, TUNSETOWNER, (void *)(uintptr_t)user); #endif IOCTL(fd, TUNSETPERSIST, (void *)(uintptr_t)1); // show info #if ENABLE_FEATURE_TUNCTL_UG if (opts & OPT_b) { puts(ifr.ifr_name); } else { printf("Set '%s' %spersistent", ifr.ifr_name, ""); printf(" and owned by uid %ld", user); if (group != -1) printf(" gid %ld", group); bb_putchar('\n'); } #else puts(ifr.ifr_name); #endif return EXIT_SUCCESS; }
#include <linux/videodev2.h> #include "trinity.h" #include "ioctls.h" static const struct ioctl videodev2_ioctls[] = { IOCTL(VIDIOC_QUERYCAP), IOCTL(VIDIOC_RESERVED), IOCTL(VIDIOC_ENUM_FMT), IOCTL(VIDIOC_G_FMT), IOCTL(VIDIOC_S_FMT), IOCTL(VIDIOC_REQBUFS), IOCTL(VIDIOC_QUERYBUF), IOCTL(VIDIOC_G_FBUF), IOCTL(VIDIOC_S_FBUF), IOCTL(VIDIOC_OVERLAY), IOCTL(VIDIOC_QBUF), #ifdef VIDIOC_EXPBUF IOCTL(VIDIOC_EXPBUF), #endif IOCTL(VIDIOC_DQBUF), IOCTL(VIDIOC_STREAMON), IOCTL(VIDIOC_STREAMOFF), IOCTL(VIDIOC_G_PARM), IOCTL(VIDIOC_S_PARM), IOCTL(VIDIOC_G_STD), IOCTL(VIDIOC_S_STD), IOCTL(VIDIOC_ENUMSTD), IOCTL(VIDIOC_ENUMINPUT), IOCTL(VIDIOC_G_CTRL), IOCTL(VIDIOC_S_CTRL),
#include <linux/cdrom.h> #include "trinity.h" #include "ioctls.h" static const struct ioctl cdrom_ioctls[] = { IOCTL(CDROMPAUSE), IOCTL(CDROMRESUME), IOCTL(CDROMPLAYMSF), IOCTL(CDROMPLAYTRKIND), IOCTL(CDROMREADTOCHDR), IOCTL(CDROMREADTOCENTRY), IOCTL(CDROMSTOP), IOCTL(CDROMSTART), IOCTL(CDROMEJECT), IOCTL(CDROMVOLCTRL), IOCTL(CDROMSUBCHNL), IOCTL(CDROMREADMODE2), IOCTL(CDROMREADMODE1), IOCTL(CDROMREADAUDIO), IOCTL(CDROMEJECT_SW), IOCTL(CDROMMULTISESSION), IOCTL(CDROM_GET_MCN), IOCTL(CDROMRESET), IOCTL(CDROMVOLREAD), IOCTL(CDROMREADRAW), IOCTL(CDROMREADCOOKED), IOCTL(CDROMSEEK), IOCTL(CDROMPLAYBLK), IOCTL(CDROMREADALL), IOCTL(CDROMGETSPINDOWN),
#include <linux/ioctl.h> #include <linux/rfkill.h> #include "ioctls.h" #include "utils.h" static const struct ioctl rfkill_ioctls[] = { IOCTL(RFKILL_IOCTL_NOINPUT), }; static const char *const rfkill_devs[] = { "rfkill", }; static const struct ioctl_group rfkill_grp = { .devtype = DEV_MISC, .devs = rfkill_devs, .devs_cnt = ARRAY_SIZE(rfkill_devs), .sanitise = pick_random_ioctl, .ioctls = rfkill_ioctls, .ioctls_cnt = ARRAY_SIZE(rfkill_ioctls), }; REG_IOCTL_GROUP(rfkill_grp)
#include <linux/ioctl.h> #include <linux/input.h> #include "ioctls.h" #include "shm.h" #include "utils.h" static const struct ioctl input_ioctls[] = { IOCTL(EVIOCGVERSION), IOCTL(EVIOCGID), IOCTL(EVIOCGREP), IOCTL(EVIOCSREP), IOCTL(EVIOCGKEYCODE), #ifdef EVIOCGKEYCODE_V2 IOCTL(EVIOCGKEYCODE_V2), #endif IOCTL(EVIOCSKEYCODE), #ifdef EVIOCSKEYCODE_V2 IOCTL(EVIOCSKEYCODE_V2), #endif IOCTL(EVIOCGNAME(0)), IOCTL(EVIOCGPHYS(0)), IOCTL(EVIOCGUNIQ(0)), #ifdef EVIOCGPROP IOCTL(EVIOCGPROP(0)), #endif #ifdef EVIOCGMTSLOTS IOCTL(EVIOCGMTSLOTS(0)), #endif IOCTL(EVIOCGKEY(0)), IOCTL(EVIOCGLED(0)),
#include "config.h" #ifdef USE_NVME #include <linux/ioctl.h> #include <linux/nvme.h> #include "utils.h" #include "ioctls.h" static const struct ioctl nvme_ioctls[] = { IOCTL(NVME_IOCTL_ID), IOCTL(NVME_IOCTL_ADMIN_CMD), IOCTL(NVME_IOCTL_SUBMIT_IO), IOCTL(NVME_IOCTL_IO_CMD), IOCTL(NVME_IOCTL_RESET), }; static const char *const nvme_devs[] = { "nvme", }; static const struct ioctl_group nvme_grp_misc = { .devtype = DEV_CHAR, .devs = nvme_devs, .devs_cnt = ARRAY_SIZE(nvme_devs), .sanitise = pick_random_ioctl, .ioctls = nvme_ioctls, .ioctls_cnt = ARRAY_SIZE(nvme_ioctls), }; REG_IOCTL_GROUP(nvme_grp_misc)
MtpUSBTransportSendData( STransport* port, void* pXferBuf, MTP_DWORD bytesToSend, BOOL bCompleteXfer, MTP_DWORD* pBytesSent ) { ssize_t wrBytes = WRITE( port->MtpFd, pXferBuf, bytesToSend ); /* send zero length packet */ IOCTL( port->MtpFd, MTP_IOC_SEND_ZLP ); }
#include <linux/ioctl.h> #include "utils.h" #include "ioctls.h" #define MCE_GET_RECORD_LEN _IOR('M', 1, int) #define MCE_GET_LOG_LEN _IOR('M', 2, int) #define MCE_GETCLEAR_FLAGS _IOR('M', 3, int) static const struct ioctl mce_ioctls[] = { IOCTL(MCE_GET_RECORD_LEN, 0, 0), IOCTL(MCE_GET_LOG_LEN, 0, 0), IOCTL(MCE_GETCLEAR_FLAGS, 0, 0), }; static const char *const mce_devs[] = { "mcelog", }; static const struct ioctl_group mce_grp = { .devtype = DEV_MISC, .devs = mce_devs, .devs_cnt = ARRAY_SIZE(mce_devs), .sanitise = pick_random_ioctl, .ioctls = mce_ioctls, .ioctls_cnt = ARRAY_SIZE(mce_ioctls), }; REG_IOCTL_GROUP(mce_grp)
Device::Device(int fd, const EndpointPtr &controlEp): _fd(fd), _capabilities(0), _controlEp(controlEp) { try { IOCTL(_fd.Get(), USBDEVFS_GET_CAPABILITIES, &_capabilities); } catch(const std::exception &ex) { fprintf(stderr, "get usbfs capabilities failed: %s\n", ex.what()); } }
void Submit() { IOCTL(Fd, USBDEVFS_SUBMITURB, &KernelUrb); }
#include "config.h" #ifdef USE_VFIO #include <linux/vfio.h> #include "utils.h" #include "ioctls.h" static const struct ioctl vfio_ioctls[] = { IOCTL(VFIO_GET_API_VERSION, 0, 0), IOCTL(VFIO_CHECK_EXTENSION, 0, 0), IOCTL(VFIO_SET_IOMMU, 0, 0), IOCTL(VFIO_GROUP_GET_STATUS, 0, 0), IOCTL(VFIO_GROUP_SET_CONTAINER, 0, 0), IOCTL(VFIO_GROUP_UNSET_CONTAINER, 0, 0), IOCTL(VFIO_GROUP_GET_DEVICE_FD, 0, 0), IOCTL(VFIO_DEVICE_GET_INFO, 0, 0), IOCTL(VFIO_DEVICE_GET_REGION_INFO, 0, 0), IOCTL(VFIO_DEVICE_GET_IRQ_INFO, 0, 0), IOCTL(VFIO_DEVICE_SET_IRQS, 0, 0), IOCTL(VFIO_DEVICE_RESET, 0, 0), IOCTL(VFIO_IOMMU_GET_INFO, 0, 0), IOCTL(VFIO_IOMMU_MAP_DMA, 0, 0), IOCTL(VFIO_IOMMU_UNMAP_DMA, 0, 0), }; static const char *const vfio_devs[] = { "vfio", }; static const struct ioctl_group vfio_grp = {
#include <unistd.h> /* size_t */ #include <hacked/ion.h> #include <linux/ioctl.h> #include "trinity.h" #include "ioctls.h" #include "utils.h" #include "config.h" static const struct ioctl ion_ioctls[] = { IOCTL(ION_IOC_ALLOC), IOCTL(ION_IOC_FREE), IOCTL(ION_IOC_SHARE), IOCTL(ION_IOC_MAP), IOCTL(ION_IOC_IMPORT), IOCTL(ION_IOC_SYNC), IOCTL(ION_IOC_CUSTOM), #ifdef CONFIG_COMPAT IOCTL(COMPAT_ION_IOC_ALLOC), IOCTL(COMPAT_ION_IOC_FREE), IOCTL(COMPAT_ION_IOC_CUSTOM), #endif }; static const char *const ion_devs[] = { "ion", }; static const struct ioctl_group ion_grp = { .name = "ion", .devtype = DEV_MISC, .devs = ion_devs,
#include "config.h" #ifdef USE_KVM #include <linux/ioctl.h> #include <linux/kvm.h> #include "compat.h" #include "ioctls.h" #include "utils.h" static const struct ioctl kvm_ioctls[] = { IOCTL(KVM_SET_MEMORY_REGION), IOCTL(KVM_CREATE_VCPU), IOCTL(KVM_GET_DIRTY_LOG), IOCTL(KVM_SET_NR_MMU_PAGES), IOCTL(KVM_GET_NR_MMU_PAGES), IOCTL(KVM_SET_USER_MEMORY_REGION), IOCTL(KVM_SET_TSS_ADDR), IOCTL(KVM_SET_IDENTITY_MAP_ADDR), IOCTL(KVM_S390_UCAS_MAP), IOCTL(KVM_S390_UCAS_UNMAP), IOCTL(KVM_S390_VCPU_FAULT), IOCTL(KVM_CREATE_IRQCHIP), IOCTL(KVM_IRQ_LINE), IOCTL(KVM_GET_IRQCHIP), IOCTL(KVM_SET_IRQCHIP), IOCTL(KVM_CREATE_PIT), IOCTL(KVM_IRQ_LINE_STATUS), IOCTL(KVM_REGISTER_COALESCED_MMIO), IOCTL(KVM_UNREGISTER_COALESCED_MMIO), IOCTL(KVM_ASSIGN_PCI_DEVICE),
/* err = MG_NET_QUERY(socket [, AVAILABLE_BYTES=a] [, IS_LISTENER=l] [, LOCAL_HOST=lh] [, LOCAL_PORT=lp] [, REMOTE_HOST=rh] [, REMOTE_PORT=rp]) Returns various information about the socket in question. AVAILABLE_BYTES: number of bytes available for reading. REMOTE_HOST: host number of the remote host the socket is connected to. IS_LISTENER: true if the socket was created using MG_NET_CREATEPORT() */ static IDL_VPTR IDL_CDECL mg_net_query(int argc, IDL_VPTR argv[], char *argk) { IDL_LONG i; IDL_VPTR vpPlainArgs[1],vpTmp; struct sockaddr_in peer_addr; int addr_len, err; IDL_LONG iRet = 0; static IDL_VPTR vpRHost, vpAvail, vpListen, vpLPort, vpRPort, vpLHost; static IDL_KW_PAR kw_pars[] = { IDL_KW_FAST_SCAN, { "AVAILABLE_BYTES", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpAvail) }, { "IS_LISTENER", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpListen) }, { "LOCAL_HOST", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpLHost) }, { "LOCAL_PORT", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpLPort) }, { "REMOTE_HOST", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpRHost) }, { "REMOTE_PORT", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 0, IDL_CHARA(vpRPort) }, { NULL} }; IDL_KWCleanup(IDL_KW_MARK); IDL_KWGetParams(argc, argv, argk, kw_pars, vpPlainArgs, 1); i = IDL_LongScalar(vpPlainArgs[0]); if ((i < 0) || (i >= MAX_SOCKETS)) { IDL_KWCleanup(IDL_KW_CLEAN); return(IDL_GettmpLong(-1)); } if (vpRHost || vpRPort) { addr_len = sizeof(struct sockaddr_in); err = getpeername(net_list[i].socket, (struct sockaddr *) &peer_addr, &addr_len); if (err != 0) { iRet = -1; } else { if (vpRHost) { vpTmp = IDL_GettmpULong(peer_addr.sin_addr.s_addr); IDL_VarCopy(vpTmp, vpRHost); } if (vpRPort) { vpTmp = IDL_GettmpLong((long) ntohs(peer_addr.sin_port)); IDL_VarCopy(vpTmp, vpRPort); } } } if (vpAvail) { int len; err = IOCTL(net_list[i].socket, FIONREAD, &len); if (err != 0) { iRet = -1; } else { vpTmp = IDL_GettmpULong(len); IDL_VarCopy(vpTmp, vpAvail); } } if (vpListen) { vpTmp = IDL_GettmpLong(net_list[i].iState == NET_LISTEN); IDL_VarCopy(vpTmp, vpListen); } if (vpLPort || vpLHost) { addr_len = sizeof(struct sockaddr_in); err = getsockname(net_list[i].socket, (struct sockaddr *) &peer_addr, &addr_len); if (err != 0) { iRet = -1; } else { if (vpLHost) { vpTmp = IDL_GettmpULong(peer_addr.sin_addr.s_addr); IDL_VarCopy(vpTmp, vpLHost); } if (vpLPort) { vpTmp = IDL_GettmpLong((long) ntohs(peer_addr.sin_port)); IDL_VarCopy(vpTmp, vpLPort); } } } IDL_KWCleanup(IDL_KW_CLEAN); return(IDL_GettmpLong(iRet)); }
#include <linux/ioctl.h> #include <linux/rtc.h> #include "ioctls.h" #include "utils.h" static const struct ioctl rtc_ioctls[] = { IOCTL(RTC_AIE_ON, 0, 0), IOCTL(RTC_AIE_OFF, 0, 0), IOCTL(RTC_UIE_ON, 0, 0), IOCTL(RTC_UIE_OFF, 0, 0), IOCTL(RTC_PIE_ON, 0, 0), IOCTL(RTC_PIE_OFF, 0, 0), IOCTL(RTC_WIE_ON, 0, 0), IOCTL(RTC_WIE_OFF, 0, 0), IOCTL(RTC_ALM_SET, 0, 0), IOCTL(RTC_ALM_READ, 0, 0), IOCTL(RTC_RD_TIME, 0, 0), IOCTL(RTC_SET_TIME, 0, 0), IOCTL(RTC_IRQP_READ, 0, 0), IOCTL(RTC_IRQP_SET, 0, 0), IOCTL(RTC_EPOCH_READ, 0, 0), IOCTL(RTC_EPOCH_SET, 0, 0), IOCTL(RTC_WKALM_SET, 0, 0), IOCTL(RTC_WKALM_RD, 0, 0), IOCTL(RTC_PLL_GET, 0, 0), IOCTL(RTC_PLL_SET, 0, 0), #ifdef RTC_VL_READ IOCTL(RTC_VL_READ, 0, 0), #endif #ifdef RTC_VL_CLR
#include <linux/watchdog.h> #include "utils.h" #include "ioctls.h" static const struct ioctl watchdog_ioctls[] = { IOCTL(WDIOC_GETSUPPORT), IOCTL(WDIOC_GETSTATUS), IOCTL(WDIOC_GETBOOTSTATUS), IOCTL(WDIOC_GETTEMP), IOCTL(WDIOC_SETOPTIONS), IOCTL(WDIOC_KEEPALIVE), IOCTL(WDIOC_SETTIMEOUT), IOCTL(WDIOC_GETTIMEOUT), IOCTL(WDIOC_SETPRETIMEOUT), IOCTL(WDIOC_GETPRETIMEOUT), IOCTL(WDIOC_GETTIMELEFT), }; static const char *const watchdog_devs[] = { "watchdog", }; static const struct ioctl_group watchdog_grp_misc = { .devtype = DEV_MISC, .devs = watchdog_devs, .devs_cnt = ARRAY_SIZE(watchdog_devs), .sanitise = pick_random_ioctl, .ioctls = watchdog_ioctls, .ioctls_cnt = ARRAY_SIZE(watchdog_ioctls), };
#include <linux/ioctl.h> #include <linux/uinput.h> #include "trinity.h" #include "ioctls.h" static const struct ioctl uinput_ioctls[] = { IOCTL(UI_DEV_CREATE), IOCTL(UI_DEV_DESTROY), IOCTL(UI_SET_EVBIT), IOCTL(UI_SET_KEYBIT), IOCTL(UI_SET_RELBIT), IOCTL(UI_SET_ABSBIT), IOCTL(UI_SET_MSCBIT), IOCTL(UI_SET_LEDBIT), IOCTL(UI_SET_SNDBIT), IOCTL(UI_SET_FFBIT), IOCTL(UI_SET_PHYS), IOCTL(UI_SET_SWBIT), #ifdef UI_SET_PROPBIT IOCTL(UI_SET_PROPBIT), #endif IOCTL(UI_BEGIN_FF_UPLOAD), IOCTL(UI_END_FF_UPLOAD), IOCTL(UI_BEGIN_FF_ERASE), IOCTL(UI_END_FF_ERASE), }; static const char *const uinput_devs[] = { "uinput", };
AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl) #define AUTOFS_DEV_IOCTL_EXPIRE \ _IOWR(AUTOFS_IOCTL, \ AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl) #define AUTOFS_DEV_IOCTL_ASKUMOUNT \ _IOWR(AUTOFS_IOCTL, \ AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl) #define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \ _IOWR(AUTOFS_IOCTL, \ AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl) static const struct ioctl autofs_ioctls[] = { IOCTL(AUTOFS_IOC_READY), IOCTL(AUTOFS_IOC_FAIL), IOCTL(AUTOFS_IOC_CATATONIC), IOCTL(AUTOFS_IOC_PROTOVER), /* IOCTL(AUTOFS_IOC_SETTIMEOUT32), */ IOCTL(AUTOFS_IOC_SETTIMEOUT), IOCTL(AUTOFS_IOC_EXPIRE), IOCTL(AUTOFS_IOC_EXPIRE_MULTI), IOCTL(AUTOFS_IOC_EXPIRE_INDIRECT), IOCTL(AUTOFS_IOC_EXPIRE_DIRECT), IOCTL(AUTOFS_IOC_PROTOSUBVER), IOCTL(AUTOFS_IOC_ASKUMOUNT), IOCTL(AUTOFS_DEV_IOCTL_VERSION), IOCTL(AUTOFS_DEV_IOCTL_PROTOVER), IOCTL(AUTOFS_DEV_IOCTL_PROTOSUBVER),
/* Play raw data on /dev/dsp or whatever. This is snatched from "vplay.c", by Michael Beck - [email protected] */ static void PlayRaw( unsigned char *samples, int n, int rate ) { #ifdef AUDIO_DEVICE int audio, tmp; /* I guess we could have saved some nanoseconds by opening the device and do all the checking & setup *once* at startup, but then we would block the device, and we will not do that! */ audio = open(AUDIO_DEVICE, O_WRONLY, 0); if (audio == -1) { Message("can't open audio device %s...\n",AUDIO_DEVICE); return; } IOCTL(audio, SNDCTL_DSP_GETBLKSIZE, tmp); if (tmp < 4096 || tmp > 65536) { Message("Invalid audio buffers size %d\n", tmp); close(audio); return; } if (ioctl(audio, SNDCTL_DSP_SYNC, NULL) < 0) { Message("couldn't sync dsp device %s...\n",AUDIO_DEVICE); close(audio); return; } /* set samplesize 8 */ tmp = 8; IOCTL(audio, SNDCTL_DSP_SAMPLESIZE, tmp); if ( tmp != 8 ) { Message("unable to set 8 bit sample size!\n"); close(audio); return; } /* set mono */ tmp = 0; if ( IOCTL(audio, SNDCTL_DSP_STEREO, tmp) < 0) { Message("unable to set MONO\n"); close(audio); return; } /* set speed */ if (IOCTL(audio, SNDCTL_DSP_SPEED, rate ) < 0) { Message("unable to set audio speed to %d\n",rate); close(audio); return; } /* go : */ tmp = write(audio, samples, n); if ( tmp != n ) Message("could only write %d of %d samples...\n",tmp,n); close(audio); #else Message("Not compiled with audio support!\n"); #endif /* AUDIO_DEVICE */ }