Getting the list of IOCTLS in the kernel.

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


for $keys (keys %ioctls_numbers)
print \”$keys — $ioctls_numbers{$keys}\\n\”;

find duplicate entry in a list in bash with sed

Here I will take an example of rss2email list, but I guess I will be able to pass on the concept.

Here is example of the output of the r2e list command:

1: (default: [email protected])
2: (default: [email protected])
3: (default: [email protected])
4: (default: [email protected])

Target here is to get the list of all duplicate entries if any. So, first we need to remove the numbers from the begining and the email ID from the end.

We will use sed to remove the email and the numbers. Heres what we can use for doing this

sed \’s/^[0-9]*: //\’


sed \’s/ (.*//\’

So, let\’s try now with

r2e list |sed \’s/^[0-9]*: //\’ |sed \’s/ (.*//\’

If you see just the lines we are interested in then it is time to use the uniq command.

r2e list |sed \’s/^[0-9]*: //\’ |sed \’s/ (.*//\’ |uniq -d