[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Possible dd bug - no close of "if=/of=" fds
From: |
HARDY, Steven |
Subject: |
RE: Possible dd bug - no close of "if=/of=" fds |
Date: |
Wed, 7 Dec 2005 18:01:25 -0000 |
Thanks very much - your tip led me to the problem which is that
/dev/mydevice's driver returns -EIO from it's release() function, and this
return value is not returned to the user via close() - reimplementing this
as a flush() function solved the problem, since the -EIO is passed up
through close() to dd.
Apologies for blaming dd, I've certainly learnt a few things looking through
it's code!
Many thanks,
Steve
-----Original Message-----
From: Jim Meyering [mailto:address@hidden
Sent: Wednesday, December 07, 2005 3:36 PM
To: HARDY, Steven
Cc: 'address@hidden'
Subject: Re: Possible dd bug - no close of "if=/of=" fds
"HARDY, Steven" <address@hidden> wrote:
> I'm experiencing some problems trying to use "dd" to load firmware
> onto a device, and I guess this could be a potential bug?
>
> - dd if=myfirmware.bin of=/dev/mydevice
>
> The problem is that /dev/mydevice returns -EIO if the load has been
> unsuccessful, but dd always returns 0 whether this occurs or not.
>
> I was expecting dd to explicitly close the if=/of= file descriptors
> and return any errors, but looking at the code it seems to close only
> stdin/stdout, and does not check for successful close of the input and
> output files??
>
> I am using coreutils-5.9.3 - any help or suggestions much appreciated.
If you're using Linux, try using strace on it:
strace -o log dd if=myfirmware.bin of=/dev/mydevice
You'll see that dd reopens stdin on the if=...-specified name, and reopens
stdout on the of=...-specified name. So when it closes STDIN_FILENO, it's
actually closing a file handle that is open on your input file.
This email is for the intended addressee only.
If you have received it in error then you must not use, retain, disseminate or
otherwise deal with it.
Please notify the sender by return email.
The views of the author may not necessarily constitute the views of EADS
Astrium Limited.
Nothing in this email shall bind EADS Astrium Limited in any contract or
obligation.
EADS Astrium Limited, Registered in England and Wales No. 2449259
Registered Office: Gunnels Wood Road, Stevenage, Hertfordshire, SG1 2AS, England