ioctl

How to check if interface is up

我与影子孤独终老i 提交于 2019-12-03 07:27:47
Title pretty much says it all. If I run ifconfig , I get this: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet -snip- netmask 255.255.255.0 broadcast -snip- ... Using this, I can know if it's up or not ( <UP,... ), but I want to be able to do this in C (or C++, if there is a simpler solution there) without relying on parsing external processes. Here is what I've got so far (doesn't work): bool is_interface_online(std::string interface) { struct ifreq ifr; int sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, interface.c_str());

Linux - ioctl with FIONREAD always 0

◇◆丶佛笑我妖孽 提交于 2019-12-03 06:05:47
I'm trying to get to know how many bytes there are readable at my TCP socket. I am calling ioctl with the Flag "FIONREAD" which should actually give me this value. When I call the function I get as return val 0 ( so no Error ) but also my integer argument gets the value 0. That would be no problem but when I call the recv() method I actually read some Bytes out of the socket. What am I doing wrong? // here some Code: char recBuffer[BUFFERLENGTH] = {0}; int bytesAv = 0; int bytesRead = 0; int flags = 0; if ( ioctl (m_Socket,FIONREAD,&bytesAv) < 0 ) { // Error } if ( bytesAv < 1 ) { // No Data

I2C_SLAVE ioctl purpose

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am writing code for implementing a simple i2c read/write function using the general linux i2c driver linux/i2c-dev.h I am confused about the ioctl : I2C_SLAVE The kernel documentation states as follows : You can do plain i2c transactions by using read(2) and write(2) calls. You do not need to pass the address byte; instead, set it through ioctl I2C_SLAVE before you try to access the device However I am using the ioctl I2C_RDWR where I again set the slave address using i2c_msg.addr . The kernel documentation also mentions the following :

AVRDUDE Android Arduino ioctl error

匿名 (未验证) 提交于 2019-12-03 02:53:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My previous question, Android cannot talk to Arduino using AVRDUDE , has been resolved. I can now connect my Nexus 7 to my Arduino Uno. The full command I am running is this: /system/xbin/su (getting root here) /data/data/jackpal.androidterm/local/bin/avrdude -F -V -c arduino -p ATMEGA328P -P /dev/bus/usb/002/002 -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:led.hex Here I am trying to put the hex file on the Arduino. I do however get the following error: avrdude: ser_open():can't set attributes for device "

calling ioctl() from Java - how is it done?

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to access a serial port from within my app (the app has read/write permission to the device). How do I make ioctl() calls from my Java-based app ? 回答1: JNI -- and it wont be easy JNI is the Java Native Interface. It defines a way for managed code (written in the Java programming language) to interact with native code (written in C/C++). It's vendor-neutral, has support for loading code from dynamic shared libraries, and while cumbersome at times is reasonably efficient. 文章来源: calling ioctl() from Java - how is it done?

Delphi - Using DeviceIoControl passing IOCTL_DISK_GET_LENGTH_INFO to get flash media physical size (Not Partition)

匿名 (未验证) 提交于 2019-12-03 02:22:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Alright this is the result of a couple of other questions. It appears I was doing something wrong with the suggestions and at this point have come up with an error when using the suggested API to get the media size. Those new to my problem I am working at the physical disk level, not within the confines of a partition or file system. What I am doing I am trying to get the size of a flash card from the first block to the last, boot record partition space and all. While I don't need it to dump the information from a card, I do want dynamic

unlocked_ioctl vs normal ioctl

流过昼夜 提交于 2019-12-03 01:59:22
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 ioctl() calls in userspace part of the code too? Read this LWN article: http://lwn.net/Articles/119652/ Also sometime between 2.6.33 and a 2.6.35 rc (use git-diff to find out which commit) the kernel now WARNs when only .ioctl is defined. This is a move towards more explicit and

“inappropriate ioctl for device”

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Perl script running in an 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 no read permissions for file or something similar? What does this inappropriate ioctl for device message mean? How can I fix it? EDIT: This is what I found when I did strace . open("/local/logs/xxx/xxxxServer.log", O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE, 0666) = 4 _llseek(4, 0,

SCSI Read(10) on a Physical Drive on Windows

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried issuing a SCSI Read(10) command to a physical drive on a Windows 7 machine. Below is the code snippet that I am using. It is failing with error code 87. void scsi_read() { const UCHAR cdb[10] = { 0x28, 0, 0, 0, 0, 0, 0, 0, 512, 0 }; UCHAR buf[512]; BYTE senseBuf[196]; const int SENSE_LENGTH = 196; LPCSTR fname = "\\\\.\\E:"; HANDLE fh; DWORD ioctl_bytes; DWORD err = 0; SCSI_PASS_THROUGH s = {0}; memcpy(s.Cdb, cdb, sizeof(cdb)); s.CdbLength = 10; s.DataIn = SCSI_IOCTL_DATA_IN; s.TimeOutValue = 30; s.Length = sizeof(SCSI_PASS_THROUGH);

why does ioctl return “bad address”

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use the the code below to output data from SPI port of an embedded board (olimex imx233-micro -- it is not a board specific question). When I run the code ioctl return " bad address ". I am modifying the code on http://twilight.ponies.cz/spi-test.c which works fine. Could anyone tell me what am I doing wrong? root@ubuntu:/home# gcc test.c -o test test.c:20: warning: conflicting types for ‘msg_send’ test.c:16: note: previous implicit declaration of ‘msg_send’ was here root@ubuntu:/home# ./test errno:Bad address - cannot send SPI message