Getting the list of IOCTLS in the kernel.
2010-06-25
191 words
1 min read
Sometime back I was helping one of my friends in looking for all the IOCTLs supported by the kernel. Well we did not find the info we were looking for and thus thought to write a perl script to get all the IOCTLS supported by the kernel. Here it is, simple script to scan through the code and give you a list:
#!/usr/bin/perl —
@files = `grep -r ” _IO” /usr/src/redhat/SOURCES/linux-2.6.20/* |grep define ioctls_grep`;
open (DAT, ”ioctls_grep”) ||die ”could not open ioctls_grep”;
@files = DAT;
close(DAT);
my %ioctls_numbers;
print ”Grep completed..\n”;
open (DAT, ”ioctls_numbers_found”);foreach (@files)
{
($file, $line) = split(/:/);
print ”$file\n\t”;
$_ = $line;
($junk, $name, $test) = split;
$temp = $test;
if ($temp =~ m/^_IORW/) { print ” Read/Write :: $name $test\n”;}
elsif ($temp =~ m/^_IOR/) { print ” Read :: $name $test\n”;}
elsif ($temp =~ m/^_IOW/){ print ” Write :: $name $test\n”;}
elsif ($temp =~ m/^_IO/) {print ” IOCTLS :: $name $test\n”;}
else {
print ”$name $test\n”;
if ($test =~ m/^0x/ ){
$ioctls_numbers{$name} = $test;
print DAT ”$name \t\t\t– $test in file $file\n”
}
}}
close(DAT);for $keys (keys %ioctls_numbers)
{
print ”$keys — $ioctls_numbers{$keys}\n”;
}
Related Articles:
- 2010/05/24 Inotify Example - Introduction to Inotify with a C Program Example
- 2010/06/02 Logwatch for Linux Systems.
- 2010/04/29 Building Your Own Linux Kernel, part 1
- 2010/04/28 String and Array Creation
- 2010/04/11 Bugzilla Automation with perl — add, update or query any bug in Bugzilla using perl and www series modules for perl.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.