Discussion:
dd of=/dev/port.
Shaul Karl
2004-08-08 14:07:29 UTC
Permalink
Is the following expected?

# printf "\xa2" | dd of=/dev/port bs=1 count=1 skip=675
0+0 records in
0+0 records out
0 bytes transferred in 0.001999 seconds (0 bytes/sec)
# printf "$?\n"
0

I run it as root. Why there were 0 bytes transferred and still it is
a 0 return code? Is there any significance in the fact that there were
0+0 records in? A delay must be used? Should I use ioperm (2) before?
Anything else?
It is kernel 2.6.7-2 on a Debian system.

I believe I can read, although I am still try to verify that the
output is what is expected:

$ dd if=/dev/port bs=1 count=5 skip=672 | od -b
dd: opening `/dev/port': Permission denied
0000000
$

# dd if=/dev/port bs=1 count=5 skip=672 | od -b
5+0 records in
5+0 records out
5 bytes transferred in 0.000461 seconds (10846 bytes/sec)
0000000 377 377 377 000 000
0000005
#
--
"If you have an apple and I have an apple and we exchange apples then
you and I will still each have one apple. But if you have an idea and I
have an idea and we exchange these ideas, then each of us will have two
ideas." -- George Bernard Shaw (sent by shaulk @ 013 . net . il)

=================================================================
To unsubscribe, send mail to linux-il-request-Xh+***@public.gmane.org with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request-Xh+***@public.gmane.org
a***@public.gmane.org
2004-08-08 14:30:39 UTC
Permalink
Post by Shaul Karl
Is the following expected?
# printf "\xa2" | dd of=/dev/port bs=1 count=1 skip=675
0+0 records in
0+0 records out
0 bytes transferred in 0.001999 seconds (0 bytes/sec)
# printf "$?\n"
0
I run it as root. Why there were 0 bytes transferred and still it is
a 0 return code? Is there any significance in the fact that there were
What does strace(1) say about this?

--Amos



=================================================================
To unsubscribe, send mail to linux-il-request-Xh+***@public.gmane.org with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request-Xh+***@public.gmane.org
Shaul Karl
2004-08-08 22:18:04 UTC
Permalink
Post by a***@public.gmane.org
Post by Shaul Karl
Is the following expected?
# printf "\xa2" | dd of=/dev/port bs=1 count=1 skip=675
0+0 records in
0+0 records out
0 bytes transferred in 0.001999 seconds (0 bytes/sec)
# printf "$?\n"
0
I run it as root. Why there were 0 bytes transferred and still it is
a 0 return code? Is there any significance in the fact that there were
What does strace(1) say about this?
strace was helpful.
Should have issued:

printf "\xa2" | dd of=/dev/port bs=1 count=1 seek=675

that is seek and not skip at the end. If someone is curious I can send
the full output of strace.
--
"If you have an apple and I have an apple and we exchange apples then
you and I will still each have one apple. But if you have an idea and I
have an idea and we exchange these ideas, then each of us will have two
ideas." -- George Bernard Shaw (sent by shaulk @ 013 . net . il)

=================================================================
To unsubscribe, send mail to linux-il-request-Xh+***@public.gmane.org with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request-Xh+***@public.gmane.org
Ez-Aton
2004-08-12 01:29:54 UTC
Permalink
dd is meant to be used with block devices, not with character devices.
To hijack character devices, you can simply cat them to somewhere.

Ez.
Post by a***@public.gmane.org
Post by Shaul Karl
Is the following expected?
# printf "\xa2" | dd of=/dev/port bs=1 count=1 skip=675
0+0 records in
0+0 records out
0 bytes transferred in 0.001999 seconds (0 bytes/sec)
# printf "$?\n"
0
I run it as root. Why there were 0 bytes transferred and still it is
a 0 return code? Is there any significance in the fact that there were
What does strace(1) say about this?
--Amos
=================================================================
the word "unsubscribe" in the message body, e.g., run the command
=================================================================
To unsubscribe, send mail to linux-il-request-Xh+***@public.gmane.org with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request-Xh+***@public.gmane.org
a***@public.gmane.org
2004-08-12 06:28:19 UTC
Permalink
Post by Ez-Aton
dd is meant to be used with block devices, not with character devices.
To hijack character devices, you can simply cat them to somewhere.
But dd has the relatively singular option (apart from perl, I guess) of
letting its user
to control an lseek(2) call from command line, which is what Shaul
exploited "as
designed" (in the answer to his own question he used "seek" which solved
his problem).

Cheers,

--Amos
Post by Ez-Aton
Ez.
Post by Shaul Karl
Is the following expected?
# printf "\xa2" | dd of=/dev/port bs=1 count=1 skip=675
0+0 records in
0+0 records out
0 bytes transferred in 0.001999 seconds (0 bytes/sec)
# printf "$?\n"
0
I run it as root. Why there were 0 bytes transferred and still it is
a 0 return code? Is there any significance in the fact that there were
=================================================================
To unsubscribe, send mail to linux-il-request-Xh+***@public.gmane.org with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request-Xh+***@public.gmane.org
Loading...