[BusyBox] dd permission denied problem!
Matt Kraai
kraai at alumni.carnegiemellon.edu
Tue Jan 16 17:34:01 UTC 2001
On Tue, Jan 16, 2001 at 09:14:54AM -0800, kent robotti wrote:
> I wrote:
>> I'll assume you've checked that the permissions of /dev/null
>> and /dev/loop0 allow write access. Given that, my guess is that
>> the ftruncate call is failing. Would you please test again,
>> adding conv=notrunc to the command line?
>
> There's no problem it i use conv=notrunc.
I forgot to copy the list on a patch which I believe fixes the
problem. Here it is:
--- dd.c.orig Tue Jan 16 07:14:04 2001
+++ dd.c Tue Jan 16 07:54:14 2001
@@ -41,7 +41,7 @@
int dd_main(int argc, char **argv)
{
- int i, ifd, ofd, sync = FALSE, trunc = TRUE;
+ int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
@@ -94,8 +94,19 @@
}
if (outfile != NULL) {
- if ((ofd = open(outfile, O_WRONLY | O_CREAT, 0666)) < 0)
+ oflag = O_WRONLY | O_CREAT;
+
+ if (!seek && trunc)
+ oflag |= O_TRUNC;
+
+ if ((ofd = open(outfile, oflag, 0666)) < 0)
perror_msg_and_die("%s", outfile);
+
+ if (seek && trunc) {
+ if (ftruncate(ofd, seek * bs) < 0)
+ perror_msg_and_die("%s", outfile);
+ }
+
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
@@ -110,11 +121,6 @@
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
- perror_msg_and_die("%s", outfile);
- }
-
- if (trunc) {
- if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
Matt
More information about the busybox
mailing list