[fedfs-utils] [PATCH 1/3] open(2) with O_CREAT requires the caller to provide a mode.
Chuck Lever
chuck.lever at oracle.com
Tue Aug 2 09:19:06 PDT 2011
From: Jeff Layton <jlayton at redhat.com>
Signed-off-by: Jeff Layton <jlayton at redhat.com>
Jeff reports the following error:
=== cut here ===
Here's an excerpt from the build with RPM:
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I. -I../../src/include -ggdb -fstrict-aliasing -fpie -Wall -Wextra -pedantic -Wformat=2 -Wstrict-aliasing=2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c nsdb.c
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I. -I../../src/include -ggdb -fstrict-aliasing -fpie -Wall -Wextra -pedantic -Wformat=2 -Wstrict-aliasing=2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c sqlite.c
In file included from /usr/include/fcntl.h:267:0,
from nsdb.c:39:
In function 'open',
inlined from 'nsdb_new_certfile' at nsdb.c:535:5:
/usr/include/bits/fcntl2.h:51:24: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT in second argument needs 3 arguments
I think the -D_FORTIFY_SOURCE=2 is what makes this check happen.
=== cut here ===
NB: This code does not work before or after this patch is applied, as
it is currently provisional and untested.
I'm applying this patch to prevent compiler errors when fedfs-utils is
built by RPM's automated build process. More is planned for a
subsequent release.
Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---
src/libnsdb/nsdb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index cad92eb..00be913 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -532,7 +532,7 @@ nsdb_new_certfile(const char *certdata, const unsigned int certlen,
goto out;
}
- fd = open(pathbuf, O_WRONLY | O_SYNC | O_CREAT | O_EXCL);
+ fd = open(pathbuf, O_WRONLY | O_SYNC | O_CREAT | O_EXCL, 0666);
if (fd == -1) {
xlog(D_GENERAL, "%s: Failed to open %s: %m",
__func__, pathbuf);
More information about the fedfs-utils-devel
mailing list