From c005b541bf9d54327ff860aad88367b854bae3d8 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 9 Jun 2023 13:32:27 +0000 Subject: Add devino, refactor openwrite(v)nclose Signed-off-by: Laurent Bercot --- src/include/skalibs/devino.h | 18 ++++++++++++++ src/include/skalibs/djbunix.h | 57 +++++++++++++++++++++++++------------------ src/include/skalibs/stddjb.h | 1 + 3 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 src/include/skalibs/devino.h (limited to 'src/include') diff --git a/src/include/skalibs/devino.h b/src/include/skalibs/devino.h new file mode 100644 index 0000000..b4feaf3 --- /dev/null +++ b/src/include/skalibs/devino.h @@ -0,0 +1,18 @@ +/* ISC license. */ + +#ifndef SKALIBS_DEVINO_H +#define SKALIBS_DEVINO_H + +#include + +typedef struct devino_s devino, *devino_ref ; +struct devino_s +{ + dev_t dev ; + ino_t ino ; +} ; +#define DEVINO_ZERO { .dev = 0, .ino = 0 } + +extern int devino_cmp (void const *, void const *) ; + +#endif diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 2d2057a..b89a868 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -10,6 +10,7 @@ #include #include +#include extern int coe (int) ; extern int uncoe (int) ; @@ -97,53 +98,61 @@ extern ssize_t openreadnclose (char const *, char *, size_t) ; extern ssize_t openreadnclose_nb (char const *, char *, size_t) ; extern int openreadfileclose (char const *, stralloc *, size_t) ; -#define writenclose_unsafe(fd, s, n) writenclose_unsafe_internal(fd, s, (n), 0, 0, 0) -#define writenclose_unsafe_sync(fd, s, n) writenclose_unsafe_internal(fd, s, (n), 0, 0, 1) +#define writenclose_unsafe(fd, s, n) writenclose_unsafe5(fd, s, (n), 0) +#define writenclose_unsafe_sync(fd, s, n) writenclose_unsafe5(fd, s, (n), 0, 1) #define writenclose_unsafe_devino(fd, s, n, dev, ino) writenclose_unsafe_internal(fd, s, n, dev, (ino), 0) #define writenclose_unsafe_devino_sync(fd, s, n, dev, ino) writenclose_unsafe_internal(fd, s, n, dev, (ino), 1) -extern int writenclose_unsafe_internal (int, char const *, size_t, dev_t *, ino_t *, int) ; +extern int writenclose_unsafe5 (int, char const *, size_t, devino *, unsigned int) ; +extern int writenclose_unsafe_internal (int, char const *, size_t, dev_t *, ino_t *, int) gccattr_deprecated ; -#define openwritenclose_unsafe(f, s, n) openwritenclose_unsafe_internal(f, s, (n), 0, 0, 0) -#define openwritenclose_unsafe_sync(f, s, n) openwritenclose_unsafe_internal(f, s, (n), 0, 0, 1) +#define openwritenclose_unsafe(f, s, n) openwritenclose_unsafe5(f, s, (n), 0, 0) +#define openwritenclose_unsafe_sync(f, s, n) openwritenclose_unsafe5(f, s, (n), 0, 1) #define openwritenclose_unsafe_devino(f, s, n, dev, ino) openwritenclose_unsafe_internal(f, s, n, dev, (ino), 0) #define openwritenclose_unsafe_devino_sync(f, s, n, dev, ino) openwritenclose_unsafe_internal(f, s, n, dev, (ino), 1) -extern int openwritenclose_unsafe_internal (char const *, char const *, size_t, dev_t *, ino_t *, int) ; +extern int openwritenclose_unsafe5 (char const *, char const *, size_t, devino *, unsigned int) ; +extern int openwritenclose_unsafe_internal (char const *, char const *, size_t, dev_t *, ino_t *, int) gccattr_deprecated ; -#define openwritenclose_suffix(f, s, n, t) openwritenclose_suffix_internal(f, s, n, 0, 0, 0, t) -#define openwritenclose_suffix_sync(f, s, n, t) openwritenclose_suffix_internal(f, s, n, 0, 0, 1, t) +#define openwritenclose_suffix(f, s, n, t) openwritenclose_suffix6(f, s, n, 0, 0, 0, t) +#define openwritenclose_suffix_sync(f, s, n, t) openwritenclose_suffix6(f, s, n, 0, 0, 1, t) #define openwritenclose_suffix_devino(f, s, n, t, dev, ino) openwritenclose_suffix_internal(f, s, n, dev, (ino), 0, t) #define openwritenclose_suffix_devino_sync(f, s, n, t, dev, ino) openwritenclose_suffix_internal(f, s, n, dev, (ino), 1, t) -extern int openwritenclose_suffix_internal (char const *, char const *, size_t, dev_t *, ino_t *, int, char const *) ; +extern int openwritenclose_suffix6 (char const *, char const *, size_t, devino *, unsigned int, char const *) ; +extern int openwritenclose_suffix_internal (char const *, char const *, size_t, dev_t *, ino_t *, int, char const *) gccattr_deprecated ; -#define openwritenclose(f, s, n) openwritenclose_internal(f, s, (n), 0, 0, 0) -#define openwritenclose_sync(f, s, n) openwritenclose_internal(f, s, (n), 0, 0, 1) +#define openwritenclose(f, s, n) openwritenclose5(f, s, (n), 0, 0) +#define openwritenclose_sync(f, s, n) openwritenclose5(f, s, (n), 0, 1) #define openwritenclose_devino(f, s, n, dev, ino) openwritenclose_internal(f, s, n, dev, (ino), 0) #define openwritenclose_devino_sync(f, s, n, dev, ino) openwritenclose_internal(f, s, n, dev, (ino), 1) -extern int openwritenclose_internal (char const *, char const *, size_t, dev_t *, ino_t *, int) ; +extern int openwritenclose5 (char const *, char const *, size_t, devino *, unsigned int) ; +extern int openwritenclose_internal (char const *, char const *, size_t, dev_t *, ino_t *, int) gccattr_deprecated ; -#define writenvclose_unsafe(fd, v, n) writevnclose_unsafe_internal(fd, v, (n), 0, 0, 0) -#define writevnclose_unsafe_sync(fd, v, n) writevnclose_unsafe_internal(fd, v, (n), 0, 0, 1) +#define writenvclose_unsafe(fd, v, n) writevnclose_unsafe5(fd, v, (n), 0, 0) +#define writevnclose_unsafe_sync(fd, v, n) writevnclose_unsafe5(fd, v, (n), 0, 1) #define writevnclose_unsafe_devino(fd, v, n, dev, ino) writevnclose_unsafe_internal(fd, v, n, dev, (ino), 0) #define writevnclose_unsafe_devino_sync(fd, v, n, dev, ino) writevnclose_unsafe_internal(fd, v, n, dev, (ino), 1) -extern int writevnclose_unsafe_internal (int, struct iovec const *, unsigned int, dev_t *, ino_t *, int) ; +extern int writevnclose_unsafe5 (int, struct iovec const *, unsigned int, devino *, unsigned int) ; +extern int writevnclose_unsafe_internal (int, struct iovec const *, unsigned int, dev_t *, ino_t *, int) gccattr_deprecated ; -#define openwritevnclose_unsafe(f, v, n) openwritevnclose_unsafe_internal(f, v, (n), 0, 0, 0) -#define openwritevnclose_unsafe_sync(f, v, n) openwritevnclose_unsafe_internal(f, v, (n), 0, 0, 1) +#define openwritevnclose_unsafe(f, v, n) openwritevnclose_unsafe5(f, v, (n), 0, 0) +#define openwritevnclose_unsafe_sync(f, v, n) openwritevnclose_unsafe5(f, v, (n), 0, 1) #define openwritevnclose_unsafe_devino(f, v, n, dev, ino) openwritevnclose_unsafe_internal(f, v, n, dev, (ino), 0) #define openwritevnclose_unsafe_devino_sync(f, v, n, dev, ino) openwritevnclose_unsafe_internal(f, v, n, dev, (ino), 1) -extern int openwritevnclose_unsafe_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int) ; +extern int openwritevnclose_unsafe5 (char const *, struct iovec const *, unsigned int, devino *, unsigned int) ; +extern int openwritevnclose_unsafe_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int) gccattr_deprecated ; -#define openwritevnclose_suffix(f, v, n, t) openwritevnclose_suffix_internal(f, v, n, 0, 0, 0, t) -#define openwritevnclose_suffix_sync(f, v, n, t) openwritevnclose_suffix_internal(f, v, n, 0, 0, 1, t) +#define openwritevnclose_suffix(f, v, n, t) openwritevnclose_suffix6(f, v, n, 0, 0, t) +#define openwritevnclose_suffix_sync(f, v, n, t) openwritevnclose_suffix6(f, v, n, 0, 1, t) #define openwritevnclose_suffix_devino(f, v, n, t, dev, ino) openwritevnclose_suffix_internal(f, v, n, dev, (ino), 0, t) #define openwritevnclose_suffix_devino_sync(f, v, n, t, dev, ino) openwritevnclose_suffix_internal(f, v, n, dev, (ino), 1, t) -extern int openwritevnclose_suffix_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int, char const *) ; +extern int openwritevnclose_suffix6 (char const *, struct iovec const *, unsigned int, devino *, unsigned int, char const *) ; +extern int openwritevnclose_suffix_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int, char const *) gccattr_deprecated ; -#define openwritevnclose(f, v, n) openwritevnclose_internal(f, v, (n), 0, 0, 0) -#define openwritevnclose_sync(f, v, n) openwritevnclose_internal(f, v, (n), 0, 0, 1) +#define openwritevnclose(f, v, n) openwritevnclose5(f, v, (n), 0, 0) +#define openwritevnclose_sync(f, v, n) openwritevnclose5(f, v, (n), 0, 1) #define openwritevnclose_devino(f, v, n, dev, ino) openwritevnclose_internal(f, v, n, dev, (ino), 0) #define openwritevnclose_devino_sync(f, v, n, dev, ino) openwritevnclose_internal(f, v, n, dev, (ino), 1) -extern int openwritevnclose_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int) ; +extern int openwritevnclose5 (char const *, struct iovec const *, unsigned int, devino *, unsigned int) ; +extern int openwritevnclose_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int) gccattr_deprecated ; extern int rm_rf (char const *) ; extern int rm_rf_tmp (char const *, stralloc *) ; diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index e044895..3ba1a51 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3