mirror of
https://github.com/upa/mscp.git
synced 2026-02-14 09:14:47 +08:00
now mscp links libmscp
This commit is contained in:
19
src/path.h
19
src/path.h
@@ -98,14 +98,15 @@ static mdir *mscp_opendir(const char *path, sftp_session sftp)
|
||||
if (sftp) {
|
||||
d->r = sftp_opendir(sftp, path);
|
||||
if (!d->r) {
|
||||
pr_err("sftp_opendir: %s: %s\n", path, sftp_get_ssh_error(sftp));
|
||||
pr_err("sftp_opendir '%s': %s\n",
|
||||
path, sftp_get_ssh_error(sftp));
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
d->l = opendir(path);
|
||||
if (!d->l) {
|
||||
pr_err("opendir: %s: %s\n", path, strerrno());
|
||||
pr_err("opendir '%s': %s\n", path, strerrno());
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
@@ -227,7 +228,7 @@ struct mscp_file_handle {
|
||||
};
|
||||
typedef struct mscp_file_handle mfh;
|
||||
|
||||
static mfh mscp_open(const char *path, mode_t mode, int flags, size_t off,
|
||||
static mfh mscp_open(const char *path, int flags, mode_t mode, size_t off,
|
||||
sftp_session sftp)
|
||||
{
|
||||
mfh h;
|
||||
@@ -238,12 +239,12 @@ static mfh mscp_open(const char *path, mode_t mode, int flags, size_t off,
|
||||
if (sftp) {
|
||||
h.sf = sftp_open(sftp, path, flags, mode);
|
||||
if (!h.sf) {
|
||||
pr_err("sftp_open %s: %s\n", path, sftp_get_ssh_error(sftp));
|
||||
pr_err("sftp_open '%s': %s\n", path, sftp_get_ssh_error(sftp));
|
||||
return h;
|
||||
}
|
||||
|
||||
if (sftp_seek64(h.sf, off) < 0) {
|
||||
pr_err("sftp_seek64 %s: %s\n", path, sftp_get_ssh_error(sftp));
|
||||
pr_err("sftp_seek64 '%s': %s\n", path, sftp_get_ssh_error(sftp));
|
||||
sftp_close(h.sf);
|
||||
h.sf = NULL;
|
||||
return h;
|
||||
@@ -251,11 +252,11 @@ static mfh mscp_open(const char *path, mode_t mode, int flags, size_t off,
|
||||
} else {
|
||||
h.fd = open(path, flags, mode);
|
||||
if (h.fd < 0) {
|
||||
pr_err("open %s: %s\n", path, strerrno());
|
||||
pr_err("open '%s': %s\n", path, strerrno());
|
||||
return h;
|
||||
}
|
||||
if (lseek(h.fd, off, SEEK_SET) < 0) {
|
||||
pr_err("lseek %s: %s\n", path, strerrno());
|
||||
pr_err("lseek '%s': %s\n", path, strerrno());
|
||||
close(h.fd);
|
||||
h.fd = -1;
|
||||
return h;
|
||||
@@ -283,12 +284,12 @@ static int mscp_chmod(const char *path, mode_t mode, sftp_session sftp)
|
||||
{
|
||||
if (sftp) {
|
||||
if (sftp_chmod(sftp, path, mode) < 0) {
|
||||
pr_err("sftp_chmod %s: %s\n", path, sftp_get_ssh_error(sftp));
|
||||
pr_err("sftp_chmod '%s': %s\n", path, sftp_get_ssh_error(sftp));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (chmod(path, mode) < 0) {
|
||||
pr_err("chmod %s: %s\n", path, strerrno());
|
||||
pr_err("chmod '%s': %s\n", path, strerrno());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user