Hi,
This might be new or might not happen to all: I see quite a lot of files
having compiling error of missing argument for open() function when
O_CREAT is in the flag, as following:
In function 'open',
inlined from 'main' at getdents04.c:141:
/usr/include/bits/fcntl2.h:51: error: call to '__open_missing_mode'
declared with attribute error: open with O_CREAT in second argument
needs 3 arguments
Thus I did a patch, which fixes mainly the above issue. It also fixes
another issue of too many arguments for open() function in iogen.c file:
iogen.c:1089:
/usr/include/bits/fcntl2.h:45: error: call to '__open_too_many_args'
declared with attribute error: open can be called eit
her with 2 or 3 arguments, not more
Maybe you find the patch useful.
Thanks,
Yi
--
Yi Xu, QA Engineer
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/clone/clone02.c ltp-full-20071231/testcases/kernel/syscalls/clone/clone02.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/clone/clone02.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/clone/clone02.c 2008-01-17 14:19:00.000000000 +0100
@@ -327,7 +327,7 @@ test_setup()
* Open file from parent, which will be closed by
* child in test_FILES(), used for testing CLONE_FILES flag
*/
- if ((fd_parent = open(file_name, O_CREAT | O_RDWR)) == -1) {
+ if ((fd_parent = open(file_name, O_CREAT | O_RDWR, 0777)) == -1) { //mode must be specified when O_CREATE is in the flag
tst_resm(TWARN, "open() failed in test_setup()");
return 0;
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/fcntl/fcntl18.c ltp-full-20071231/testcases/kernel/syscalls/fcntl/fcntl18.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/fcntl/fcntl18.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/fcntl/fcntl18.c 2008-01-17 14:26:07.000000000 +0100
@@ -81,7 +81,7 @@ int main(int ac, char **av)
/* Skip since uClinux does not implement memory protection */
tst_resm(TINFO, "Enter block 1");
fail = 0;
- if ((fd = open("temp.dat", O_CREAT|O_RDWR)) < 0) {
+ if ((fd = open("temp.dat", O_CREAT|O_RDWR, 0777)) < 0) { //mode must be specified when O_CREATE is in the flag
tst_resm(TFAIL, "file opening error");
fail = 1;
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/fdatasync/fdatasync01.c ltp-full-20071231/testcases/kernel/syscalls/fdatasync/fdatasync01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/fdatasync/fdatasync01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/fdatasync/fdatasync01.c 2008-01-17 14:33:22.000000000 +0100
@@ -144,7 +144,7 @@ setup(void)
tst_brkm(TBROK, tst_exit, "Failed to initialize filename");
/*NOTREACHED*/
}
- if((fd = open(filename, O_CREAT|O_WRONLY)) == -1) {
+ if((fd = open(filename, O_CREAT|O_WRONLY, 0777)) == -1) { //mode must be specified when O_CREATE is in the flag
tst_brkm(TBROK, tst_exit, "open() failed");
/*NOTREACHED*/
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/getdents/getdents04.c ltp-full-20071231/testcases/kernel/syscalls/getdents/getdents04.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/getdents/getdents04.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/getdents/getdents04.c 2008-01-17 16:02:14.000000000 +0100
@@ -138,7 +138,7 @@ int main(int ac, char **av)
tst_brkm(TBROK, cleanup, "sprintf failed");
}
- if ((fd = open(newfile, O_CREAT | O_RDWR)) == -1) {
+ if ((fd = open(newfile, O_CREAT | O_RDWR, 0777)) == -1) {
perror("file open");
tst_brkm(TBROK, cleanup, "open of file failed");
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/mprotect/mprotect02.c ltp-full-20071231/testcases/kernel/syscalls/mprotect/mprotect02.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/mprotect/mprotect02.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/mprotect/mprotect02.c 2008-01-17 14:49:24.000000000 +0100
@@ -98,8 +98,7 @@ int main(int ac, char **av)
/* reset Tst_count in case we are looping */
Tst_count = 0;
- fd = open(file1, O_RDWR | O_CREAT);
- if (fd < 0) {
+ if ((fd = open(file1, O_RDWR | O_CREAT, 0777) < 0 )) { //mode must be specified when O_CREATE is in the flag
tst_brkm(TBROK, cleanup, "open failed");
/*NOTREACHED*/
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/mprotect/mprotect03.c ltp-full-20071231/testcases/kernel/syscalls/mprotect/mprotect03.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/mprotect/mprotect03.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/mprotect/mprotect03.c 2008-01-17 14:54:48.000000000 +0100
@@ -99,8 +99,7 @@ int main(int ac, char **av)
/* reset Tst_count in case we are looping */
Tst_count = 0;
- fd = open(file1, O_RDWR | O_CREAT);
- if (fd < 0) {
+ if((fd = open(file1, O_RDWR | O_CREAT, 0777)) < 0 ) { //mode must be specified when O_CREAT is in the flag
tst_brkm(TBROK, cleanup, "open failed");
/*NOTREACHED*/
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/open/open04.c ltp-full-20071231/testcases/kernel/syscalls/open/open04.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/open/open04.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/open/open04.c 2008-01-17 14:59:12.000000000 +0100
@@ -87,7 +87,7 @@ int main(int ac, char **av)
/* reset Tst_count in case we are looping */
Tst_count = 0;
- TEST(open(fname, O_RDWR | O_CREAT));
+ TEST(open(fname, O_RDWR | O_CREAT, 0777));
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "call succeeded unexpectedly");
@@ -129,7 +129,7 @@ setup()
nfile = getdtablesize();
sprintf(fname, "open04.%d", mypid);
- if ((first = fd = open(fname, O_RDWR | O_CREAT)) == -1) {
+ if ((first = fd = open(fname, O_RDWR | O_CREAT, 0777)) == -1) {
tst_brkm(TBROK, cleanup, "Cannot open first file");
}
@@ -144,7 +144,7 @@ setup()
for (ifile = first; ifile <= nfile; ifile++) {
sprintf(fname, "open04.%d.%d", ifile, mypid);
- if ((fd = open(fname, O_RDWR | O_CREAT)) == -1) {
+ if ((fd = open(fname, O_RDWR | O_CREAT, 0777)) == -1) {
if (errno != EMFILE) {
tst_brkm(TBROK, cleanup, "Expected EMFILE got "
"%d", errno);
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/pselect/pselect01.c ltp-full-20071231/testcases/kernel/syscalls/pselect/pselect01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/pselect/pselect01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/pselect/pselect01.c 2008-01-17 15:11:22.000000000 +0100
@@ -69,7 +69,7 @@ int main()
setup();
- fd = open(FILENAME,O_CREAT | O_RDWR);
+ fd = open(FILENAME,O_CREAT | O_RDWR, 0777);
if (fd < 0)
{
tst_resm(TBROK,"Opening %s...Failed....err %d",FILENAME,errno);
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/read/read02.c ltp-full-20071231/testcases/kernel/syscalls/read/read02.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/read/read02.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/read/read02.c 2008-01-17 15:02:50.000000000 +0100
@@ -173,7 +173,7 @@ setup(void)
tst_brkm(TBROK, cleanup, "open of fd2 failed");
}
- if ((fd3 = open(fname, O_RDWR | O_CREAT)) == -1) {
+ if ((fd3 = open(fname, O_RDWR | O_CREAT, 0666)) == -1) {
tst_brkm(TBROK, cleanup, "open of fd3 (temp file) failed");
}
@@ -182,7 +182,7 @@ setup(void)
/*NOTREACHED*/
}
close(fd3);
- if ((fd3 = open(fname, O_RDWR | O_CREAT)) == -1) {
+ if ((fd3 = open(fname, O_RDWR | O_CREAT, 0666)) == -1) {
tst_brkm(TBROK, cleanup, "open of fd3 (temp file) failed");
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/select/select01.c ltp-full-20071231/testcases/kernel/syscalls/select/select01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/select/select01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/select/select01.c 2008-01-17 15:14:02.000000000 +0100
@@ -228,7 +228,7 @@ setup()
/* create a temporary directory and go to it */
tst_tmpdir();
- if ((Fd=open(FILENAME, O_CREAT | O_RDWR)) == -1) {
+ if ((Fd=open(FILENAME, O_CREAT | O_RDWR, 0777)) == -1) {
tst_brkm(TBROK, cleanup,
"open(%s, O_CREAT | O_RDWR) failed: errno:%d\n",
errno);
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/sendfile/sendfile03.c ltp-full-20071231/testcases/kernel/syscalls/sendfile/sendfile03.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/sendfile/sendfile03.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/sendfile/sendfile03.c 2008-01-17 15:12:22.000000000 +0100
@@ -175,7 +175,7 @@ setup()
/*NOTREACHED*/
}
sprintf(out_file, "out.%d", getpid());
- if ((out_fd = open(out_file, O_TRUNC | O_CREAT | O_RDWR)) < 0) {
+ if ((out_fd = open(out_file, O_TRUNC | O_CREAT | O_RDWR, 0777)) < 0) {
tst_brkm(TBROK, cleanup, "open failed, errno: %d", errno);
/*NOTREACHED*/
}
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/splice/splice01.c ltp-full-20071231/testcases/kernel/syscalls/splice/splice01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/splice/splice01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/splice/splice01.c 2008-01-17 15:04:20.000000000 +0100
@@ -157,7 +157,7 @@ static int splice_test(void)
buffer[i] = i & 0xff;
}
- fd_in = open(testfile1, O_WRONLY | O_CREAT | O_TRUNC);
+ fd_in = open(testfile1, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd_in < 0) {
perror("open: ");
return -1;
@@ -183,7 +183,7 @@ static int splice_test(void)
return -1;
}
- fd_out = open(testfile2, O_WRONLY | O_CREAT | O_TRUNC);
+ fd_out = open(testfile2, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd_out < 0) {
close(fd_in);
close(pipes[0]);
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/symlink/symlink01.c ltp-full-20071231/testcases/kernel/syscalls/symlink/symlink01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/symlink/symlink01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/symlink/symlink01.c 2008-01-17 15:06:13.000000000 +0100
@@ -1078,7 +1078,7 @@ struct all_test_cases *tc_ptr;
}
else if (cktcsid(tc_ptr->tcid, OPEN)) {
- TEST( open(tc_ptr->fn_arg[1], (O_EXCL | O_CREAT)) );
+ TEST( open(tc_ptr->fn_arg[1], (O_EXCL | O_CREAT), 0666) );
errno=TEST_ERRNO;
if ((TEST_RETURN == -1) && (errno == EEXIST))
if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST )
@@ -1281,7 +1281,7 @@ struct all_test_cases *tc_ptr;
else if (cktcsid(tc_ptr->tcid, OPEN)) {
int fd;
- TEST( open(tc_ptr->fn_arg[1], O_CREAT) );
+ TEST( open(tc_ptr->fn_arg[1], O_CREAT, 0666) );
fd=TEST_RETURN;
errno=TEST_ERRNO;
if ((fd == -1) && (errno == ELOOP))
diff -pur ltp-full-20071231.orig/testcases/kernel/syscalls/tee/tee01.c ltp-full-20071231/testcases/kernel/syscalls/tee/tee01.c
--- ltp-full-20071231.orig/testcases/kernel/syscalls/tee/tee01.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/syscalls/tee/tee01.c 2008-01-17 15:18:40.000000000 +0100
@@ -160,7 +160,7 @@ static int tee_test(void)
buffer[i] = i & 0xff;
}
- fd_in = open(testfile1, O_WRONLY | O_CREAT | O_TRUNC);
+ fd_in = open(testfile1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
if (fd_in < 0) {
perror("open: ");
return -1;
@@ -195,7 +195,7 @@ static int tee_test(void)
return -1;
}
- fd_out = open(testfile2, O_WRONLY | O_CREAT | O_TRUNC);
+ fd_out = open(testfile2, O_WRONLY | O_CREAT | O_TRUNC, 0777);
if (fd_out < 0) {
close(fd_in);
close(pipe1[0]);
diff -pur ltp-full-20071231.orig/testcases/network/ipv6/sendfile6/testsf_c6.c ltp-full-20071231/testcases/network/ipv6/sendfile6/testsf_c6.c
--- ltp-full-20071231.orig/testcases/network/ipv6/sendfile6/testsf_c6.c 2008-01-17 11:18:40.000000000 +0100
+++ ltp-full-20071231/testcases/network/ipv6/sendfile6/testsf_c6.c 2008-01-17 15:27:14.000000000 +0100
@@ -43,7 +43,7 @@ char *argv[];
serv_fname = argv[4]; /* filename to request */
/* prepare to copy file from server to local machine */
- if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY)) < 0) {
+ if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY, 0777)) < 0) {
printf("file open error = %d\n", errno);
close(s);
exit(1);
diff -pur ltp-full-20071231.orig/testcases/network/tcp_cmds/sendfile/testsf_c.c ltp-full-20071231/testcases/network/tcp_cmds/sendfile/testsf_c.c
--- ltp-full-20071231.orig/testcases/network/tcp_cmds/sendfile/testsf_c.c 2008-01-17 11:18:40.000000000 +0100
+++ ltp-full-20071231/testcases/network/tcp_cmds/sendfile/testsf_c.c 2008-01-17 15:28:30.000000000 +0100
@@ -47,7 +47,7 @@ char *argv[];
clnt_fname = argv[3]; /* filename to create */
/* prepare to copy file from server to local machine */
- if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY)) < 0) {
+ if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY, 0777)) < 0) {
tst_resm(TBROK, "file open error = %d\n", errno);
close(s);
exit(1);
--- ltp-full-20071231.orig/testcases/kernel/fs/doio/iogen.c 2008-01-17 11:18:39.000000000 +0100
+++ ltp-full-20071231/testcases/kernel/fs/doio/iogen.c 2008-01-17 12:01:00.000000000 +0100
@@ -1085,7 +1085,7 @@ int nbytes;
Oflags |= O_CREAT | O_WRONLY;
- if ((fd = open(path, Oflags, 0666, Ocbits, Ocblks)) == -1) {
+ if ((fd = open(path, Oflags, 0666)) == -1) {
fprintf(stderr, "iogen%s: Could not create/open file %s: %s (%d)\n",
TagName, path, SYSERR, errno);
return -1;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list