#include <libcfs/util/string.h>
#include <lustre/lustreapi.h>
#include "lustre_rsync.h"
+#include "callvpe.h"
#define REPLICATE_STATUS_VER 1
#define CLEAR_INTERVAL 100
char savedpath[PATH_MAX + 1];
char link[PATH_MAX + 1];
char linktmp[PATH_MAX + 1];
- char cmd[PATH_MAX * 10];
int bufsize;
char *buf;
if (st_src.st_mtime != st_dest.st_mtime ||
st_src.st_size != st_dest.st_size) {
- /* XXX spawning off an rsync for every data sync and
- * waiting synchronously is bad for performance.
- * librsync could possibly used here. But it does not
- * seem to be of production grade. Multi-threaded
- * replication is also to be considered.
- */
- int status;
-
- if (snprintf(info->cmd, sizeof(info->cmd), "%s --inplace %s %s",
- rsync, info->src, info->dest) >= sizeof(info->cmd)) {
- rc = -E2BIG;
- goto err;
- }
- lr_debug(DTRACE, "\t%s %s\n", info->cmd, info->tfid);
- status = system(info->cmd);
- if (status == -1) {
+ /* XXX spawning off an rsync for every data sync and
+ * waiting synchronously is bad for performance.
+ * librsync could possibly used here. But it does not
+ * seem to be of production grade. Multi-threaded
+ * replication is also to be considered.
+ */
+ char *args[] = {
+ rsync,
+ "--inplace",
+ "--",
+ info->src,
+ info->dest,
+ NULL,
+ };
+ extern char **environ;
+ int status;
+
+ lr_debug(DTRACE, "\t%s %s %s %s %s %s\n", args[0], args[1],
+ args[2], args[3], args[4], info->tfid);
+
+ status = callvpe(rsync, args, environ);
+ if (status < 0) {
rc = -errno;
} else if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
lr_debug(DTRACE, "Not syncing %s and %s %s\n", info->src,
info->dest, info->tfid);
}
-err:
+
return rc;
}
/* Recursively remove directory and its contents */
int lr_rm_recursive(struct lr_info *info)
{
+ char *args[] = {
+ "rm",
+ "-rf",
+ "--",
+ info->dest,
+ NULL,
+ };
+ extern char **environ;
+ int status;
int rc;
- snprintf(info->cmd, sizeof(info->cmd), "rm -rf %s",
- info->dest);
- rc = system(info->cmd);
- if (rc == -1)
- rc = -errno;
+ status = callvpe("/bin/rm", args, environ);
+ if (status < 0)
+ rc = -errno;
+ else if (WIFEXITED(status))
+ rc = WEXITSTATUS(status) == 0 ? 0 : -EINVAL;
+ else
+ rc = -EINTR;
- return rc;
+ return rc;
}
/* Remove a file under SPECIAL_DIR with its tfid as its name. */
}
rc = llapi_changelog_set_xflags(changelog_priv,
- CHANGELOG_EXTRA_FLAG_UIDGID);
+ CHANGELOG_EXTRA_FLAG_UIDGID |
+ CHANGELOG_EXTRA_FLAG_NID |
+ CHANGELOG_EXTRA_FLAG_OMODE);
if (rc < 0) {
fprintf(stderr, "Error setting xflag in changelog for fs %s.\n",
status->ls_source_fs);