summaryrefslogtreecommitdiff
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
parent15ec28669f6bd4cf4c958f84c0c7dbe58628b375 (diff)
downloadskalibs-9806a4f3bb81f71c46735a2b378cb074fef6e27b.tar.xz
Prepare for 2.9.4.0; add open*coe() functions.
-rw-r--r--NEWS6
-rw-r--r--doc/index.html2
-rw-r--r--doc/libstddjb/djbunix.html51
-rw-r--r--doc/license.html2
-rw-r--r--doc/upgrade.html7
-rw-r--r--package/info2
-rw-r--r--src/include/skalibs/djbunix.h8
-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
20 files changed, 166 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 887216d..becc140 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
Changelog for skalibs.
+In 2.9.4.0
+----------
+
+ - New open*coe functions.
+
+
In 2.9.3.0
----------
diff --git a/doc/index.html b/doc/index.html
index 7d86278..c7cb59c 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -60,7 +60,7 @@ with a standard C development environment </li>
<h3> Download </h3>
<ul>
- <li> The current released version of skalibs is <a href="skalibs-2.9.3.0.tar.gz">2.9.3.0</a>. </li>
+ <li> The current released version of skalibs is <a href="skalibs-2.9.4.0.tar.gz">2.9.4.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs
git repository</a>:
diff --git a/doc/libstddjb/djbunix.html b/doc/libstddjb/djbunix.html
index 2e99dd0..0ac0a2c 100644
--- a/doc/libstddjb/djbunix.html
+++ b/doc/libstddjb/djbunix.html
@@ -254,12 +254,24 @@ Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int open_readcoe (char const *file) </code> <br />
+Opens <em>file</em> in read-only, non-blocking mode, close-on-exec.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int openb_read (char const *file) </code> <br />
Opens <em>file</em> in read-only, blocking mode.
Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int openb_readcoe (char const *file) </code> <br />
+Opens <em>file</em> in read-only, blocking mode, close-on-exec.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int open_readb (char const *file) </code> <br />
Opens <em>file</em> in read-only, blocking mode.
Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
@@ -271,6 +283,11 @@ with FIFOs.
</p>
<p>
+<code> int open_readbcoe (char const *file) </code> <br />
+Same as above, but the file is opened close-on-exec.
+</p>
+
+<p>
<code> int open_excl (char const *file) </code> <br />
Opens <em>file</em> in write-only, non-blocking mode, with the
additional O_EXCL and O_CREAT flags.
@@ -278,6 +295,13 @@ Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int open_exclcoe (char const *file) </code> <br />
+Opens <em>file</em> in write-only, non-blocking mode, close-on-exec, with the
+additional O_EXCL and O_CREAT flags.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int open_append (char const *file) </code> <br />
Opens <em>file</em> in write-only, non-blocking mode, with the
additional O_APPEND and O_CREAT flags.
@@ -285,6 +309,13 @@ Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int open_appendcoe (char const *file) </code> <br />
+Opens <em>file</em> in write-only, non-blocking mode, close-on-exec, with the
+additional O_APPEND and O_CREAT flags.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int open_trunc (char const *file) </code> <br />
Opens <em>file</em> in write-only, non-blocking mode, with the
additional O_TRUNC and O_CREAT flags.
@@ -292,6 +323,13 @@ Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int open_trunccoe (char const *file) </code> <br />
+Opens <em>file</em> in write-only, non-blocking mode, close-on-exec, with the
+additional O_TRUNC and O_CREAT flags.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int open_create (char const *file) </code> <br />
Opens <em>file</em> in write-only, non-blocking mode, with the
additional O_CREAT flag.
@@ -299,11 +337,24 @@ Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> int open_createcoe (char const *file) </code> <br />
+Opens <em>file</em> in write-only, non-blocking mode, close-on-exec, with the
+additional O_CREAT flag.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
+<p>
<code> int open_write (char const *file) </code> <br />
Opens <em>file</em> in write-only, non-blocking mode.
Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
</p>
+<p>
+<code> int open_writecoe (char const *file) </code> <br />
+Opens <em>file</em> in write-only, non-blocking mode, close-on-exec.
+Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.
+</p>
+
<h3> Executable search and execution, and environment </h3>
<p>
diff --git a/doc/license.html b/doc/license.html
index 27bbf9f..9aae77e 100644
--- a/doc/license.html
+++ b/doc/license.html
@@ -74,7 +74,7 @@ color, or different text font. </li>
<p>
<em>I am aware that the previous restrictions sound completely
ridiculous while the official skalibs documentation is incomplete.
-As of 2.9.3.0, I'm not going to enforce those restrictions, but if you're
+As of 2.9.4.0, I'm not going to enforce those restrictions, but if you're
going to provide documentation for skalibs, don't keep it to yourself,
please send it to me instead. :-) </em>
</p>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index e59df35..0f1aee8 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -16,6 +16,13 @@
<a href="//skarnet.org/">skarnet.org</a>
</p>
+<h2> in 2.9.4.0 </h2>
+
+<ul>
+ <li> New <tt>open*coe</tt> functions, which are O_CLOEXEC versions of the
+<a href="libstddjb/djbunix.html">djbunix.h</a> functions without <tt>coe</tt>. </li>
+</ul>
+
<h2> in 2.9.3.0 </h2>
<ul>
diff --git a/package/info b/package/info
index dc93a07..5d41757 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=skalibs
-version=2.9.3.0
+version=2.9.4.0
category=prog
package_macro_name=SKALIBS
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
index fe8c2f9..2a6fdd4 100644
--- a/src/include/skalibs/djbunix.h
+++ b/src/include/skalibs/djbunix.h
@@ -43,13 +43,21 @@ extern void lock_unx (int) ;
extern int open2 (char const *, unsigned int) ;
extern int open3 (char const *, unsigned int, unsigned int) ;
extern int open_read (char const *) ;
+extern int open_readcoe (char const *) ;
extern int openb_read (char const *) ;
+extern int openb_readcoe (char const *) ;
extern int open_readb (char const *) ;
+extern int open_readbcoe (char const *) ;
extern int open_excl (char const *) ;
+extern int open_exclcoe (char const *) ;
extern int open_append (char const *) ;
+extern int open_appendcoe (char const *) ;
extern int open_create (char const *) ;
+extern int open_createcoe (char const *) ;
extern int open_trunc (char const *) ;
+extern int open_trunccoe (char const *) ;
extern int open_write (char const *) ;
+extern int open_writecoe (char const *) ;
extern int socket_internal (int, int, int, unsigned int) ;
extern int socketpair_internal (int, int, int, unsigned int, int *) ;
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))
{