diff options
Diffstat (limited to 'geo-replication/src')
-rw-r--r-- | geo-replication/src/gsyncd.c | 12 | ||||
-rw-r--r-- | geo-replication/src/procdiggy.c | 9 |
2 files changed, 12 insertions, 9 deletions
diff --git a/geo-replication/src/gsyncd.c b/geo-replication/src/gsyncd.c index c9c863ca2fd..1beeda1380c 100644 --- a/geo-replication/src/gsyncd.c +++ b/geo-replication/src/gsyncd.c @@ -7,6 +7,8 @@ later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ +#include "compat.h" +#include "syscall.h" #include <stdlib.h> #include <stdio.h> @@ -189,12 +191,12 @@ find_gsyncd (pid_t pid, pid_t ppid, char *name, void *data) if (ppid != pida[0]) return 0; - sprintf (path, PROC"/%d/cmdline", pid); + snprintf (path, sizeof path, PROC"/%d/cmdline", pid); fd = open (path, O_RDONLY); if (fd == -1) return 0; - ret = read (fd, buf, sizeof (buf)); - close (fd); + ret = sys_read (fd, buf, sizeof (buf)); + sys_close (fd); if (ret == -1) return 0; for (zeros = 0, p = buf; zeros < 2 && p < buf + ret; p++) @@ -270,8 +272,8 @@ invoke_rsync (int argc, char **argv) goto error; } /* check if rsync target matches gsyncd target */ - sprintf (path, PROC"/%d/cwd", pida[1]); - ret = readlink (path, buf, sizeof (buf)); + snprintf (path, sizeof path, PROC"/%d/cwd", pida[1]); + ret = sys_readlink (path, buf, sizeof (buf)); if (ret == -1 || ret == sizeof (buf)) goto error; if (strcmp (argv[argc - 1], "/") == 0 /* root dir cannot be a target */ || diff --git a/geo-replication/src/procdiggy.c b/geo-replication/src/procdiggy.c index d9253bbb89e..1ea52c1a6a1 100644 --- a/geo-replication/src/procdiggy.c +++ b/geo-replication/src/procdiggy.c @@ -16,6 +16,7 @@ #include <sys/param.h> /* for PATH_MAX */ #include "common-utils.h" +#include "syscall.h" #include "procdiggy.h" pid_t @@ -27,7 +28,7 @@ pidinfo (pid_t pid, char **name) char *p = NULL; int ret = 0; - sprintf (path, PROC"/%d/status", pid); + snprintf (path, sizeof path, PROC"/%d/status", pid); f = fopen (path, "r"); if (!f) @@ -89,10 +90,10 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data), pid_t ppid = -1; int ret = 0; - d = opendir (PROC); + d = sys_opendir (PROC); if (!d) return -1; - while (errno = 0, de = readdir (d)) { + while (errno = 0, de = sys_readdir (d)) { if (gf_string2int (de->d_name, &pid) != -1 && pid >= 0) { ppid = pidinfo (pid, &name); switch (ppid) { @@ -105,7 +106,7 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data), break; } } - closedir (d); + sys_closedir (d); if (!de && errno) { fprintf (stderr, "failed to traverse "PROC" (%s)\n", strerror (errno)); |