O_CREAT requires a mode argument for open()
This patch passes the current umask of the dd process.
--- usr/klibc/klibc-0.81.orig/utils/dd.c	2002-09-03 00:49:08.000000000 +0200
+++ usr/klibc/klibc-0.81/utils/dd.c	2003-11-23 18:04:11.000000000 +0100
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #define ARRAY_SIZE(x)	(sizeof(x) / sizeof(x[0]))
 
@@ -483,7 +485,7 @@ int main(int argc, char *argv[])
 	 * Open the output file, if specified.
 	 */
 	if (OPT_OF->str) {
-		wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT);
+		wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT,~umask(0) &
(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH));
 		if (wr_fd == -1) {
 			perror("open output file");
 			return 1;
-- 
USB is for mice, FireWire is for men!
sUse lINUX ag, n?RNBERG
Olaf Hering wrote:> O_CREAT requires a mode argument for open() > This patch passes the current umask of the dd process. >No need to; umask is anded by the kernel. Just pass 0666 or 0777, whichever is appropriate. Either way, this one is already fixed in the CVS tree. -hpa> > --- usr/klibc/klibc-0.81.orig/utils/dd.c 2002-09-03 00:49:08.000000000 +0200 > +++ usr/klibc/klibc-0.81/utils/dd.c 2003-11-23 18:04:11.000000000 +0100 > @@ -8,6 +8,8 @@ > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > +#include <sys/types.h> > +#include <sys/stat.h> > > #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) > > @@ -483,7 +485,7 @@ int main(int argc, char *argv[]) > * Open the output file, if specified. > */ > if (OPT_OF->str) { > - wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT); > + wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT,~umask(0) & (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)); > if (wr_fd == -1) { > perror("open output file"); > return 1;