rem: struct buffer buf; buf_init(&buf, 0); buf_add_path(&buf, from); buf_add_path(&buf, to); err = sftp_request(SSH_FXP_RENAME, &buf, SSH_FXP_STATUS, NULL); buf_free(&buf);
add: err = sshfs_do_rename(from, to); if (err == -EPERM && rename_workaround) { size_t tolen = strlen(to); if (tolen + RENAME_TEMP_CHARS < PATH_MAX) { int tmperr; char totmp[PATH_MAX]; strcpy(totmp, to); random_string(totmp + tolen, RENAME_TEMP_CHARS); tmperr = sshfs_do_rename(to, totmp); if (!tmperr) { err = sshfs_do_rename(from, to); if (!err) err = sshfs_unlink(totmp); else sshfs_do_rename(totmp, to); } } }
context: static int sshfs_rename(const char *from, const char *to){    int err;    struct buffer buf;    buf_init(&buf, 0);    buf_add_path(&buf, from);    buf_add_path(&buf, to);    err = sftp_request(SSH_FXP_RENAME, &buf, SSH_FXP_STATUS, NULL);    buf_free(&buf);    return err;}