ioctl

IOCTL Linux device driver [closed]

孤者浪人 提交于 2019-11-26 18:43:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 months ago . Can anyone explain me, What is IOCTL ? What is it used for? How can I use it? Why can't I define new function that does the same work as IOCTL ? 回答1: An ioctl , which means "input-output control" is a kind of device-specific system call. There are only a few system calls in Linux

获取板子网卡Ip

我的未来我决定 提交于 2019-11-26 14:56:02
积累点滴,一种获取板子网卡Ip方法 1 int main() 2 { 3 struct ifreq stIfconfig; 4 5 char szIPeth0[ 16 ]; 6 char szIPeth1[ 16 ]; 7 memset(szIPeth0, 0x0 , 16 ); 8 memset(szIPeth1, 0x0 , 16 ); 9 10 int nNetWorkSocket = socket(AF_INET, SOCK_DGRAM, 0 ); 11 12 // 获取eth0的ip 13 strncpy(stIfconfig.ifr_name, " eth0 " , 5 ); 14 if (ioctl(nNetWorkSocket, SIOCGIFADDR, &stIfconfig) < 0 ) 15 { 16 printf( " ioctl does not get eth0! " ) 17 } 18 else 19 { 20 strncpy(szIPeth0,inet_ntoa((( struct sockaddr_in*)&(stIfconfig.ifr_addr))->sin_addr), 16 ); 21 } 22 23 // 获取eth1的ip 24 strncpy(stIfconfig.ifr_name, " eth1 " , 5 ); 25 if

Detect laptop lid closure and opening

只愿长相守 提交于 2019-11-26 13:03:18
问题 Is it possible to detect when a laptop\'s lid is open or closed? From what I\'ve read, this isn\'t possible, but SO has helped me with the impossible before. The only thing I\'ve found that might be in the right direction is an MSDN blog post about IOCTLs needed to report power buttons. Is it possible to \"sniff\" these as the OS calls them? I\'m using VB.NET, but will take suggestions in any language. Thank you for your time and advice. Edit : My software will be (eventually) overriding the

Beep on Linux in C

老子叫甜甜 提交于 2019-11-26 11:24:12
问题 I want to generate a beep sound with a specific frequency and length (for different sound signals) using the system beeper (and only the speakers if beeper is not available / accessible). I know it is possible to do this by using ioctl, but that requires root access, which I don\'t want. I know I could just use the \"beep\" command, but that would be a dependency, which, if possible, shouldn\'t be used (no external dependencies at all, just the basic linux libraries and C). What I currently