Regarding added SMB-test in
https://github.com/curl/curl/pull/1630,
it's nice to see SMB is getting some focus (although I'm not able to run
these tests on my StrawberryPerl).
2 problems in smb.c AFAICS:
1) '_getpid()' is not a valid function in djgpp/MSDOS. Simple fix:
--- a/smb.c 2017-07-04 11:24:33
+++ b/smb.c 2017-07-04 12:42:10
@@ -31,12 +31,12 @@
#define BUILDING_CURL_SMB_C
#ifdef HAVE_PROCESS_H
-#include <process.h>
-#ifdef CURL_WINDOWS_APP
-#define getpid GetCurrentProcessId
-#else
-#define getpid _getpid
-#endif
+ #include <process.h>
+ #ifdef CURL_WINDOWS_APP
+ #define getpid GetCurrentProcessId
+ #elif !defined(MSDOS)
+ #define getpid _getpid
+ #endif
#endif
#include "smb.h"
2) A "curl --remote-time .." does nothing for smb://.
Seems to be a matter of using the 'smb_nt_create_response::last_change_time'
struct-member. The attached diff seems to work here.
A test like:
curl --remote-time -o test-file --libcurl - smb://host/Users/Public/test-file
shows
...
curl_easy_setopt(hnd, CURLOPT_FILETIME, 1L);
And the timestamp after the D/L seems okay.
--
--gv
--- a/smb.c 2017-07-04 11:24:33
+++ b/smb.c 2017-07-04 12:42:10
@@ -31,12 +31,12 @@
#define BUILDING_CURL_SMB_C
#ifdef HAVE_PROCESS_H
-#include <process.h>
-#ifdef CURL_WINDOWS_APP
-#define getpid GetCurrentProcessId
-#else
-#define getpid _getpid
-#endif
+ #include <process.h>
+ #ifdef CURL_WINDOWS_APP
+ #define getpid GetCurrentProcessId
+ #elif !defined(MSDOS)
+ #define getpid _getpid
+ #endif
#endif
#include "smb.h"
@@ -715,6 +715,23 @@
return CURLE_OK;
}
+/*
+ * Convert a timestamp from the Windows world (100 nsec units from
+ * 1 Jan 1601) to Posix time.
+ */
+static void get_posix_time (long *_out, const void *_in)
+{
+#ifdef HAVE_LONGLONG
+ long long time = *(long long *) _in;
+#else
+ unsigned __int64 time = *(unsigned __int64 *) _in;
+#endif
+
+ time -= 116444736000000000ULL;
+ time /= 10000000;
+ *_out = (long) time;
+}
+
static CURLcode smb_request_state(struct connectdata *conn, bool *done)
{
struct smb_request *req = conn->data->req.protop;
@@ -725,6 +742,7 @@
unsigned short off;
CURLcode result;
void *msg = NULL;
+ const struct smb_nt_create_response *smb_m;
/* Start the request */
if(req->state == SMB_REQUESTING) {
@@ -767,7 +785,8 @@
next_state = SMB_TREE_DISCONNECT;
break;
}
- req->fid = smb_swap16(((struct smb_nt_create_response *)msg)->fid);
+ smb_m = (const struct smb_nt_create_response*) msg;
+ req->fid = smb_swap16(smb_m->fid);
conn->data->req.offset = 0;
if(conn->data->set.upload) {
conn->data->req.size = conn->data->state.infilesize;
@@ -775,9 +794,11 @@
next_state = SMB_UPLOAD;
}
else {
- conn->data->req.size =
- smb_swap64(((struct smb_nt_create_response *)msg)->end_of_file);
+ smb_m = (const struct smb_nt_create_response*) msg;
+ conn->data->req.size = smb_swap64(smb_m->end_of_file);
Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size);
+ if(conn->data->set.get_filetime)
+ get_posix_time (&conn->data->info.filetime, &smb_m->last_change_time);
next_state = SMB_DOWNLOAD;
}
break;
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html