From 04905aaeffba2bc77866a4056dc3f2020a86bb26 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
- int fd_chown (int fd, unsigned int uid, unsigned int gid)
+ int fd_chown (int fd, uid_t uid, gid_t gid)
Safe wrapper around
fchown().
This function requires root privileges.
@@ -177,7 +177,7 @@ in Linux 2.6.17 and later
- unsigned int fd_catn (int from, int to, unsigned int n)
+ size_t fd_catn (int from, int to, size_t n)
Synchronously copies at most n bytes from fd from to fd to.
Returns the total number of transmitted bytes; sets errno if this number
is lesser than n. EOF is reported as EPIPE. See above for zero-copy
@@ -319,16 +319,6 @@ group database. This is a privileged operation.
Returns -1 and sets errno if it fails; returns 0 if it succeeds.
- int prot_gid (int gid)
-Alias to setgid.
-
- int prot_uid (int uid)
-Alias to setuid.
-
@@ -382,7 +372,7 @@ simply exiting 0.
- void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen)
+ void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
Alters envp (which does not have to be NULL-terminated, but the
number envlen of elements must be provided) with the modifier
string modifs of length modiflen, then performs
@@ -390,7 +380,7 @@ string modifs of length modiflen, then performs
- void pathexec_r (char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen)
+ void pathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
Same as pathexec_r_name, except that the file argument is read from argv[0].
- void pathexec_fromenv (char const *const *argv, char const *const *envp, unsigned int envlen)
+ void pathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen)
Performs pathexec_r() with the given arguments and the hidden modifier
string.
- int doublefork ()
+ pid_t doublefork ()
Performs a double fork. Returns -1 if it fails (and
sets errno, EINTR meaning that the intermediate process
was killed by a signal), 0 if the current process is the grandchild,
@@ -512,7 +502,7 @@ be unchanged.
- int wait_nohang (int *wstat)
+ pid_t wait_nohang (int *wstat)
Instantly reaps one zombie, and stores the status information into
*wstat.
Returns the PID of the reaped zombie if it succeeds, 0 if there was
@@ -522,13 +512,13 @@ or -1 (and sets errno) if it fails.
- int waitpid_nointr (pid_t pid, int *wstat, int flags)
+ pid_t waitpid_nointr (pid_t pid, int *wstat, int flags)
Safe wrapper around
waitpid().
- int wait_pid_nohang (pid_t pid, int *wstat)
+ pid_t wait_pid_nohang (pid_t pid, int *wstat)
Instantly reaps an undetermined number of zombies until it finds pid.
Stores the status information for dead pid into *wstat.
Returns pid if it succeeds, 0 if there was
@@ -587,33 +577,27 @@ Returns 1 if it succeeds, and 0 (and sets errno) if it fails.
- int openreadclose (char const *file, stralloc *sa, unsigned int dummy)
-Legacy interface for openslurpclose(sa, file)
. The dummy
-argument is unused. Returns 0 if it succeeds, and -1 (and sets errno) if it fails.
-
- int openreadnclose (char const *file, char *s, unsigned int n)
+ ssize_t openreadnclose (char const *file, char *s, size_t n)
Reads at most n bytes from file file into preallocated
buffer s. Returns -1 (and sets errno) if it fails; else returns the
number of read bytes. If that number is not n, errno is set to EPIPE.
- int openreadnclose_nb (char const *file, char *s, unsigned int n)
+ ssize_t openreadnclose_nb (char const *file, char *s, size_t n)
Like openreadnclose, but can fail with EAGAIN if the file cannot be
immediately read (for instance if it's a named pipe or other special file).
- int openreadfileclose (char const *file, stralloc *sa, unsigned int n)
+ int openreadfileclose (char const *file, stralloc *sa, size_t n)
Reads at most n bytes from file file into the *sa
stralloc, which is grown (if needed) to just accommodate the file
size. Returns 1 if it succeeds and 0 (and sets errno) if it fails.
- int openwritenclose_unsafe_internal (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, unsigned char dosync)
+ int openwritenclose_unsafe_internal (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, int dosync)
Writes the n bytes stored at s into file file.
The previous contents of file are destroyed even if the function
fails. If dosync is nonzero, the new contents of file
@@ -623,16 +607,16 @@ The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.
- int openwritenclose_unsafe (char const *file, char const *s, unsigned int len)
-int openwritenclose_unsafe_sync (char const *file, char const *s, unsigned int len)
-int openwritenclose_unsafe_devino (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino)
-int openwritenclose_unsafe_devino_sync (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino)
+ int openwritenclose_unsafe (char const *file, char const *s, size_t len)
+int openwritenclose_unsafe_sync (char const *file, char const *s, size_t len)
+int openwritenclose_unsafe_devino (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino)
+int openwritenclose_unsafe_devino_sync (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino)
Trivial shortcuts around openwritenclose_unsafe_internal(). The
reader can easily figure out what they do.
- int openwritenclose_suffix_internal (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, unsigned char dosync, char const *suffix)
+ int openwritenclose_suffix_internal (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, int dosync, char const *suffix)
Writes the n bytes stored at s into file file,
by first writing into filesuffix and atomically renaming
filesuffix to file. IOW, the old contents of file
@@ -645,43 +629,43 @@ The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.
- int openwritenclose_suffix (char const *file, char const *s, unsigned int len, char const *suffix)
-int openwritenclose_suffix_sync (char const *file, char const *s, unsigned int len, char const *suffix)
-int openwritenclose_suffix_devino (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, char const *suffix)
-int openwritenclose_suffix_devino_sync (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, char const *suffix)
+ int openwritenclose_suffix (char const *file, char const *s, size_t len, char const *suffix)
+int openwritenclose_suffix_sync (char const *file, char const *s, size_t len, char const *suffix)
+int openwritenclose_suffix_devino (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, char const *suffix)
+int openwritenclose_suffix_devino_sync (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, char const *suffix)
Trivial shortcuts around openwritenclose_suffix_internal(). The
reader can easily figure out what they do.
- int openwritevnclose_unsafe_internal (char const *file, siovec_t const *v, unsigned int vlen, uint64 *dev, uint64 *ino, unsigned char dosync)
+ int openwritevnclose_unsafe_internal (char const *file, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino, int dosync)
Like openwritenclose_unsafe_internal, but the content to
write is taken from a
-siovec_t scatter/gather array of vlen
+scatter/gather array of vlen
elements instead of a single string.
- int openwritevnclose_unsafe (char const *file, siovec_t const *v, unsigned int vlen)
-int openwritevnclose_unsafe_sync (char const *file, siovec_t const *v, unsigned int vlen)
-int openwritevnclose_unsafe_devino (char const *file, siovec_t const *v, unsigned int vlen, uint64 *dev, uint64 *ino)
-int openwritevnclose_unsafe_devino_sync (char const *file, siovec_t const *v, unsigned int vlen, uint64 *dev, uint64 *ino)
+ int openwritevnclose_unsafe (char const *file, struct iovec const *v, unsigned int vlen)
+int openwritevnclose_unsafe_sync (char const *file, struct iovec const *v, unsigned int vlen)
+int openwritevnclose_unsafe_devino (char const *file, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino)
+int openwritevnclose_unsafe_devino_sync (char const *file, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino)
Trivial wrappers around openwritevnclose_unsafe_internal().
- int openwritevnclose_suffix_internal (char const *file, siovec_t const *v, unsigned int vlen, uint64 *dev, uint64 *ino, unsigned char dosync, char const *suffix)
+ int openwritevnclose_suffix_internal (char const *file, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino, int dosync, char const *suffix)
Like openwritenclose_suffix_internal, but the content to
write is taken from a
-siovec_t scatter/gather array of vlen
+scatter/gather array of vlen
elements instead of a single string.
- int openwritenclose_suffix (char const *file, char const *s, unsigned int len, char const *suffix)
-int openwritenclose_suffix_sync (char const *file, char const *s, unsigned int len, char const *suffix)
-int openwritenclose_suffix_devino (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, char const *suffix)
-int openwritenclose_suffix_devino_sync (char const *file, char const *s, unsigned int len, uint64 *dev, uint64 *ino, char const *suffix)
+ int openwritenclose_suffix (char const *file, char const *s, size_t len, char const *suffix)
+int openwritenclose_suffix_sync (char const *file, char const *s, size_t len, char const *suffix)
+int openwritenclose_suffix_devino (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, char const *suffix)
+int openwritenclose_suffix_devino_sync (char const *file, char const *s, size_t len, dev_t *dev, ino_t *ino, char const *suffix)
Trivial wrappers around openwritevnclose_suffix_internal().
- int rm_rf_in_tmp (stralloc *tmp, unsigned int n)
+ int rm_rf_in_tmp (stralloc *tmp, size_t n)
Deletes a filesystem subtree, using *tmp
as heap-allocated temporary space.
Returns 0 if it succeeds or -1 (and sets errno) if it fails.
@@ -763,14 +747,14 @@ Returns 0 if it succeeds and -1 (and sets errno) if it fails.
- int sabasename (stralloc *sa, char const *s, unsigned int len)
+ int sabasename (stralloc *sa, char const *s, size_t len)
Appends the basename of filename s (of length len)
to *sa.
Returns 1 if it succeeds and 0 (and sets errno) if it fails.
- int sadirname (stralloc *sa, char const *s, unsigned int len)
+ int sadirname (stralloc *sa, char const *s, size_t len)
Appends the dirname of filename s (of length len)
to *sa.
Returns 1 if it succeeds and 0 (and sets errno) if it fails.
--
cgit v1.2.3