Ignore:
Timestamp:
Aug 16, 2016, 5:41:49 PM (9 years ago)
Author:
Silvan Scherrer
Message:

samba client: add the possibility to have logfiles per share

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/src/ndpsmb.c

    r959 r960  
    3535
    3636/* time conversion functions: SMB protocol sends timestamps in GMT time,
    37 * os2 api uses localtime,
    38 * emx/klibc uses timezone and daylight saving to convert GMT timestamps,
    39 * so only the timezone must be counted in conversion.
    40 */
    41 void fsphUnixTimeToDosDate( time_t time, FDATE* fdate, FTIME *ftime)
     37 * os2 api uses localtime,
     38 * emx/klibc uses timezone and daylight saving to convert GMT timestamps,
     39 * so only the timezone must be counted in conversion.
     40 */
     41void fsphUnixTimeToDosDate(Resource *pRes, time_t time, FDATE* fdate, FTIME *ftime)
    4242{
    4343        struct tm* gmt = localtime( &time);
     
    4545        if (gmt->tm_isdst>0)
    4646        {
    47            debuglocal(9, "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
     47           debuglocal(pRes, 9, "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    4848           time -= 3600;
    4949           gmt = localtime( &time);
     
    5656        ftime->minutes = gmt->tm_min;
    5757        ftime->hours = gmt->tm_hour;
    58 }
    59 
    60 void fsphDosDateToUnixTime( FDATE fdate, FTIME ftime, ULONG* time)
     58        return;
     59}
     60
     61void fsphDosDateToUnixTime(Resource *pRes, FDATE fdate, FTIME ftime, ULONG* time)
    6162{
    6263        struct tm gmtime = { 0 };
    6364
    64         debuglocal(9, "fsphDosDateToUnixTime time %02d:%02d:%02d\n", ftime.hours, ftime.minutes, ftime.twosecs*2);
     65        debuglocal(pRes, 9, "fsphDosDateToUnixTime time %02d:%02d:%02d\n", ftime.hours, ftime.minutes, ftime.twosecs*2);
    6566        gmtime.tm_mday = fdate.day;
    6667        gmtime.tm_mon = fdate.month-1;
     
    7273
    7374        *time = mktime( &gmtime);
    74         debuglocal(9, "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
     75        debuglocal(pRes, 9, "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
    7576#if 0 // as mktime() already does dst we don't need to add something
    7677        struct tm* gmt;
     
    7879        if (gmt->tm_isdst>0)
    7980        {
    80            debuglocal(9, "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
     81           debuglocal(pRes, 9, "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    8182           *time += 3600;
    8283        }
    83         debuglocal(9, "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
     84        debuglocal(pRes, 9, "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
    8485#endif
     86        return;
    8587}
    8688       
     
    111113        {ND_PROP_ULONG, 0, "CLD", "32"},
    112114        {ND_PROP_ULONG, 0, "EASUPPORT", "1"},
     115        {ND_PROP_ULONG, 0, "LOGLEVEL", "0"},
    113116        {ND_PROP_STRING, 0, NULL, NULL}
    114117};
     
    154157        if (rcLock != NO_ERROR)     \
    155158           return rcLock;           \
     159        smbwrp_Logging(pRes);       \
    156160} while (0)
    157161
     
    165169#endif
    166170
    167 int helperEASet (cli_state *cli, FEALIST *pFEAList, char *path)
     171int helperEASet (Resource *pRes, cli_state *cli, FEALIST *pFEAList, char *path)
    168172{
    169173        int rc = 0;
     
    181185           while (done < pFEAList->cbList)
    182186           {
    183               rc = smbwrp_setea(cli, path, (char*)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
     187              rc = smbwrp_setea(pRes, cli, path, (char*)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
    184188              if (rc)
    185189                 break;
     
    201205
    202206        lockInit();
    203         debugInit();
    204         debuglocal(9,"Working with %s bit fileio NDFS\n", ifL ? "64" : "32");
    205207        return NO_ERROR;
    206208}
     
    234236        stat->attrFile = (finfo->attr & 0x37);
    235237
    236         fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
    237         fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
    238         fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
     238        fsphUnixTimeToDosDate(pConn->pRes, finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
     239        fsphUnixTimeToDosDate(pConn->pRes, finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
     240        fsphUnixTimeToDosDate(pConn->pRes, finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
    239241        return;
    240242}
     
    259261        stat.attrFile = (finfo->attr & 0x37);
    260262
    261         fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
    262         fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
    263         fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
    264         debuglocal(9, "fname %s\n", finfo->fname);
    265         debuglocal(9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
    266         debuglocal(9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2);
     263        fsphUnixTimeToDosDate(pConn->pRes, finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
     264        fsphUnixTimeToDosDate(pConn->pRes, finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
     265        fsphUnixTimeToDosDate(pConn->pRes, finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
     266        debuglocal(pConn->pRes, 9, "fname %s\n", finfo->fname);
     267        debuglocal(pConn->pRes, 9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
     268        debuglocal(pConn->pRes, 9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2);
    267269
    268270        ph->fsphAddFile32L(plist, &stat, name, strlen(name), finfo, sizeof(*finfo), 0);
     
    344346#endif
    345347        pRes->pdc = NULL;
     348        pRes->loglevel = 0;
    346349
    347350        t = 0, q = NULL;
     
    451454        }
    452455
     456        t = 0;
     457        rc = ph->fsphQueryUlongProperty (properties, "LOGLEVEL", &t);
     458        if (!rc)
     459        {
     460           if (t > 10)
     461              rc = ERROR_INVALID_PARAMETER;
     462           else
     463              pRes->loglevel = t;
     464        }
     465
     466        // figure out the used share/server/workgroup
     467        char *logfileext = '\0';
     468        if (pRes->srv.share_name)
     469           logfileext = pRes->srv.share_name;
     470        if (!logfileext && pRes->srv.server_name)
     471           logfileext = pRes->srv.server_name;
     472        if (!logfileext && pRes->srv.workgroup)
     473           logfileext = pRes->srv.workgroup;
     474
     475        // init debug and write the very first message
     476        debugInit(pRes, logfileext, ifL);
     477        debuglocal(pRes, 9, "NdpMountResource initResource\n");
     478
     479        // init code
     480        smbwrp_init(pRes);
     481
    453482        /*
    454483         * Create a directory cache with expiration time and cache listings
    455484         * the above values come from the gui. default: timeout 10; listings: 32
    456485        */
    457         dircache_create(&pRes->pdc, pRes->cachetimeout, pRes->cachedepth);
     486        dircache_create(pRes);
    458487
    459488        return rc;
     
    562591              // reconnect to server here, first test new connection
    563592              cli_state* tmp_cli = NULL;
    564               rc = smbwrp_connect( &tmpRes, &tmp_cli);
     593              rc = smbwrp_connect(&tmpRes, &tmp_cli);
    565594              if (!rc)
    566595              {
    567596                 // new connection is ok, disconnect old one
    568597                 cli_state* cli = pConn->cli;
    569                  smbwrp_disconnect( pRes, cli);
     598                 smbwrp_disconnect(pRes, cli);
    570599                 // save tmp data structure
    571600                 memcpy( pRes, &tmpRes, sizeof( tmpRes));
     
    582611
    583612/* check if the requested resource is available */
    584 static int checkMountResource( Resource* pRes)
     613static int checkMountResource(Resource* pRes)
    585614{
    586615        int rc;
     
    588617        cli_state* cli = NULL;
    589618
    590         debuglocal(9, "checkMountResource in tid#%d\n", _gettid());
    591         rc = smbwrp_connect( pRes, &cli);
     619        debuglocal(pRes, 9, "checkMountResource in tid#%d\n", _gettid());
     620        rc = smbwrp_connect(pRes, &cli);
    592621        switch (rc)
    593622        {
     
    620649        } /* endswitch */
    621650
    622         smbwrp_disconnect( pRes, cli);
     651        smbwrp_disconnect(pRes, cli);
    623652        return rc;
    624653}
     
    631660
    632661        ENTER();
    633 
    634         debuglocal(9,"NdpMountResource in\n");
    635         // init code
    636         smbwrp_init();
    637662
    638663        /*
     
    666691        }
    667692
    668         debuglocal(9, "NdpMountResource rc=%d\n", rc);
     693        debuglocal(pRes, 9, "NdpMountResource rc=%d\n", rc);
    669694        LEAVE();
    670695        return rc;
     
    675700        Resource *pRes = (Resource *)resource;
    676701        ENTER();
    677         dircache_delete(pRes->pdc);
     702        dircache_delete(pRes);
    678703        memset(&pRes->srv, 0, sizeof(pRes->srv));
     704        debuglocal(pRes, 9, "NdpFreeResource %d\n", NO_ERROR);
     705        debugClose(pRes);
    679706        free(pRes);
    680         debuglocal(9, "NdpFreeResource %d\n", NO_ERROR);
    681707        LEAVE();
    682708        return NO_ERROR;
     
    689715        int rc = ND_RSRC_DIFFERENT;
    690716
    691         debuglocal(9, "NdpRsrcCompare in\n");
     717        debuglocal(pRes, 9, "NdpRsrcCompare in\n");
    692718        if (ph->fsphStrICmp(pRes->srv.server_name, pRes2->srv.server_name) == 0
    693719           && ph->fsphStrICmp(pRes->srv.share_name, pRes2->srv.share_name) == 0
     
    699725        }
    700726
    701         debuglocal(9, "NdpRsrcCompare %d\n", rc);
     727        debuglocal(pRes, 9, "NdpRsrcCompare %d\n", rc);
    702728        return rc;
    703729}
     
    706732{
    707733        // do nothing
    708         debuglocal(9, "NdpRsrcUpdate %d\n", NO_ERROR);
     734        Resource *pRes = (Resource *)resource;
     735        debuglocal(pRes, 9, "NdpRsrcUpdate %d\n", NO_ERROR);
    709736        return NO_ERROR;
    710737}
     
    716743        char s[4096];
    717744
    718         debuglocal(9, "NdpRsrcQueryInfo in\n");
     745        debuglocal(pRes, 9, "NdpRsrcQueryInfo in\n");
    719746
    720747        switch (pRes->rootlevel)
     
    739766           memcpy(pdata, s, *poutlen);
    740767
    741         debuglocal(9, "NdpRsrcQueryInfo %d\n", rc);
     768        debuglocal(pRes, 9, "NdpRsrcQueryInfo %d\n", rc);
    742769        return rc;
    743770}
     
    759786
    760787        ENTER();
    761         debuglocal(9, "NdpRsrcQueryFSAllocate %08x\n", pfsa);
     788        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate %08x\n", pfsa);
    762789
    763790        if (!pfsa)
     
    767794        }
    768795
    769         debuglocal(9, "NdpRsrcQueryFSAllocate in tid#%d\n", _gettid());
    770         rc = smbwrp_connect( pRes, &cli);
     796        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate in tid#%d\n", _gettid());
     797        rc = smbwrp_connect(pRes, &cli);
    771798        if (rc)
    772799        {
    773            debuglocal(9, "NdpRsrcQueryFSAllocate smbwrp_connect failed rc=%d\n", rc);   
     800           debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate smbwrp_connect failed rc=%d\n", rc);     
    774801           pfsa->cSectorUnit = 1;
    775802           pfsa->cUnit = 123456;
     
    781808        }
    782809
    783         rc = smbwrp_dskattr( cli, &fsa);
     810        rc = smbwrp_dskattr(pRes, cli, &fsa);
    784811        if (rc)
    785812        {
     
    798825        }
    799826
    800         smbwrp_disconnect( pRes, cli);
    801         debuglocal(9, "NdpRsrcQueryFSAllocate %d/%d (cUnit = %d/cUnitAvail = %d/cbSector = %d)\n", rc, rc1, pfsa->cUnit, pfsa->cUnitAvail, pfsa->cbSector);
     827        smbwrp_disconnect(pRes, cli);
     828        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate %d/%d (cUnit = %d/cUnitAvail = %d/cbSector = %d)\n", rc, rc1, pfsa->cUnit, pfsa->cUnitAvail, pfsa->cbSector);
    802829
    803830        LEAVE();
     
    814841        ENTER();
    815842
    816         debuglocal(9, "NdpCreateConnection in\n");
     843        debuglocal(pRes, 9, "NdpCreateConnection in\n");
    817844
    818845        pConn = malloc( sizeof(Connection));
     
    822849        if (rc)
    823850        {
    824            debuglocal(9, "NdpCreateConnection ERROR_NOT_ENOUGH_MEMORY %d\n", rc);
     851           debuglocal(pRes, 9, "NdpCreateConnection ERROR_NOT_ENOUGH_MEMORY %d\n", rc);
    825852           LEAVE();
    826853           return rc;
     
    831858        pConn->file.fd = -1;
    832859
    833         debuglocal(9, "NdpCreateConnection send CONNECT\n");
    834         rc = smbwrp_connect( pRes, &pConn->cli);
     860        debuglocal(pRes, 9, "NdpCreateConnection send CONNECT\n");
     861        rc = smbwrp_connect(pRes, &pConn->cli);
    835862        if (rc)
    836863        {
     
    841868
    842869        *pconn = (HCONNECTION)pConn;
    843         debuglocal(9, "NdpCreateConnection [%p] %d\n", pConn, rc);
     870        debuglocal(pRes, 9, "NdpCreateConnection [%p] %d\n", pConn, rc);
    844871
    845872        LEAVE();
     
    855882        ENTER();
    856883
    857         debuglocal(9, "NdpFreeConnection in [%p]\n", pConn);
     884        debuglocal(pRes, 9, "NdpFreeConnection in [%p]\n", pConn);
    858885        if (pConn->file.fd >= 0)
    859886        {
    860            rc = smbwrp_close( pConn->cli, &pConn->file);
     887           rc = smbwrp_close(pRes, pConn->cli, &pConn->file);
    861888           pConn->file.fd = -1;
    862889        }
    863890
    864         smbwrp_disconnect( pRes, pConn->cli);
    865 
     891        smbwrp_disconnect(pRes, pConn->cli);
     892
     893        debuglocal(pRes, 9, "NdpFreeConnection %d\n", NO_ERROR);
    866894        free(pConn);
    867         debuglocal(9, "NdpFreeConnection %d\n", NO_ERROR);
    868895
    869896        LEAVE();
     
    900927        ENTER();
    901928
    902         debuglocal(9, "NdpQueryPathInfo in [%p] <%s>\n", pConn, szPath);
     929        debuglocal(pRes, 9, "NdpQueryPathInfo in [%p] <%s>\n", pConn, szPath);
    903930       
    904931        /*
     
    915942           // First check if there is information in the directory cache.
    916943           unsigned long ulAge = 0;
    917            if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
     944           if (dircache_find_path(pRes, szPath, &finfo, &ulAge))
    918945           {
    919946              if (ulAge <= 15) /* @todo configurable. */
     
    927954
    928955           rc = pathparser(pRes, pConn, szPath, path);
    929            debuglocal(9, "NdpQueryPathInfo pathparser for <%s> rc=%d\n", path, rc);
     956           debuglocal(pRes, 9, "NdpQueryPathInfo pathparser for <%s> rc=%d\n", path, rc);
    930957           switch (rc)
    931958           {
     
    944971
    945972           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    946            debuglocal(9, "NdpQueryPathInfo smbwrp_getattr for <%s>\n", path);
    947            rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     973           debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_getattr for <%s>\n", path);
     974           rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
    948975           if (rc)
    949976           {
     
    952979              {
    953980                 // free current cli resources
    954                  smbwrp_disconnect( pRes, pConn->cli);
     981                 smbwrp_disconnect(pRes, pConn->cli);
    955982                 // reconnect
    956                  rcCon = smbwrp_connect( pRes, &pConn->cli);
     983                 rcCon = smbwrp_connect(pRes, &pConn->cli);
    957984                 if (rcCon != NO_ERROR)
    958                     debuglocal(9, "NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
     985                    debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
    959986                 // try file list again if reconnecting worked
    960987                 if (rcCon == NO_ERROR)
    961                     rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     988                    rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
    962989              }
    963990
    964               debuglocal(9, "NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
     991              debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
    965992              switch (rc)
    966993              {
     
    9891016              {
    9901017                 *p = 0;
    991                  rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    992                  debuglocal(9, "NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
     1018                 rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
     1019                 debuglocal(pRes, 9, "NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
    9931020                 if (rc == NO_ERROR)
    9941021                    rc = (finfo.attr & FILE_DIRECTORY) !=0 ? ERROR_FILE_NOT_FOUND:ERROR_PATH_NOT_FOUND;
     
    9981025           }
    9991026        } while (0);
    1000         debuglocal(9, "NdpQueryPathInfo <%s> (%s) %d\n", szPath, path, rc);
     1027        debuglocal(pRes, 9, "NdpQueryPathInfo <%s> (%s) %d\n", szPath, path, rc);
    10011028
    10021029        LEAVE();
     
    10201047        ENTER();
    10211048
    1022         debuglocal(9, "NdpFindStart in [%p]\n", pConn);
     1049        debuglocal(pRes, 9, "NdpFindStart in [%p]\n", pConn);
    10231050
    10241051        strncpy(dir, szPath, sizeof(dir) - 1);
     
    10761103           strcpy(state.mask, "\\*");
    10771104
    1078         debuglocal(9, "NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
     1105        debuglocal(pRes, 9, "NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
    10791106        state.dir, state.dir_mask, state.mask, state.fullpath);
    1080         rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
     1107        rc = smbwrp_filelist(pRes, &pRes->srv, pConn->cli, &state);
    10811108        /*
    10821109         * we need to handle reconnection also here, because NdpQueryPathInfo
     
    10871114        {
    10881115           // free current cli resources
    1089            smbwrp_disconnect( pRes, pConn->cli);
     1116           smbwrp_disconnect(pRes, pConn->cli);
    10901117           // reconnect
    1091            smbwrp_connect( pRes, &pConn->cli);
     1118           smbwrp_connect(pRes, &pConn->cli);
    10921119           // try file list again next loop
    1093            rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    1094            debuglocal(9, "NdpFindStart remote connection lost, rc = %d\n", rc);
    1095         }
    1096 
    1097         debuglocal(9, "NdpFindStart <%s> (%s) cnt %d %d\n", szPath, path, count, rc);
     1120           rc = smbwrp_filelist(pRes, &pRes->srv, pConn->cli, &state);
     1121           debuglocal(pRes, 9, "NdpFindStart remote connection lost, rc = %d\n", rc);
     1122        }
     1123
     1124        debuglocal(pRes, 9, "NdpFindStart <%s> (%s) cnt %d %d\n", szPath, path, count, rc);
    10981125
    10991126        LEAVE();
     
    11031130int APIENTRY NdpDeletePathInfo (HRESOURCE resource, NDFILEINFOL *pfi)
    11041131{
    1105         debuglocal(9, "NdpDeletePathInfo %d\n", 0);
     1132        Resource * pRes = (Resource *)resource;
     1133        debuglocal(pRes, 9, "NdpDeletePathInfo %d\n", 0);
    11061134        return NO_ERROR;
    11071135}
     
    11091137int APIENTRY NdpRefresh (HCONNECTION conn, char *path, int tree)
    11101138{
    1111         debuglocal(9, "NdpRefresh <%s> %d\n", path, 0);
     1139        Connection *pConn = (Connection *)conn;
     1140        debuglocal(pConn->pRes, 9, "NdpRefresh <%s> %d\n", path, 0);
    11121141        return NO_ERROR;
    11131142}
     
    11211150        */
    11221151
    1123         debuglocal(9, "NdpDicardresourceData %d\n", 0);
     1152        Resource * pRes = (Resource *)resource;
     1153        debuglocal(pRes, 9, "NdpDicardresourceData %d\n", 0);
    11241154        return NO_ERROR;
    11251155}
     
    11361166        ENTER();
    11371167
    1138         debuglocal(9, "NdpSetPathInfo in [%p]\n", pConn);
     1168        debuglocal(pRes, 9, "NdpSetPathInfo in [%p]\n", pConn);
    11391169
    11401170        // delete the dir cache
    1141         dircache_invalidate(szPathName, pRes->pdc, 1);
     1171        dircache_invalidate(szPathName, pRes, 1);
    11421172
    11431173        do {
     
    11481178           memset(&finfo, 0, sizeof(finfo));
    11491179           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    1150            fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo.mtime));
     1180           fsphDosDateToUnixTime(pRes, pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo.mtime));
    11511181           finfo.attr = pfi->stat.attrFile & 0x37;
    1152            rc = smbwrp_setattr(pConn->cli, &finfo);
     1182           rc = smbwrp_setattr(pRes, pConn->cli, &finfo);
    11531183        } while (0);
    11541184
    1155         debuglocal(9, "NdpSetPathInfo <%s> (%s) %d\n", szPathName, path, rc);
    1156 
    1157         LEAVE();
    1158         return rc;
    1159 }
    1160 
    1161 int buildFEALIST(FEALIST *pFEASrc, GEALIST *pGEAList, FEALIST *pFEAList)
     1185        debuglocal(pRes, 9, "NdpSetPathInfo <%s> (%s) %d\n", szPathName, path, rc);
     1186
     1187        LEAVE();
     1188        return rc;
     1189}
     1190
     1191int buildFEALIST(Resource *pRes, FEALIST *pFEASrc, GEALIST *pGEAList, FEALIST *pFEAList)
    11621192{
    11631193        int rc = 0;
     
    11731203        pfeadest = pFEAList->list;
    11741204        dsize = pFEAList->cbList;
    1175         //debuglocal(9,"buildFEALIST in destsize %d srcsize %d pGEAList=%08x pGEAList->cbList=%d\n", dsize, ddone, size, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1205        //debuglocal(pRes, 9,"buildFEALIST in destsize %d srcsize %d pGEAList=%08x pGEAList->cbList=%d\n", dsize, ddone, size, pGEAList, pGEAList ? pGEAList->cbList : 0);
    11761206
    11771207        while (done < size)
     
    11871217              while (done < size)
    11881218              {
    1189                  //debuglocal(9,"comp <%s> <%s>\n", name, pgea->szName);
     1219                 //debuglocal(pRes, 9,"comp <%s> <%s>\n", name, pgea->szName);
    11901220                 if (!ph->fsphStrNCmp(name, pgea->szName, pgea->cbName))
    11911221                 {
     
    12111241           }
    12121242           done += sizeof(FEA) + pfea->cbName + 1 + pfea->cbValue;
    1213            //debuglocal(9,"buuildfea <%s> insert=%d pfea->cbName=%d pfea->cbValue=%d srcdone=%d destdone=%d pfeadest=%08x pfea=%08x\n", name, insert, pfea->cbName, pfea->cbValue, done, ddone, pfeadest, pfea);
     1243           //debuglocal(pRes, 9,"buuildfea <%s> insert=%d pfea->cbName=%d pfea->cbValue=%d srcdone=%d destdone=%d pfeadest=%08x pfea=%08x\n", name, insert, pfea->cbName, pfea->cbValue, done, ddone, pfeadest, pfea);
    12141244           pfea = (FEA *)((char *)pFEASrc + done);
    12151245        }
     
    12191249           rc = ERROR_BUFFER_OVERFLOW;
    12201250
    1221         debuglocal(9, "buildFEALIST rc=%d destsize=%d destdone=%d srcsize=%d pGEAList=%08x\n", rc, dsize, ddone, size, pGEAList);
     1251        debuglocal(pRes, 9, "buildFEALIST rc=%d destsize=%d destdone=%d srcsize=%d pGEAList=%08x\n", rc, dsize, ddone, size, pGEAList);
    12221252        return rc;
    12231253}
     
    12441274        if (rc || !fdata.ulSize || !fdata.pData)
    12451275        {
    1246            debuglocal(9, "NdpEAQuery: ph->fsphGetFileInfoData = %d/%d %08x\n", rc, fdata.ulSize, fdata.pData);
     1276           debuglocal(pRes, 9, "NdpEAQuery: ph->fsphGetFileInfoData = %d/%d %08x\n", rc, fdata.ulSize, fdata.pData);
    12471277           return ERROR_EAS_NOT_SUPPORTED;
    12481278        }
     
    12521282        finfo = (smbwrp_fileinfo *)fdata.pData;
    12531283        path = finfo->fname;
    1254         debuglocal(9, "NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1284        debuglocal(pRes, 9, "NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    12551285
    12561286        char *pchBuffer = (char *)malloc(cbBuffer);
     
    12621292
    12631293        do {
    1264            rc = smbwrp_listea( pConn->cli, path, pchBuffer, cbBuffer);
     1294           rc = smbwrp_listea(pRes, pConn->cli, path, pchBuffer, cbBuffer);
    12651295           pFEASrc = (FEALIST*) pchBuffer;
    12661296           if (rc)
     
    12811311           }
    12821312           else
    1283               rc = buildFEALIST((FEALIST *)pFEASrc, pGEAList, pFEAList);
     1313              rc = buildFEALIST(pRes, (FEALIST *)pFEASrc, pGEAList, pFEAList);
    12841314        } while (0);
    12851315
    12861316        free(pchBuffer);
    1287         debuglocal(9, "NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
     1317        debuglocal(pRes, 9, "NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
    12881318
    12891319        LEAVE();
     
    13011331        smbwrp_fileinfo *finfo;
    13021332
    1303         debuglocal(9, "NdpEASet in [%p]\n", pConn);
     1333        debuglocal(pRes, 9, "NdpEASet in [%p]\n", pConn);
    13041334
    13051335        if (!pfi || !pfi->pszName)
     
    13121342        if (rc || !fdata.ulSize || !fdata.pData)
    13131343        {
    1314            debuglocal(9, "NdpEASet: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
     1344           debuglocal(pRes, 9, "NdpEASet: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
    13151345           return ERROR_EAS_NOT_SUPPORTED;
    13161346        }
     
    13191349        path = finfo->fname;
    13201350
    1321         rc = helperEASet(pConn->cli, pFEAList, path);
    1322         debuglocal(9, "NdpEASet %d\n", rc);
     1351        rc = helperEASet(pRes, pConn->cli, pFEAList, path);
     1352        debuglocal(pRes, 9, "NdpEASet %d\n", rc);
    13231353        return rc;
    13241354}
     
    13461376        if (rc || !fdata.ulSize || !fdata.pData)
    13471377        {
    1348            debuglocal(9, "NdpEASize: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
     1378           debuglocal(pRes, 9, "NdpEASize: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
    13491379           return ERROR_EAS_NOT_SUPPORTED;
    13501380        }
     
    13591389        {
    13601390           *pulEASize = easize;
    1361            debuglocal(9, "NdpEASize <%s> cached %d\n", path, easize);
     1391           debuglocal(pRes, 9, "NdpEASize <%s> cached %d\n", path, easize);
    13621392           LEAVE();
    13631393           return NO_ERROR;
    13641394        }
    13651395
    1366         debuglocal(9, "NdpEASize in [%p] <%s> \n", pConn, path);
     1396        debuglocal(pRes, 9, "NdpEASize in [%p] <%s> \n", pConn, path);
    13671397
    13681398        char *pchBuffer = (char *)malloc(cbBuffer);
     
    13741404
    13751405        do {
    1376            rc = smbwrp_listea(pConn->cli, path, pchBuffer, cbBuffer);
     1406           rc = smbwrp_listea(pRes, pConn->cli, path, pchBuffer, cbBuffer);
    13771407           pfealist = (FEALIST*)pchBuffer;
    13781408           if (rc)
     
    13941424
    13951425        free(pchBuffer);
    1396         debuglocal(9, "NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
     1426        debuglocal(pRes, 9, "NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
    13971427
    13981428        LEAVE();
     
    14081438        char path[CCHMAXPATH+1] = {0};
    14091439       
    1410         debuglocal(9, "NdpSetCurrentDir in [%p]\n", pConn);
     1440        debuglocal(pRes, 9, "NdpSetCurrentDir in [%p]\n", pConn);
    14111441
    14121442        ENTER();
     
    14171447              break;
    14181448
    1419         rc = smbwrp_chdir(&pRes->srv, pConn->cli, path);
     1449        rc = smbwrp_chdir(pRes, &pRes->srv, pConn->cli, path);
    14201450        } while (0);
    14211451
    1422         debuglocal(9, "NdpSetCurrentDir <%s> (%s) %d\n", szPath, path, rc);
     1452        debuglocal(pRes, 9, "NdpSetCurrentDir <%s> (%s) %d\n", szPath, path, rc);
    14231453
    14241454        LEAVE();
     
    14281458int APIENTRY NdpCopy (HCONNECTION conn, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc, ULONG ulOption)
    14291459{
    1430         debuglocal(9, "NdpCopy <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
     1460        Connection *pConn = (Connection *)conn;
     1461        Resource *pRes = pConn->pRes;
     1462        debuglocal(pRes, 9, "NdpCopy <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
    14311463        return ERROR_CANNOT_COPY;
    14321464}
     
    14341466int APIENTRY NdpCopy2 (HCONNECTION conn, HRESOURCE resDst, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc, ULONG ulOption)
    14351467{
    1436         debuglocal(9, "NdpCopy2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
     1468        Connection *pConn = (Connection *)conn;
     1469        Resource *pRes = pConn->pRes;
     1470        debuglocal(pRes, 9, "NdpCopy2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
    14371471        return ERROR_CANNOT_COPY;
    14381472}
     
    14481482        ENTER();
    14491483
    1450         debuglocal(9, "NdpForceDelete in [%p]\n", pConn);
    1451 
    1452         dircache_invalidate(szFile, pRes->pdc, 1);
     1484        debuglocal(pRes, 9, "NdpForceDelete in [%p]\n", pConn);
     1485
     1486        dircache_invalidate(szFile, pRes, 1);
    14531487
    14541488        do {
     
    14571491              break;
    14581492
    1459            rc = smbwrp_unlink(pConn->cli, path);
     1493           rc = smbwrp_unlink(pRes, pConn->cli, path);
    14601494        } while (0);
    14611495
    1462         debuglocal(9, "NdpForceDelete <%s> (%s) %d\n", szFile, path, rc);
     1496        debuglocal(pRes, 9, "NdpForceDelete <%s> (%s) %d\n", szFile, path, rc);
    14631497
    14641498        LEAVE();
     
    14771511        ENTER();
    14781512
    1479         debuglocal(9, "NdpCreateDir in [%p]\n", pConn);
    1480 
    1481         dircache_invalidate(szDirName, pRes->pdc, 1);
     1513        debuglocal(pRes, 9, "NdpCreateDir in [%p]\n", pConn);
     1514
     1515        dircache_invalidate(szDirName, pRes, 1);
    14821516
    14831517        do {
     
    14861520              break;
    14871521
    1488            rc = smbwrp_mkdir(pConn->cli, path);
     1522           rc = smbwrp_mkdir(pRes, pConn->cli, path);
    14891523        } while (0);
    14901524
     
    14921526
    14931527        if (path && pRes->easupport)
    1494            rcEASet = helperEASet(pConn->cli, pFEAList, path);
    1495 
    1496         debuglocal(9, "NdpCreateDir <%s> (%s) rc=%d, EASupport=%s rc=%d\n", szDirName, path, rc, pRes->easupport?"yes":"no", rcEASet);
     1528           rcEASet = helperEASet(pRes, pConn->cli, pFEAList, path);
     1529
     1530        debuglocal(pRes, 9, "NdpCreateDir <%s> (%s) rc=%d, EASupport=%s rc=%d\n", szDirName, path, rc, pRes->easupport?"yes":"no", rcEASet);
    14971531
    14981532        return rc;
     
    15091543        ENTER();
    15101544
    1511         debuglocal(9, "NdpDeleteDir in [%p]\n", pConn);
    1512 
    1513         dircache_invalidate(szDir, pRes->pdc, 1);
     1545        debuglocal(pRes, 9, "NdpDeleteDir in [%p]\n", pConn);
     1546
     1547        dircache_invalidate(szDir, pRes, 1);
    15141548
    15151549        do {
     
    15181552              break;
    15191553
    1520            rc = smbwrp_rmdir(pConn->cli, path);
     1554           rc = smbwrp_rmdir(pRes, pConn->cli, path);
    15211555        } while (0);
    15221556
    1523         debuglocal(9, "NdpDeleteDir <%s> (%s) %d\n", szDir, path, rc);
     1557        debuglocal(pRes, 9, "NdpDeleteDir <%s> (%s) %d\n", szDir, path, rc);
    15241558
    15251559        LEAVE();
     
    15391573        ENTER();
    15401574
    1541         debuglocal(9, "NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
    1542 
    1543         dircache_invalidate(szSrc, pRes->pdc, 1);
    1544         dircache_invalidate(szDst, pRes->pdc, 1);
     1575        debuglocal(pRes, 9, "NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
     1576
     1577        dircache_invalidate(szSrc, pRes, 1);
     1578        dircache_invalidate(szDst, pRes, 1);
    15451579
    15461580        do
     
    15651599              p = szDst + l1 - l2 + 1;
    15661600           }
    1567            rc = smbwrp_rename(pConn->cli, src, p);
     1601           rc = smbwrp_rename(pRes, pConn->cli, src, p);
    15681602        } while (0);
    15691603
    1570         debuglocal(9, "NdpMove <%s> -> <%s> (%s) %d\n", szSrc, szDst, src, rc);
     1604        debuglocal(pRes, 9, "NdpMove <%s> -> <%s> (%s) %d\n", szSrc, szDst, src, rc);
    15711605
    15721606        LEAVE();
     
    15761610int APIENTRY NdpMove2 (HCONNECTION conn, HRESOURCE resDst, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc)
    15771611{
    1578         debuglocal(9, "NdpMove2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_WRITE_PROTECT);
     1612        Connection *pConn = (Connection *)conn;
     1613        Resource *pRes = pConn->pRes;
     1614        debuglocal(pRes, 9, "NdpMove2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_WRITE_PROTECT);
    15791615        return ERROR_WRITE_PROTECT;
    15801616}
     
    16001636        ENTER();
    16011637
    1602         debuglocal(9, "smbopen in [%p] %d\n", pConn, pConn->file.fd);
     1638        debuglocal(pRes, 9, "smbopen in [%p] %d\n", pConn, pConn->file.fd);
    16031639
    16041640        if (flags & O_CREAT)
    1605            dircache_invalidate(szFileName, pRes->pdc, 1);
     1641           dircache_invalidate(szFileName, pRes, 1);
    16061642
    16071643        do {
     
    16371673           pConn->file.openattr = ulAttribute & 0x37;
    16381674           pConn->file.denymode = (ulOpenMode & 0x70) >> 4;
    1639            rc = smbwrp_open(pConn->cli, &pConn->file);
     1675           rc = smbwrp_open(pConn->pRes, pConn->cli, &pConn->file);
    16401676        } while (0);
    16411677
    1642         debuglocal(9, "smbopen <%s> (%s) %08x %08x %08x %d. file = %d\n", szFileName, path, flags, ulOpenMode, ulAttribute, rc, pConn->file.fd);
     1678        debuglocal(pRes, 9, "smbopen <%s> (%s) %08x %08x %08x %d. file = %d\n", szFileName, path, flags, ulOpenMode, ulAttribute, rc, pConn->file.fd);
    16431679        if (!rc && pFEAList)
    16441680        {
    16451681           int rc1 = NdpFileEASet((HCONNECTION)pConn, (NDFILEHANDLE)0, pFEAList);
    1646            debuglocal(9, "smbopen NdpFileEASet %d. pFEAList->cbList %d\n", rc1, pFEAList->cbList);
     1682           debuglocal(pRes, 9, "smbopen NdpFileEASet %d. pFEAList->cbList %d\n", rc1, pFEAList->cbList);
    16471683        }
    16481684
     
    16901726        ENTER();
    16911727
    1692         debuglocal(9, "NdpSetFileAttribute in [%p]\n", pConn);
     1728        debuglocal(pRes, 9, "NdpSetFileAttribute in [%p]\n", pConn);
    16931729        do {
    16941730           rc = pathparser(pRes, pConn, szFileName, path);
     
    16991735           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    17001736           finfo.attr = usAttr & 0x37;
    1701            rc = smbwrp_setattr(pConn->cli, &finfo);
     1737           rc = smbwrp_setattr(pRes, pConn->cli, &finfo);
    17021738        } while (0);
    17031739
    1704         debuglocal(9, "NdpSetFileAttribute <%s> (%s) %04x %d\n", szFileName, path, usAttr, rc);
     1740        debuglocal(pRes, 9, "NdpSetFileAttribute <%s> (%s) %04x %d\n", szFileName, path, usAttr, rc);
    17051741
    17061742        LEAVE();
     
    17101746int APIENTRY NdpFlush (HRESOURCE resource)
    17111747{
    1712         debuglocal(9, "NdpFlush %d\n", ERROR_NOT_SUPPORTED);
     1748        Resource *pRes = (Resource *)resource;
     1749        debuglocal(pRes, 9, "NdpFlush %d\n", ERROR_NOT_SUPPORTED);
    17131750        return ERROR_NOT_SUPPORTED;
    17141751}
     
    17221759int APIENTRY NdpIOCTL (int type, HRESOURCE resource, char *path, int function, void *in, ULONG insize, PULONG poutlen)
    17231760{
     1761        Resource *pRes = (Resource *)resource;
    17241762        if (function == ND_PL_INIT_THREAD)
    17251763        {
    17261764           smbwrp_initthread();
    1727            debuglocal(9, "NdpIOCTL init thread\n");
     1765           debuglocal(pRes, 9, "NdpIOCTL init thread\n");
    17281766           return NO_ERROR;
    17291767        }
    17301768
    1731         debuglocal(9, "NdpIOCTL <%s> %d\n", path, function);
     1769        debuglocal(pRes, 9, "NdpIOCTL <%s> %d\n", path, function);
    17321770
    17331771        if (in && insize > 4096)
     
    17531791        ENTER();
    17541792
    1755         debuglocal(9, "NdpFileQueryInfo in [%p]\n", pConn);
     1793        debuglocal(pRes, 9, "NdpFileQueryInfo in [%p]\n", pConn);
    17561794        do {
    17571795           if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    17611799           }
    17621800           strncpy(finfo.fname, pConn->file.fname, sizeof(finfo.fname) - 1);
    1763            rc = smbwrp_fgetattr(pConn->cli, &pConn->file, &finfo);
     1801           rc = smbwrp_fgetattr(pRes, pConn->cli, &pConn->file, &finfo);
    17641802           if (!rc)
    17651803           {
     
    17691807        } while (0);
    17701808
    1771         debuglocal(9, "NdpFileQueryInfo <%s> %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, rc);
     1809        debuglocal(pRes, 9, "NdpFileQueryInfo <%s> %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, rc);
    17721810
    17731811        LEAVE();
     
    17891827           return ERROR_EAS_NOT_SUPPORTED;
    17901828
    1791         debuglocal(9, "NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
     1829        debuglocal(pRes, 9, "NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    17921830
    17931831        char *pchBuffer = (char *)malloc(cbBuffer);
     
    18031841              break;
    18041842           }
    1805            rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer);
     1843           rc = smbwrp_flistea(pRes, pConn->cli, &pConn->file, pchBuffer, cbBuffer);
    18061844           pFEASrc = (FEALIST *)pchBuffer;
    18071845           if (rc)
     
    18221860           }
    18231861           else
    1824               rc = buildFEALIST(pFEASrc, pGEAList, pFEAList);
     1862              rc = buildFEALIST(pRes, pFEASrc, pGEAList, pFEAList);
    18251863
    18261864        } while (0);
    18271865
    18281866        free(pchBuffer);
    1829         debuglocal(9, "NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
     1867        debuglocal(pRes, 9, "NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
    18301868
    18311869        LEAVE();
     
    18401878        unsigned long action;
    18411879
    1842         debuglocal(9, "NdpFileEASet in [%p]\n", pConn);
     1880        debuglocal(pRes, 9, "NdpFileEASet in [%p]\n", pConn);
    18431881
    18441882        if (!pFEAList || pFEAList->cbList <= sizeof(long))
     
    18631901           while (done < pFEAList->cbList)
    18641902           {
    1865               rc = smbwrp_fsetea(pConn->cli, &pConn->file, (char *)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
     1903              rc = smbwrp_fsetea(pRes, pConn->cli, &pConn->file, (char *)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
    18661904              if (rc)
    18671905                 break;
     
    18731911        } while (0);
    18741912
    1875         debuglocal(9, "NdpFileEASet %d\n", rc);
     1913        debuglocal(pRes, 9, "NdpFileEASet %d\n", rc);
    18761914
    18771915        LEAVE();
     
    18951933           return ERROR_EAS_NOT_SUPPORTED;
    18961934
    1897         debuglocal(9, "NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
     1935        debuglocal(pRes, 9, "NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    18981936
    18991937        char *pchBuffer = (char *)malloc(cbBuffer);
     
    19091947              break;
    19101948           }
    1911            rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer);
     1949           rc = smbwrp_flistea(pRes, pConn->cli, &pConn->file, pchBuffer, cbBuffer);
    19121950           pFEAList = (FEALIST*)pchBuffer;
    19131951           if (rc)
     
    19291967
    19301968        free(pchBuffer);
    1931         debuglocal(9, "NdpFileEASize %d %d\n", *pulEASize, rc);
     1969        debuglocal(pRes, 9, "NdpFileEASize %d %d\n", *pulEASize, rc);
    19321970
    19331971        LEAVE();
     
    19441982        ENTER();
    19451983
    1946         debuglocal(9, "NdpFileSetInfo in [%p]\n", pConn);
     1984        debuglocal(pRes, 9, "NdpFileSetInfo in [%p]\n", pConn);
    19471985
    19481986        // delete the dir cache
    1949         dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
     1987        dircache_invalidate(pConn->file.fullname, pRes, 1);
    19501988
    19511989        do {
     
    19581996           // deferred setinfo - on closing the file
    19591997           pConn->file.openattr = attrFile;
    1960            fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime));
    1961            fsphDosDateToUnixTime(pfi->stat.fdateCreation, pfi->stat.ftimeCreation, &(pConn->file.ctime));
     1998           fsphDosDateToUnixTime(pRes, pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime));
     1999           fsphDosDateToUnixTime(pRes, pfi->stat.fdateCreation, pfi->stat.ftimeCreation, &(pConn->file.ctime));
    19622000           pConn->file.updatetime = 2;
    1963            debuglocal(9, "NdpFileSetInfo mtime %d\n", pConn->file.mtime);
     2001           debuglocal(pRes, 9, "NdpFileSetInfo mtime %d\n", pConn->file.mtime);
    19642002        } while (0);
    19652003
    1966         debuglocal(9, "NdpFileSetInfo <%s> %08x %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc);
     2004        debuglocal(pRes, 9, "NdpFileSetInfo <%s> %08x %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc);
    19672005
    19682006        LEAVE();
     
    19792017        ENTER();
    19802018
    1981         debuglocal(9, "NdpFileSetFilePtrL in [%p]\n", pConn);
     2019        debuglocal(pRes, 9, "NdpFileSetFilePtrL in [%p]\n", pConn);
    19822020
    19832021        do {
     
    19882026           }
    19892027
    1990            rc = smbwrp_lseek(pConn->cli, &pConn->file, ulMethod, llOffset);
     2028           rc = smbwrp_lseek(pRes, pConn->cli, &pConn->file, ulMethod, llOffset);
    19912029           if (!rc)
    19922030              *pllActual = pConn->file.offset;
     
    19942032        } while (0);
    19952033
    1996         debuglocal(9, "NdpFileSetFilePtrL <%s> %lld %lu %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llOffset, ulMethod, *pllActual, rc);
     2034        debuglocal(pRes, 9, "NdpFileSetFilePtrL <%s> %lld %lu %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llOffset, ulMethod, *pllActual, rc);
    19972035
    19982036        LEAVE();
     
    20022040int APIENTRY NdpFileSetFilePtr (HCONNECTION conn, NDFILEHANDLE handle, LONG lOffset, ULONG ulMethod, ULONG *pulActual)
    20032041{
     2042        Connection *pConn = (Connection *)conn;
    20042043        LONGLONG llActual;
    20052044        int rc = NdpFileSetFilePtrL(conn, handle, lOffset, ulMethod, &llActual);
    20062045        *pulActual = llActual & 0xFFFFFFFF;
    2007         debuglocal(9, "NdpFileSetFilePtr %ld %lu %ld %d\n", lOffset, ulMethod, *pulActual, rc);
     2046        debuglocal(pConn->pRes, 9, "NdpFileSetFilePtr %ld %lu %ld %d\n", lOffset, ulMethod, *pulActual, rc);
    20082047        return rc;
    20092048}
     
    20182057        ENTER();
    20192058
    2020         debuglocal(9, "NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
     2059        debuglocal(pRes, 9, "NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
    20212060
    20222061        do {
     
    20272066           }
    20282067
    2029            rc = smbwrp_close(pConn->cli, &pConn->file);
     2068           rc = smbwrp_close(pRes, pConn->cli, &pConn->file);
    20302069
    20312070        } while (0);
    20322071
    2033         debuglocal(9, "NdpFileClose %d %d\n", pConn->file.fd, rc);
     2072        debuglocal(pRes, 9, "NdpFileClose %d %d\n", pConn->file.fd, rc);
    20342073        pConn->file.fd = -1;
    20352074
     
    20402079int APIENTRY NdpFileCommit (HCONNECTION conn, NDFILEHANDLE handle)
    20412080{
    2042         debuglocal(9, "NdpFileCommit %d\n", NO_ERROR);
     2081        Connection *pConn = (Connection *)conn;
     2082        debuglocal(pConn->pRes, 9, "NdpFileCommit %d\n", NO_ERROR);
    20432083        return NO_ERROR;
    20442084}
     
    20462086int APIENTRY NdpFileNewSize (HCONNECTION conn, NDFILEHANDLE handle, ULONG ulLen)
    20472087{
     2088        Connection *pConn = (Connection *)conn;
    20482089        int rc = NdpFileNewSizeL(conn, handle, ulLen);
    2049         debuglocal(9, "NdpFileNewSize %ld %d\n", ulLen, rc);
     2090        debuglocal(pConn->pRes, 9, "NdpFileNewSize %ld %d\n", ulLen, rc);
    20502091        return rc;
    20512092}
     
    20602101        ENTER();
    20612102
    2062         debuglocal(9, "NdpFileNewSizeL in [%p]\n", pConn);
     2103        debuglocal(pRes, 9, "NdpFileNewSizeL in [%p]\n", pConn);
    20632104
    20642105        do {
     
    20692110           }
    20702111
    2071            rc = smbwrp_setfilesize(pConn->cli, &pConn->file, llLen);
     2112           rc = smbwrp_setfilesize(pRes, pConn->cli, &pConn->file, llLen);
    20722113
    20732114        } while (0);
    20742115
    2075         debuglocal(9, "NdpFileNewSizeL <%s> %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llLen, rc);
     2116        debuglocal(pRes, 9, "NdpFileNewSizeL <%s> %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llLen, rc);
    20762117
    20772118        LEAVE();
     
    20932134        ENTER();
    20942135
    2095         debuglocal(9, "NdpFileRead in [%p]\n", pConn);
     2136        debuglocal(pRes, 9, "NdpFileRead in [%p]\n", pConn);
    20962137
    20972138        do {
     
    21062147              ULONG ulActual;
    21072148              ULONG ulToRead = ulRead - ulReadCompleted;
    2108               debuglocal(9, "NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     2149              debuglocal(pRes, 9, "NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
    21092150
    21102151              if (ulToRead > NDPSMB_READ_MAX_SIZE)
    21112152              ulToRead = NDPSMB_READ_MAX_SIZE;
    21122153
    2113               rc = smbwrp_read(pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
     2154              rc = smbwrp_read(pRes, pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
    21142155              if (ulActual == 0 || rc != NO_ERROR)
    21152156                 break;
     
    21252166           *pulActual = ulReadCompleted;
    21262167
    2127         debuglocal(9, "NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
     2168        debuglocal(pRes, 9, "NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
    21282169
    21292170        LEAVE();
     
    21422183        ENTER();
    21432184
    2144         debuglocal(9, "NdpFileWrite in [%p]\n", pConn);
     2185        debuglocal(pRes, 9, "NdpFileWrite in [%p]\n", pConn);
    21452186
    21462187        /*
     
    21512192         * a new function needs to be done to update only one file in the cache
    21522193        */
    2153         dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
     2194        dircache_invalidate(pConn->file.fullname, pRes, 1);
    21542195
    21552196        do {
     
    21592200              break;
    21602201           }
    2161            rc = smbwrp_write(pConn->cli, &pConn->file, pBuffer, ulWrite, pulActual);
     2202           rc = smbwrp_write(pRes, pConn->cli, &pConn->file, pBuffer, ulWrite, pulActual);
    21622203
    21632204        } while (0);
    21642205
    2165         debuglocal(9, "NdpFileWrite <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulWrite, *pulActual, rc);
    2166 
    2167         LEAVE();
    2168         return rc;
    2169 }
     2206        debuglocal(pRes, 9, "NdpFileWrite <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulWrite, *pulActual, rc);
     2207
     2208        LEAVE();
     2209        return rc;
     2210}
Note: See TracChangeset for help on using the changeset viewer.