ioctl

Maximum buffer length for sendto?

How do you get the maximum number of bytes that can be passed to a sendto(..) call for a socket opened as a UDP port? ...

Behavior of SIO_FLUSH

When SIO_FLUSH socket ioctl is used in a Windows environment (in user space), I am confused as to what happens. Does this: (1) completely discard the data from the TCP/IP send queue into a black hole, or (2) push the queued send data across the connection until the buffer is empty, or (3) something else? Thanks! ...

How to get base_baud frequency of a com-port in windows

Is there a windows call to get the baud base frequency, like this one in linux. struct serial_struct ser; ioctl(com, TIOCGSERIAL, &ser); base = ser.baud_base; ...

reading / writing fram using I2C on Linux

I'm trying to read/write to a FM24CL64-GTR FRAM chip that is connected over a I2C bus on address 0b 1010 011. When I'm trying to write 3 bytes (data address 2 bytes, + data one byte), I get a kernel message ([12406.360000] i2c-adapter i2c-0: sendbytes: NAK bailout.), as well as the write returns != 3. See code below: #include <linux/i...

Setting non-canonical mode on stdin with Ruby

I'm playing around with making a simple terminal-based game with Ruby, and I'm currently trying to come up with a way of reading input from the terminal. So far I've been using gets, but I'd like to have the game react instantly without requiring a newline (so you don't need to press a key, THEN enter). I've figured out I need to put t...

ioctl FIOREAD on raw socket in Linux

I have an implementation which uses ioctl(FIONREAD) to determine the number of pending octets in the Raw Socket receive buffer in Linux and then call a recv on that. I read somewhere that the ioctl interface for raw sockets in Linux does not actually return the actual pending octets. Is this correct? I am asking because I am loosing s...

V4L problem with VIDIOCGCAP ioctl call

Hi guys, I'm having some issue working with V4L (the API that provides unified access to various video capturing for Linux). I'm tryng to make a VIDIOCGCAP ioctl call, but I get an INVALID ARGUMENT error. Here is an strace: execve("./test", ["./test"], [/* 26 vars */]) = 0 brk(0) = 0x8d5c000 access("/et...

How does iwlist() command scans the wireless networks??

I want to know how iwlist command scans the wireless networks available, in linux. I read its source code and there was an ioctl call using SIOCSIWSCAN to trigger the scan and SIOCGIWSCAN to get the scan results. But how the beacon frames are captured and analyzed by these system calls? ...

Why is ioctl() not blocking?

I have written code for passing file descriptors between unrelated processes using streams. The server should wait for the client to send a file descriptor. Here is the server code: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stropts.h> #include <stdio.h> #include <errno.h> #include <unistd.h> ...

Handling User-Break (UART Break) on a /dev/tty device in Linux

Here is some code sample, but the issue is that the signal handler is not called when a 'break' is sent over the serial line with 'putty'. #include <sys/ioctl.h> #include <termios.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/signal.h> #include <errno.h> #include <sys/types.h> #inclu...

Using Linux ioctl with Mono

I'm trying to do ioctl command through Mono framework, but I cant find what I'm looking for. I'm trying to send command to a DVB card that has a kernel module. I hope someone can link or explain clearly how this can be done. Any example with Mono using kernel modules would be useful I guess. ...

unlocked_ioctl vs normal ioctl

In my driver's file_operations structure, I have: struct file_operations Fops = { read: device_read, write: device_write, unlocked_ioctl: device_ioctl, ... }; I.e. there is no ioctl field used. Is this sufficient to avoid Big Kernel Lock and enter into device_ioctl() without any synchronization? Or do I have to change i...

Calling DeviceIoControl from C# with IOCTL_DVD_* Control Codes

I am trying to call DeviceIoControl from C# for IOCTL_DVD_* control codes. Having read a lot of information and trying a number of examples I have not made much progress. What I am trying to eventually do is get a DVD_LAYER_DESCRIPTOR structure about the media currently in the DVD drive. I can call CreateFile successfully on the DVD d...

Adding custom struct types to strace

I'm trying to reverse-engineer a user-mode shared object that interacts with a kernel driver via ioctl syscalls. I have a header file with definitions for the kernel driver's ioctl interface (i.e. #defines for ioctl command numbers, and struct definitions for the various data sent to ioctl). I see that strace has the ability to de-refe...

how to find keyboard in /dev on osx

On linux / ubuntu, the keyboard and mouse devices are found in /dev/input/by-path/ Where is the keyboard device mounted in osx? I added a usb keyboard, and no devices got added in /dev folder. Is it located somewhere else, or is it totally unaccessible? Thanks. Edit: I was able to get some info on the keyboard using libusb: 046d:c...

Getting essid via ioctl in ruby

To avoid relying on the wireless tools I want to get the essid directly from the device with ioctl, in C this wouldn't be a problem, but in Ruby it's quite different. The problem is following struct from wireless.h that is used as input/reply of ioctl: struct iw_point { void __user *pointer; /* Pointer to the data (in user space) ...

Linux ioctl -> how to tell if current IP was obtained by dhcp

Hello all, I'm fiddling with the sockets ioctl's to get the current interfaces setup and I can already get the IP, interface name, netmask and check if the interface is up or down, (I just do IOCTl to SIOCGIFCONF, SIOCGIFNETMASK and SIOCGIFFLAGS). I am looking for a way to tell if my current IP address was obtained through dhcp or if ...

"inappropriate ioctl for device"

Hi All, I have a perl script running in a aix box. The script tries to open a file from a certain directory and it fails to read the file because file has no read permission. but i get a different error saying "inappropriate ioctl for device" Shouldn't it say something like file doesn't have read permission or something? What does t...

How to set the terminal's size?

How do I get the terminal size in Go. In C it would look like this: struct ttysize ts; ioctl(0, TIOCGWINSZ, &ts); But how to i access TIOCGWINSZ in Go ...

Is there an OS X equivalent of FreeBSD's make_dev() function?

I'm trying to port some code from FreeBSD to OS X. The code is fairly low-level and it creates a number of special device files using make_dev() and controls functionality using functions like ioctl(). Ideally I'd like to keep my code as close to the original as possible so I can more easily merge upstream changes in the future: my q...