summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-10-26 08:59:58 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-10-26 08:59:58 +0000
commit9806a4f3bb81f71c46735a2b378cb074fef6e27b (patch)
tree285d1f9d993b6233148bc4d82c2383db4c3f7a0c /src/libstddjb
parent15ec28669f6bd4cf4c958f84c0c7dbe58628b375 (diff)
downloadskalibs-9806a4f3bb81f71c46735a2b378cb074fef6e27b.tar.xz
Prepare for 2.9.4.0; add open*coe() functions.
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/open_appendcoe.c10
-rw-r--r--src/libstddjb/open_createcoe.c10
-rw-r--r--src/libstddjb/open_exclcoe.c10
-rw-r--r--src/libstddjb/open_readbcoe.c15
-rw-r--r--src/libstddjb/open_readcoe.c10
-rw-r--r--src/libstddjb/open_trunccoe.c10
-rw-r--r--src/libstddjb/open_writecoe.c10
-rw-r--r--src/libstddjb/openb_readcoe.c10
-rw-r--r--src/libstddjb/openreadfileclose.c2
-rw-r--r--src/libstddjb/openreadnclose.c4
-rw-r--r--src/libstddjb/openslurpclose.c2
-rw-r--r--src/libstddjb/openwritenclose_unsafe.c2
-rw-r--r--src/libstddjb/openwritevnclose_unsafe.c2
13 files changed, 91 insertions, 6 deletions
diff --git a/src/libstddjb/open_appendcoe.c b/src/libstddjb/open_appendcoe.c
new file mode 100644
index 0000000..3bda62e
--- /dev/null
+++ b/src/libstddjb/open_appendcoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_appendcoe (char const *fn)
+{
+ return open3(fn, O_WRONLY | O_NONBLOCK | O_APPEND | O_CREAT | O_CLOEXEC, 0666) ;
+}
diff --git a/src/libstddjb/open_createcoe.c b/src/libstddjb/open_createcoe.c
new file mode 100644
index 0000000..4f42f78
--- /dev/null
+++ b/src/libstddjb/open_createcoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_createcoe (char const *fn)
+{
+ return open3(fn, O_WRONLY | O_NONBLOCK | O_CREAT | O_CLOEXEC, 0666) ;
+}
diff --git a/src/libstddjb/open_exclcoe.c b/src/libstddjb/open_exclcoe.c
new file mode 100644
index 0000000..b24786c
--- /dev/null
+++ b/src/libstddjb/open_exclcoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_exclcoe (char const *fn)
+{
+ return open3(fn, O_WRONLY | O_CREAT | O_EXCL | O_NONBLOCK | O_CLOEXEC, 0666) ;
+}
diff --git a/src/libstddjb/open_readbcoe.c b/src/libstddjb/open_readbcoe.c
new file mode 100644
index 0000000..d461854
--- /dev/null
+++ b/src/libstddjb/open_readbcoe.c
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#include <skalibs/djbunix.h>
+
+int open_readbcoe (char const *fn)
+{
+ int fd = open_readbcoe(fn) ;
+ if (fd < 0) return -1 ;
+ if (ndelay_off(fd) < 0)
+ {
+ fd_close(fd) ;
+ return -1 ;
+ }
+ return fd ;
+}
diff --git a/src/libstddjb/open_readcoe.c b/src/libstddjb/open_readcoe.c
new file mode 100644
index 0000000..cd6a69d
--- /dev/null
+++ b/src/libstddjb/open_readcoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_readcoe (char const *fn)
+{
+ return open2(fn, O_RDONLY | O_NONBLOCK | O_CLOEXEC) ;
+}
diff --git a/src/libstddjb/open_trunccoe.c b/src/libstddjb/open_trunccoe.c
new file mode 100644
index 0000000..3be3df6
--- /dev/null
+++ b/src/libstddjb/open_trunccoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_trunccoe (char const *fn)
+{
+ return open3(fn, O_WRONLY | O_NONBLOCK | O_TRUNC | O_CREAT | O_CLOEXEC, 0666) ;
+}
diff --git a/src/libstddjb/open_writecoe.c b/src/libstddjb/open_writecoe.c
new file mode 100644
index 0000000..d04c4c5
--- /dev/null
+++ b/src/libstddjb/open_writecoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int open_writecoe (char const *fn)
+{
+ return open2(fn, O_WRONLY | O_NONBLOCK | O_CLOEXEC) ;
+}
diff --git a/src/libstddjb/openb_readcoe.c b/src/libstddjb/openb_readcoe.c
new file mode 100644
index 0000000..933830e
--- /dev/null
+++ b/src/libstddjb/openb_readcoe.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int openb_readcoe (char const *fn)
+{
+ return open2(fn, O_RDONLY | O_CLOEXEC) ;
+}
diff --git a/src/libstddjb/openreadfileclose.c b/src/libstddjb/openreadfileclose.c
index baed267..95895e8 100644
--- a/src/libstddjb/openreadfileclose.c
+++ b/src/libstddjb/openreadfileclose.c
@@ -8,7 +8,7 @@
int openreadfileclose (char const *file, stralloc *sa, size_t limit)
{
size_t n ;
- int fd = open_readb(file) ;
+ int fd = openb_readcoe(file) ;
if (fd < 0) return 0 ;
{
struct stat st ;
diff --git a/src/libstddjb/openreadnclose.c b/src/libstddjb/openreadnclose.c
index e765499..0853c87 100644
--- a/src/libstddjb/openreadnclose.c
+++ b/src/libstddjb/openreadnclose.c
@@ -22,12 +22,12 @@ static ssize_t readnclose (int fd, char *s, size_t n)
ssize_t openreadnclose (char const *file, char *s, size_t n)
{
- int fd = open_readb(file) ;
+ int fd = openb_readcoe(file) ;
return fd < 0 ? fd : readnclose(fd, s, n) ;
}
ssize_t openreadnclose_nb (char const *file, char *s, size_t n)
{
- int fd = open_read(file) ;
+ int fd = open_readcoe(file) ;
return fd < 0 ? fd : readnclose(fd, s, n) ;
}
diff --git a/src/libstddjb/openslurpclose.c b/src/libstddjb/openslurpclose.c
index 50d361e..6a431d0 100644
--- a/src/libstddjb/openslurpclose.c
+++ b/src/libstddjb/openslurpclose.c
@@ -6,7 +6,7 @@
int openslurpclose (stralloc *sa, char const *fn)
{
int r ;
- int fd = open_readb(fn) ;
+ int fd = openb_readcoe(fn) ;
if (fd == -1) return 0 ;
r = slurp(sa, fd) ;
fd_close(fd) ;
diff --git a/src/libstddjb/openwritenclose_unsafe.c b/src/libstddjb/openwritenclose_unsafe.c
index 7969e4f..893fc3a 100644
--- a/src/libstddjb/openwritenclose_unsafe.c
+++ b/src/libstddjb/openwritenclose_unsafe.c
@@ -6,7 +6,7 @@
int openwritenclose_unsafe_internal (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino, int dosync)
{
- int fd = open_trunc(fn) ;
+ int fd = open_trunccoe(fn) ;
if (fd < 0) return 0 ;
if (!writenclose_unsafe_internal(fd, s, len, dev, ino, dosync))
{
diff --git a/src/libstddjb/openwritevnclose_unsafe.c b/src/libstddjb/openwritevnclose_unsafe.c
index f3e6a6a..d707fb0 100644
--- a/src/libstddjb/openwritevnclose_unsafe.c
+++ b/src/libstddjb/openwritevnclose_unsafe.c
@@ -8,7 +8,7 @@
int openwritevnclose_unsafe_internal (char const *fn, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino, int dosync)
{
- int fd = open_trunc(fn) ;
+ int fd = open_trunccoe(fn) ;
if (fd < 0) return 0 ;
if (!writevnclose_unsafe_internal(fd, v, vlen, dev, ino, dosync))
{