php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59336 ioctl() support
Submitted: 2010-08-03 14:59 UTC Modified: 2010-08-10 08:39 UTC
Votes:10
Avg. Score:4.0 ± 0.8
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:6 (85.7%)
From: florian at phpws dot org Assigned:
Status: Wont fix Package: dio (PECL)
PHP Version: Irrelevant OS: POSIX
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: florian at phpws dot org
New email:
PHP Version: OS:

 

 [2010-08-03 14:59 UTC] florian at phpws dot org
Description:
------------
Support for ioctl() would greatly enhance the usability and scope of the dio package under Unix based systems. It would allow to configure devices that are being used with the other functions provided by dio and thereby allow for the PHP user to make use of the full scale of system devices.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-10 08:39 UTC] cyberspice@php.net
The problem with ioctl is how to handle that inconvenient 
third argument.  The prototype for ioctl is:

int ioctl(int fd, int cmd, ...);

The var-args last argument can be a long, or a pointer to 
anything.  It is very much driver specific.  The Linux 
kernel itself doesn't know the type of that argument.  
Admittedly there is some type information stored in the 
ioctl cmd value (together with the data direction - in, out, 
in/out) but it doesn't help that much.  

Implementing a PHP wrapper will not be trivial.  The third 
argument of dio_ioctl() would have to be a reference to a 
PHP variable.  Structure data would have to be represented 
as binary data in strings and it would be up to the 
implementer to populate and interpret those binary strings.  
You couldn't pass in hashes/arrays or objects as DIO would 
not know what to do with them.

Personally I feel if you're going as far as wanting to drive 
ioctls from PHP you should be writing a PECL extension to do 
it.  It is my intention to implement a DIO class which 
encapsulates the current DIO posix functions so once this is 
done you could extend that class in your own extension and 
add methods that call any ioctls you need to call.
 [2017-07-15 00:10 UTC] philipp at redfish-solutions dot com
I think you're missing something.  The type and size of the 3rd argument are embedded in the value of the 2nd argument.

See the _IOC() macro, and the IOC_TYPE() and _IOC_SIZE() macros:

http://elixir.free-electrons.com/linux/v3.6/source/include/asm-generic/ioctl.h#L65

If there's enough information to marshal into/out of userspace to kernel space, then there's enough information to marshal (the blob) for a simple language wrapper.

To compose/decompose the blob, yes, some sophisticated use of pack()/unpack() would be required.
 [2020-04-21 15:01 UTC] bugs dot php dot net at list dot robertkosten dot de
Can this request be reopened? I'm (ab-)using php as a general cli scripting language and need the cdrom ioctl calls.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 21:01:29 2024 UTC