diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-09-27 20:16:01 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-09-27 20:16:01 +0000 |
commit | c365aeb0721d3749bb5f94f09a3ad97ec6131805 (patch) | |
tree | 0a63fa2d7c499b6e835d5665438f1f67cd7db494 /src/include | |
parent | 1728f7ed8e96a03dd6a75c9668d394562ed63a59 (diff) | |
download | skalibs-c365aeb0721d3749bb5f94f09a3ad97ec6131805.tar.xz |
Rewrite openwrite(v)nclose using mkstemp
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/skalibs/djbunix.h | 24 | ||||
-rw-r--r-- | src/include/skalibs/unix-transactional.h | 4 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 757852c..f4cac8a 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -107,6 +107,12 @@ 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_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) ; + #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_devino(f, s, n, dev, ino) openwritenclose_unsafe_internal(f, s, n, dev, (ino), 0) @@ -119,6 +125,18 @@ extern int openwritenclose_unsafe_internal (char const *, char const *, size_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 *) ; +#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_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) ; + +#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 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) ; + #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_devino(f, v, n, dev, ino) openwritevnclose_unsafe_internal(f, v, n, dev, (ino), 0) @@ -131,6 +149,12 @@ extern int openwritevnclose_unsafe_internal (char const *, struct iovec const *, #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 *) ; +#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_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 rm_rf (char const *) ; extern int rm_rf_tmp (char const *, stralloc *) ; extern int rm_rf_in_tmp (stralloc *, size_t) ; /* caution ! */ diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h index a2f56e8..5f1dd90 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -32,10 +32,6 @@ extern size_t openreadnclose_at (int, char const *, char *, size_t) ; extern int openslurpclose_at (int, char const *, stralloc *) ; extern int opengetlnclose_at (int, char const *, stralloc *, int) ; -extern int openwritenclose (char const *, char const *, size_t) ; -extern int openwritenclose_devino (char const *, char const *, size_t, dev_t *, ino_t *) ; -extern int openwritenclose_tmp (char const *, char const *, size_t, stralloc *) ; -extern int openwritenclose_devino_tmp (char const *, char const *, size_t, dev_t *, ino_t *, stralloc *) ; extern size_t openwritenclose_at (int, char const *, char const *, size_t) ; extern size_t openwritevnclose_at (int, char const *, struct iovec const *, unsigned int) ; |