ioctl

Tell proc_entry->write_proc to use an ioctl with an argument?

I've seen some sample code that does this: proc_entry->read_proc = module_read; proc_entry->write_proc = module_write; However, in my module, I've used ioctls instead of the read and write. Here is my ioctl function prototype: int mytimer_ioctl(struct inode *inode, struct file *file, unsigned int fcn, unsigned long args) For read, ...

implementing ioctl() commands in FreeBSD

I am adding some code to an existing FreeBSD device driver and I am trying to pass a char* from user space to the driver. I've implemented a custom ioctl() command using the _IOW macro like so: #define TIBLOOMFILTER _IOW(0,253,char*) My call looks something like this: int file_desc = open("/dev/ti0", O_RDWR); ioctl(file_desc, TIBLOOMF...

Is it possible to call a user-space callback function from kernel space in Linux (ioctl)?

Is it possible to expand the ioctl interface in Linux so that the user-space application can send a pointer to a function to the kernel space driver? I'm in particular thinking of ways to handle the stream in user-controllable way but doing it in the kernel. Those operations could be attached to the kernel module but this would make de...

How to find out if SCSI device (say /etc/sda) is a disk or not via ioctl calls or other ?

How to find out if SCSI device (say /dev/sda) is a disk or not via ioctl calls or other ? I have tried the following but the ioctl call fails. My /dev/sda is a USB flash disk. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <scsi/scsi.h> #include <scsi/sg.h> #...

What's the best way to spy on IOCTLs?

I have a U9 Telit modem which, at first, appears as a disk drive on USB bus. Then, the native software after autorun and install, sends a couple of IOCTLs to tell the device to reappear as other things. I can see them in procmon. I want to better spy on these, to know exactly what they send and how, in order to do the same in proper way...

DeviceIoControl problem (IncorrectFunction)

Hi there! I'm trying to make my own ioctl driver command for calling it from an user-mode application dll. For now I just wanted to make sure the dll succesfuly calls that command on the driver code. So I defined my command (in the dll and in the driver's code) like this: #define BUSENUM_IOCTL(_index_) \ CTL_CODE (FILE_DEVICE_BUS_E...

C# - Possible to use IOCTL

I'm trying to code for a Point Of Sale system which allows for a "Cash Drawer" attachment. Code is provided in the manual for opening the cash drawer (in C++ using IOCTL). Since I am coding in C# .NET, is it possible to perform something similar from within C# or will I have to write some unmanaged code? Am I able to get a handle to "...

Turn off the display on remote PC

Hello. I'm fixing some bugs in the application for remote control (remote desktop-like) for Windows. And there is a feature that you can blank screen on remote machine - all the programms keep running unaffected, but the person who looks into the display on remote PC sees nothing but black screen. It is implemented by sending IoCtl requ...

how can i make IOCTL calls in kernel mode (windows)

In user mode IOCTL calls can be made via DeviceIoControl function. What can I use in kernel mode to issue IOCTL calls? I must use this inside a filesystem minifilter driver. BACKGROUND I am writing a filesystem minifilter driver, and I must issue IOCTL calls to storage devices to find out their serial number and capabilities (removable ...

get an ioctl file descriptor for ethernet port

Hi, I need to get the file descriptor to use in ioctl() calls for an ethernet port in Linux. Not sure how to do this. ...

Why can't I in python call HDIO_GETGEO?

#!/usr/bin/env python # -*- coding: utf-8 -*- ########## THIS NOW WORKS! ########## UNSUITABLE_ENVIRONMENT_ERROR = \ "This program requires at least Python 2.6 and Linux" import sys import struct import os from array import array # +++ Check environment try: import platform # Introduced in Python 2.3 except ImportError: ...

ATA TRIM Specification?

Hi, Anyone know where I'd find an ATA reference that details the protocol for triggering a TRIM? I'm looking to discover what sort of structure/object/data I'd need to send in a raw IOCTL to get an ATA device to trigger a TRIM (assuming appropriate hardware/firmware support, obviously). Thanks. ...

Why should files be mounted in Linux

Hello, I got an old library which does some manipulation with files on floppy\ CD (transferring the files on network paths). This library has a thread which checks on each second whether the file (e.g. the floppy diskette\ the CD disk) is mounted. Why? What operations can be done only on mounted files? Thanks a lot. ...

Detect laptop lid closure and opening

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...

Uninterruptible read/write calls

At some point during my C programming adventures on Linux, I encountered flags (possibly ioctl/fcntl?), that make reads and writes on a file descriptor uninterruptible. Unfortunately I cannot recall how to do this, or where I read it. Can anyone shed some light? Update0 To refine my query, I'm after the same blocking and guarantees th...

How to control access right on a SCSI disk in Linux?

I'm trying to lock a SCSI device (a shared storage disk) using ioctl but I can't find a highlevel API for this and I'm not sure which commands to use. Basically I want to be able to do the four operations mentioned here: http://docs.sun.com/app/docs/doc/816-5177/mhd-7i?l=en&amp;n=1&amp;a=view (See: Non-shared multihost disk). I already h...

what possible reasons could block a virtual terminal on Linux?

Or is it possible at all that some process or something else could block a virtual terminal? Or what could be a reason that an application hangs when trying to access the VT1? It seems, while that is happening, it is hanging in the function ioctl. Esp., this is the code which fails: int vtno = 1; const char* vtname = "/dev/tty1"; int ...

Can ioctl commands in Linux be completely enumerated?

For the purpose of security-oriented source code review, I'm interested in finding (comprehensively) all ioctl commands that are registered in the Linux kernel. Also, I'd like to classify them as either accessible by administrators (e.g root), and which ones are accessible by unprivileged users. I'm not sure if it would be easier to rea...

Having a problem figuring out how to get Ethernet interface info on Mac OS X using ioctl/SIOCGIFADDR/SIOCGIFCONF?

Are you having a problem figuring out how to get interface info on Mac OS X using ioctl/SIOCGIFADDR/SIOCGIFCONF? I had a lot of trouble getting code that worked fine on Linux to work on Mac OS X today. ...