Changeset 126
- Timestamp:
- Apr 7, 2008, 9:33:39 AM (17 years ago)
- Location:
- branches/samba-3.0/source/ndpsmb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/ndpsmb/ndpsmb.c
r123 r126 12 12 #define NULL ((void *)0) 13 13 14 #ifndef DEBUG_PRINTF 15 #define debug_printf( ...) 16 #endif 17 14 18 void log(const char *fmt, ...) 15 19 { … … 39 43 } 40 44 45 // ------------------------------------------------------------- 46 47 /* time conversion functions: SMB protocol sends timestamps in GMT time, 48 * os2 api uses localtime, 49 * emx/klibc uses timezone and daylight saving to convert GMT timestamps, 50 * so only the timezone must be counted in conversion. 51 */ 52 void fsphUnixTimeToDosDate( time_t time, FDATE* fdate, FTIME *ftime) 53 { 54 struct tm* gmt = localtime( &time); 55 if (gmt->tm_isdst>0) { 56 debug_printf( "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone); 57 time -= 3600; 58 gmt = localtime( &time); 59 } 60 fdate->day = gmt->tm_mday; 61 fdate->month = gmt->tm_mon+1; 62 fdate->year = gmt->tm_year + 1900 - 1980; 63 ftime->twosecs = gmt->tm_sec/2; 64 ftime->minutes = gmt->tm_min; 65 ftime->hours = gmt->tm_hour; 66 } 67 68 void fsphDosDateToUnixTime( FDATE fdate, FTIME ftime, unsigned long* time) 69 { 70 struct tm gmtime = { 0 }; 71 struct tm* gmt; 72 73 debug_printf( "fsphDosDateToUnixTime time %02d:%02d\n", ftime.hours, ftime.minutes); 74 gmtime.tm_mday = fdate.day; 75 gmtime.tm_mon = fdate.month-1; 76 gmtime.tm_year = fdate.year + 1980 - 1900; 77 gmtime.tm_sec = ftime.twosecs*2; 78 gmtime.tm_min = ftime.minutes; 79 gmtime.tm_hour = ftime.hours; 80 gmtime.tm_isdst = -1; // force libc to check dst saving 81 82 *time = mktime( &gmtime); 83 debug_printf( "fsphDosDateToUnixTime time1 %d %s", *time, ctime( time)); 84 gmt = localtime( (time_t*) time); 85 if (gmt->tm_isdst>0) { 86 debug_printf( "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone); 87 *time += 3600; 88 } 89 debug_printf( "fsphDosDateToUnixTime time2 %d %s", *time, ctime( time)); 90 } 91 92 // ------------------------------------------------------------- 93 41 94 int StrLen(char * s) 42 95 { … … 339 392 stat->attrFile = (finfo->attr & 0x37); 340 393 341 ph->fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);342 ph->fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);343 ph->fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);394 fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite); 395 fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation); 396 fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess); 344 397 } 345 398 … … 369 422 stat.attrFile = (finfo->attr & 0x37); 370 423 371 ph->fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 372 ph->fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 373 ph->fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 424 fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 425 fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 426 fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 427 debug_printf( "fname %s\n", finfo->fname); 428 debug_printf( "mtime %d %s", finfo->mtime, ctime( &finfo->mtime)); 429 debug_printf( "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2); 374 430 375 431 ph->fsphAddFile32L(plist, &stat, name, StrLen(name), finfo, sizeof(*finfo), 0); … … 1179 1235 NDPATHELEMENT *pel = ph->fsphNameElem(0); 1180 1236 1181 log("NdpFindStart in\n");1237 debug_printf("NdpFindStart in\n"); 1182 1238 do 1183 1239 { … … 1282 1338 do 1283 1339 { 1284 log("NdpQueryInfo in <%s>, retry = %d\n", szPath, retry);1340 debug_printf("NdpQueryInfo in <%s>, retry = %d\n", szPath, retry); 1285 1341 1286 1342 do { … … 1414 1470 char path[CCHMAXPATH+1] = {0}; 1415 1471 1416 log("NdpSetPathInfo in\n");1472 debug_printf("NdpSetPathInfo in\n"); 1417 1473 do { 1418 1474 rc = checkconnection(pConn); … … 1431 1487 1432 1488 StrNCpy(finfo->fname, path, sizeof(finfo->fname) - 1); 1433 ph->fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, (unsigned long *)&(finfo->mtime));1489 fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo->mtime)); 1434 1490 if (ifL) 1435 1491 { … … 2140 2196 smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)(pConn->mem + sizeof(pConn->file)); 2141 2197 2142 log("NdpFileQueryInfo in\n");2198 debug_printf("NdpFileQueryInfo in\n"); 2143 2199 do { 2144 2200 if (pConn->file.fd < 0 || !*pConn->file.fname) … … 2381 2437 smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)pConn->mem; 2382 2438 2383 log("NdpFileSetInfo in\n");2439 debug_printf("NdpFileSetInfo in\n"); 2384 2440 do { 2385 2441 if (pConn->file.fd < 0 || !*pConn->file.fname) … … 2404 2460 // deferred setinfo - on closing the file 2405 2461 pConn->file.openattr = attrFile; 2406 ph->fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, (unsigned long *)&(pConn->file.mtime)); 2462 fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime)); 2463 debug_printf("NdpFileSetInfo mtime %d\n", pConn->file.mtime); 2407 2464 } while (0); 2408 2465 log("NdpFileSetInfo <%s> %08x %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc, pConn->rc); -
branches/samba-3.0/source/ndpsmb/smbwrp.c
r124 r126 2 2 3 3 #include "smbwrp.h" 4 5 #ifndef DEBUG_PRINTF 6 #define debug_printf( ...) 7 #endif 4 8 5 9 static int … … 273 277 274 278 if (c_time) { 275 *c_time = convert_timespec_to_time_t(interpret_long_date(rdata+0)) - cli->serverzone;279 *c_time = convert_timespec_to_time_t(interpret_long_date(rdata+0)); 276 280 } 277 281 if (a_time) { 278 *a_time = convert_timespec_to_time_t(interpret_long_date(rdata+8)) - cli->serverzone;282 *a_time = convert_timespec_to_time_t(interpret_long_date(rdata+8)); 279 283 } 280 284 if (m_time) { 281 *m_time = convert_timespec_to_time_t(interpret_long_date(rdata+16)) - cli->serverzone;285 *m_time = convert_timespec_to_time_t(interpret_long_date(rdata+16)); 282 286 } 283 287 if (w_time) { 284 *w_time = convert_timespec_to_time_t(interpret_long_date(rdata+24)) - cli->serverzone;288 *w_time = convert_timespec_to_time_t(interpret_long_date(rdata+24)); 285 289 } 286 290 if (mode) { … … 344 348 345 349 if (c_time) { 346 *c_time = convert_timespec_to_time_t(interpret_long_date(rdata+0)) - cli->serverzone;350 *c_time = convert_timespec_to_time_t(interpret_long_date(rdata+0)); 347 351 } 348 352 if (a_time) { 349 *a_time = convert_timespec_to_time_t(interpret_long_date(rdata+8)) - cli->serverzone;353 *a_time = convert_timespec_to_time_t(interpret_long_date(rdata+8)); 350 354 } 351 355 if (m_time) { 352 *m_time = convert_timespec_to_time_t(interpret_long_date(rdata+16)) - cli->serverzone;356 *m_time = convert_timespec_to_time_t(interpret_long_date(rdata+16)); 353 357 } 354 358 if (w_time) { 355 *w_time = convert_timespec_to_time_t(interpret_long_date(rdata+24)) - cli->serverzone;359 *w_time = convert_timespec_to_time_t(interpret_long_date(rdata+24)); 356 360 } 357 361 if (mode) { … … 609 613 if (file->openattr || file->mtime) 610 614 { 611 debuglocal(4,"Set attr on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->mtime + get_time_zone(file->mtime));612 if (!cli_setatr(cli, file->fname, file->openattr, file->mtime + get_time_zone(file->mtime)))615 debuglocal(4,"Set attr on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->mtime); 616 if (!cli_setatr(cli, file->fname, file->openattr, file->mtime)) 613 617 { 614 618 debuglocal(4,"Set attr on close failed %d\n", os2cli_errno(cli)); … … 819 823 return EINVAL; 820 824 } 825 debug_printf( "smbwrp_getattr\n"); 821 826 debuglocal(4,"getattr %d %d <%s>\n", cli->capabilities & CAP_NOPATHINFO2, cli->capabilities & CAP_NT_SMBS, finfo->fname); 822 827 if (!(cli->capabilities & CAP_NOPATHINFO2) && … … 868 873 } 869 874 870 if (cli_getatr(cli, finfo->fname, (unsigned short *)&finfo->attr, (size_t *)&finfo->size, (time_t *)&finfo->mtime))875 if (cli_getatr(cli, finfo->fname, (unsigned short *)&finfo->attr, &finfo->size, (time_t *)&finfo->mtime)) 871 876 { 872 877 //debuglocal(2,("gotattr1 %08x <%s>\n", finfo->attr, finfo->fname)); … … 1036 1041 finfo->ctime = def_finfo.ctime_ts.tv_sec; 1037 1042 strncpy(finfo->fname, def_finfo.name, sizeof(finfo->fname) - 1); 1038 1043 debug_printf( "fname %s (serverzone %d, level %d)\n",finfo->fname, cli->serverzone, level); 1044 1039 1045 switch (level) { 1040 1046 case 1: /* OS/2 understands this */ … … 1090 1096 /* Offset zero is "create time", not "change time". */ 1091 1097 p += 8; 1092 finfo->atime = interpret_long_date(p).tv_sec - cli->serverzone;1098 finfo->atime = interpret_long_date(p).tv_sec; 1093 1099 p += 8; 1094 finfo->mtime = interpret_long_date(p).tv_sec - cli->serverzone;1100 finfo->mtime = interpret_long_date(p).tv_sec; 1095 1101 p += 8; 1096 finfo->ctime = interpret_long_date(p).tv_sec - cli->serverzone;1102 finfo->ctime = interpret_long_date(p).tv_sec; 1097 1103 p += 8; 1098 1104 finfo->size = IVAL2_TO_SMB_BIG_UINT(p,0); … … 1404 1410 } 1405 1411 debuglocal(1,"Filelist <%s> on master <%s> wgrp <%s> server <%s> share <%s> clidev <%s>\n", state->mask, srv->master, srv->workgroup, srv->server_name, srv->share_name, cli->dev); 1412 debug_printf( "Filelist <%s> on master <%s> wgrp <%s> server <%s> share <%s> clidev <%s>\n", state->mask, srv->master, srv->workgroup, srv->server_name, srv->share_name, cli->dev); 1406 1413 if (*srv->workgroup == 0 && *srv->server_name == 0) 1407 1414 {
Note:
See TracChangeset
for help on using the changeset viewer.