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”;
}


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it