mirror of
https://github.com/upa/mscp.git
synced 2026-02-28 03:24:41 +08:00
checkpoint includes username
This commit is contained in:
@@ -126,16 +126,17 @@ static int checkpoint_write_chunk(int fd, struct chunk *c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int checkpoint_save(const char *pathname, int dir, char *remote, pool *path_pool,
|
int checkpoint_save(const char *pathname, int dir, const char *user, const char *remote,
|
||||||
pool *chunk_pool)
|
pool *path_pool, pool *chunk_pool)
|
||||||
{
|
{
|
||||||
struct checkpoint_file_hdr hdr;
|
struct checkpoint_file_hdr hdr;
|
||||||
struct checkpoint_obj_meta meta;
|
struct checkpoint_obj_meta meta;
|
||||||
struct iovec iov[3];
|
struct iovec iov[3];
|
||||||
struct chunk *c;
|
struct chunk *c;
|
||||||
struct path *p;
|
struct path *p;
|
||||||
|
char buf[1024];
|
||||||
unsigned int i, nr_paths, nr_chunks;
|
unsigned int i, nr_paths, nr_chunks;
|
||||||
int fd;
|
int fd, ret;
|
||||||
|
|
||||||
fd = open(pathname, O_WRONLY | O_CREAT | O_TRUNC,
|
fd = open(pathname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
|
||||||
@@ -149,17 +150,26 @@ int checkpoint_save(const char *pathname, int dir, char *remote, pool *path_pool
|
|||||||
hdr.version = MSCP_CHECKPOINT_VERSION;
|
hdr.version = MSCP_CHECKPOINT_VERSION;
|
||||||
|
|
||||||
/* write meta */
|
/* write meta */
|
||||||
|
if (user)
|
||||||
|
ret = snprintf(buf, sizeof(buf), "%s@%s", user, remote);
|
||||||
|
else
|
||||||
|
ret = snprintf(buf, sizeof(buf), "%s", remote);
|
||||||
|
if (ret >= sizeof(buf)) {
|
||||||
|
priv_set_errv("too long username and/or remote");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&meta, 0, sizeof(meta));
|
memset(&meta, 0, sizeof(meta));
|
||||||
meta.hdr.type = OBJ_TYPE_META;
|
meta.hdr.type = OBJ_TYPE_META;
|
||||||
meta.hdr.len = htons(sizeof(meta) + strlen(remote) + 1);
|
meta.hdr.len = htons(sizeof(meta) + strlen(buf) + 1);
|
||||||
meta.direction = dir;
|
meta.direction = dir;
|
||||||
|
|
||||||
iov[0].iov_base = &hdr;
|
iov[0].iov_base = &hdr;
|
||||||
iov[0].iov_len = sizeof(hdr);
|
iov[0].iov_len = sizeof(hdr);
|
||||||
iov[1].iov_base = &meta;
|
iov[1].iov_base = &meta;
|
||||||
iov[1].iov_len = sizeof(meta);
|
iov[1].iov_len = sizeof(meta);
|
||||||
iov[2].iov_base = remote;
|
iov[2].iov_base = buf;
|
||||||
iov[2].iov_len = strlen(remote) + 1;
|
iov[2].iov_len = strlen(buf) + 1;
|
||||||
|
|
||||||
if (writev(fd, iov, 3) < 0) {
|
if (writev(fd, iov, 3) < 0) {
|
||||||
priv_set_errv("writev: %s", strerrno());
|
priv_set_errv("writev: %s", strerrno());
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <pool.h>
|
#include <pool.h>
|
||||||
|
|
||||||
/* checkpoint_save() stores states to a checkponint file (pathname) */
|
/* checkpoint_save() stores states to a checkponint file (pathname) */
|
||||||
int checkpoint_save(const char *pathname, int dir, char *remote_host, pool *path_pool,
|
int checkpoint_save(const char *pathname, int dir, const char *user, const char *remote,
|
||||||
pool *chunk_pool);
|
pool *path_pool, pool *chunk_pool);
|
||||||
|
|
||||||
/* checkpoint_load_meta() reads a checkpoint file (pathname) and returns
|
/* checkpoint_load_meta() reads a checkpoint file (pathname) and returns
|
||||||
* remote host string to *remote and transfer direction to *dir.
|
* remote host string to *remote and transfer direction to *dir.
|
||||||
|
|||||||
@@ -522,8 +522,8 @@ int mscp_checkpoint_load(struct mscp *m, const char *pathname)
|
|||||||
|
|
||||||
int mscp_checkpoint_save(struct mscp *m, const char *pathname)
|
int mscp_checkpoint_save(struct mscp *m, const char *pathname)
|
||||||
{
|
{
|
||||||
return checkpoint_save(pathname, m->direction, m->remote, m->path_pool,
|
return checkpoint_save(pathname, m->direction, m->ssh_opts->login_name,
|
||||||
m->chunk_pool);
|
m->remote, m->path_pool, m->chunk_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mscp_copy_thread(void *arg);
|
static void *mscp_copy_thread(void *arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user