1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Give fxp_mkdir_send an attrs parameter.

It's not used anywhere, but this would make it one step easier to add
a mode argument to PSFTP's mkdir command, if anyone needs it. Mostly
the point is to get rid of the FIXME comment in fxp_mkdir_send itself.
This commit is contained in:
Simon Tatham 2018-10-06 11:52:04 +01:00
parent d9369d4a46
commit 6c0f22bb9f
4 changed files with 13 additions and 12 deletions

2
pscp.c
View File

@ -1015,7 +1015,7 @@ int scp_send_dirname(const char *name, int modes)
* exists and is a directory we will assume we were either * exists and is a directory we will assume we were either
* successful or it didn't matter. * successful or it didn't matter.
*/ */
req = fxp_mkdir_send(fullname); req = fxp_mkdir_send(fullname, NULL);
pktin = sftp_wait_for_reply(req); pktin = sftp_wait_for_reply(req);
ret = fxp_mkdir_recv(pktin, req); ret = fxp_mkdir_recv(pktin, req);

View File

@ -516,7 +516,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
if (!result || if (!result ||
!(attrs.flags & SSH_FILEXFER_ATTR_PERMISSIONS) || !(attrs.flags & SSH_FILEXFER_ATTR_PERMISSIONS) ||
!(attrs.permissions & 0040000)) { !(attrs.permissions & 0040000)) {
req = fxp_mkdir_send(outfname); req = fxp_mkdir_send(outfname, NULL);
pktin = sftp_wait_for_reply(req); pktin = sftp_wait_for_reply(req);
result = fxp_mkdir_recv(pktin, req); result = fxp_mkdir_recv(pktin, req);
@ -1422,7 +1422,7 @@ int sftp_cmd_mkdir(struct sftp_command *cmd)
return 0; return 0;
} }
req = fxp_mkdir_send(dir); req = fxp_mkdir_send(dir, NULL);
pktin = sftp_wait_for_reply(req); pktin = sftp_wait_for_reply(req);
result = fxp_mkdir_recv(pktin, req); result = fxp_mkdir_recv(pktin, req);

14
sftp.c
View File

@ -85,6 +85,8 @@ static void BinarySink_put_fxp_attrs(BinarySink *bs, struct fxp_attrs attrs)
} }
} }
static const struct fxp_attrs no_attrs = { 0 };
#define put_fxp_attrs(bs, attrs) \ #define put_fxp_attrs(bs, attrs) \
BinarySink_put_fxp_attrs(BinarySink_UPCAST(bs), attrs) BinarySink_put_fxp_attrs(BinarySink_UPCAST(bs), attrs)
@ -460,7 +462,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req)
* Open a file. * Open a file.
*/ */
struct sftp_request *fxp_open_send(const char *path, int type, struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs) const struct fxp_attrs *attrs)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -469,10 +471,7 @@ struct sftp_request *fxp_open_send(const char *path, int type,
put_uint32(pktout, req->id); put_uint32(pktout, req->id);
put_stringz(pktout, path); put_stringz(pktout, path);
put_uint32(pktout, type); put_uint32(pktout, type);
if (attrs) put_fxp_attrs(pktout, attrs ? *attrs : no_attrs);
put_fxp_attrs(pktout, *attrs);
else
put_uint32(pktout, 0); /* empty ATTRS structure */
sftp_send(pktout); sftp_send(pktout);
return req; return req;
@ -566,7 +565,8 @@ int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req)
return fxp_errtype == SSH_FX_OK; return fxp_errtype == SSH_FX_OK;
} }
struct sftp_request *fxp_mkdir_send(const char *path) struct sftp_request *fxp_mkdir_send(const char *path,
const struct fxp_attrs *attrs)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -574,7 +574,7 @@ struct sftp_request *fxp_mkdir_send(const char *path)
pktout = sftp_pkt_init(SSH_FXP_MKDIR); pktout = sftp_pkt_init(SSH_FXP_MKDIR);
put_uint32(pktout, req->id); put_uint32(pktout, req->id);
put_stringz(pktout, path); put_stringz(pktout, path);
put_uint32(pktout, 0); /* (FIXME) empty ATTRS structure */ put_fxp_attrs(pktout, attrs ? *attrs : no_attrs);
sftp_send(pktout); sftp_send(pktout);
return req; return req;

5
sftp.h
View File

@ -138,7 +138,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req);
* if it's being created. * if it's being created.
*/ */
struct sftp_request *fxp_open_send(const char *path, int type, struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs); const struct fxp_attrs *attrs);
struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin, struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
struct sftp_request *req); struct sftp_request *req);
@ -158,7 +158,8 @@ int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Make a directory. * Make a directory.
*/ */
struct sftp_request *fxp_mkdir_send(const char *path); struct sftp_request *fxp_mkdir_send(const char *path,
const struct fxp_attrs *attrs);
int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*