skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 032b853746aabb8c3b82af674fdc783b511569f2
parent 450e114e1e1651c65dfcdbfa3c6f3967163976b3
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sat,  4 Dec 2021 08:48:45 +0000

 Add opendir_at, prepare for 2.11.1.0

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
MNEWS | 8++++++++
Mdoc/index.html | 2+-
Mdoc/upgrade.html | 15+++++++++++++++
Mpackage/deps.mak | 3++-
Mpackage/info | 2+-
Msrc/include/skalibs/unix-transactional.h | 2++
Msrc/libstddjb/fd_close.c | 4++--
Asrc/libunixonacid/opendir_at.c | 15+++++++++++++++
8 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS @@ -1,5 +1,13 @@ Changelog for skalibs. +In 2.11.1.0 +----------- + + - fd_close() doesn't retry if close() fails. (i.e. adapts to Linux's +behaviour over HP-UX's.) + - New function: opendir_at. + + In 2.11.0.0 ----------- diff --git 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.11.0.0.tar.gz">2.11.0.0</a>. </li> + <li> The current released version of skalibs is <a href="skalibs-2.11.1.0.tar.gz">2.11.1.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/upgrade.html b/doc/upgrade.html @@ -16,6 +16,21 @@ <a href="//skarnet.org/">skarnet.org</a> </p> +<h2> in 2.11.1.0 </h2> + +<ul> + <li> <tt>fd_close()</tt> now chooses to adapt to Linux's +<a href="https://man7.org/linux/man-pages/man2/close.2.html">close()</a> +behaviour (closing the fd on EINTR) over the HP-UX one (not closing it). +Destructors like +<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html">close()</a> +being allowed to fail has always been a mistake in the specification and a +programming nightmare, making it impossible to behave correctly on all +systems, but apparently standardization efforts are on the way and the Linux +behaviour seems to be the chosen one. </li> + <li> New <tt>unix-transactional.h</tt> function: <tt>opendir_at</tt>. </li> +</ul> + <h2> in 2.11.0.0 </h2> <ul> diff --git a/package/deps.mak b/package/deps.mak @@ -51,7 +51,7 @@ src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skali src/include/skalibs/textclient.h: src/include/skalibs/allreadwrite.h src/include/skalibs/tai.h src/include/skalibs/textmessage.h src/include/skalibs/textmessage.h: src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h -src/include/skalibs/unix-transactional.h: src/include/skalibs/stralloc.h src/include/skalibs/uint64.h +src/include/skalibs/unix-transactional.h: src/include/skalibs/direntry.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h src/include/skalibs/unixmessage.h: src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unixonacid.h: src/include/skalibs/ancil.h src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h @@ -716,6 +716,7 @@ src/libunixonacid/open_truncat.o src/libunixonacid/open_truncat.lo: src/libunixo src/libunixonacid/open_truncatb.o src/libunixonacid/open_truncatb.lo: src/libunixonacid/open_truncatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/open_writeat.o src/libunixonacid/open_writeat.lo: src/libunixonacid/open_writeat.c src/include/skalibs/unix-transactional.h src/libunixonacid/open_writeatb.o src/libunixonacid/open_writeatb.lo: src/libunixonacid/open_writeatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h +src/libunixonacid/opendir_at.o src/libunixonacid/opendir_at.lo: src/libunixonacid/opendir_at.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose.o src/libunixonacid/opengetlnclose.lo: src/libunixonacid/opengetlnclose.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose_at.o src/libunixonacid/opengetlnclose_at.lo: src/libunixonacid/opengetlnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/openreadnclose_at.o src/libunixonacid/openreadnclose_at.lo: src/libunixonacid/openreadnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h diff --git a/package/info b/package/info @@ -1,4 +1,4 @@ package=skalibs -version=2.11.0.0 +version=2.11.1.0 category=prog package_macro_name=SKALIBS diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h @@ -8,6 +8,7 @@ #include <sys/uio.h> #include <skalibs/uint64.h> +#include <skalibs/direntry.h> #include <skalibs/stralloc.h> /* Transactional/reliable filesystem operations */ @@ -26,6 +27,7 @@ extern int open_truncat (int, char const *) ; extern int open_truncatb (int, char const *) ; extern int open_appendat (int, char const *) ; extern int open_appendatb (int, char const *) ; +extern DIR *opendir_at (int, char const *) ; extern int stat_at (int, char const *, struct stat *) ; extern int lstat_at (int, char const *, struct stat *) ; diff --git a/src/libstddjb/fd_close.c b/src/libstddjb/fd_close.c @@ -1,12 +1,12 @@ /* ISC license. */ -#include <unistd.h> #include <errno.h> +#include <unistd.h> #include <skalibs/djbunix.h> void fd_close (int fd) { int e = errno ; - while (close(fd) < 0 && errno == EINTR) ; + close(fd) ; errno = e ; } diff --git a/src/libunixonacid/opendir_at.c b/src/libunixonacid/opendir_at.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <skalibs/direntry.h> +#include <skalibs/djbunix.h> +#include <skalibs/unix-transactional.h> + +DIR *opendir_at (int dfd, char const *name) +{ + DIR *dir ; + int fd = open_readatb(dfd, name) ; + if (fd < 0) return 0 ; + dir = fdopendir(fd) ; + if (!dir) fd_close(fd) ; + return dir ; +}