Changeset 507


Ignore:
Timestamp:
Dec 28, 2010, 10:47:09 AM (15 years ago)
Author:
Herwig Bauernfeind
Message:

Vitalis fix for maximum read size in NdpFileRead()

Location:
branches/client-2.0/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/client-2.0/src/debug.c

    r497 r507  
    3030#include <sys/stat.h>
    3131
    32 int debuglevel = 9; // we set it to 9, so we get all messages
     32int debuglevel = 1; // we set it to 9, so we get all messages
    3333char logfile[_MAX_PATH +1]  = {0};
    3434char debugfile[_MAX_PATH +1] = {0};
     
    4343BOOL writeLog()
    4444{
    45         return do_logging;
     45        return do_logging;
    4646}
    4747
    4848void debuglocal(int level, const char * fmt, ...)
    4949{
    50         FILE *f=NULL;
    51         struct stat filestat;
     50        FILE *f=NULL;
     51        struct stat filestat;
    5252
    53         // do we have to log at all
    54         if (!debuglvl(level))
     53        // do we have to log at all
     54/*      if (!debuglvl(level))
    5555        {
    5656                return;
    57         }
     57        } */
    5858
    59         // if the file ndpsmb.dbg is around we write a logfile
    60         if (!debugfile[0])
    61         {
    62            strncpy(debugfile, getenv("ETC"), 2);
    63            strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1);
    64            strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1);
    65         } /* endif */
    66        
    67         if (stat(debugfile, &filestat) !=0)
    68            return;
     59        // if the file ndpsmb.dbg is around we write a logfile
     60        if (!debugfile[0])
     61        {
     62                strncpy(debugfile, getenv("ETC"), 2);
     63                strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1);
     64                strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1);
     65        } /* endif */
     66       
     67        if (stat(debugfile, &filestat) !=0)
     68                return;
    6969
    70         //we create the logfile variable only once
    71         if (!logfile[0])
    72         {
    73                 char *env = getenv("LOGFILES");
    74                 if (env != NULL)
    75                 {
    76                    strncpy(logfile, env, sizeof(logfile) -1);
    77                    strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1);
    78                    strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1);
    79                 }
    80                 else
    81                 {
    82                    strncpy(logfile, logfilename, sizeof(logfile) -1);
    83                 }
    84                 // set the samba logging stuff
    85                 do_logging = TRUE;
    86         } /* endif */
     70        //we create the logfile variable only once
     71        if (!logfile[0])
     72        {
     73                char *env = getenv("LOGFILES");
     74                if (env != NULL)
     75                {
     76                        strncpy(logfile, env, sizeof(logfile) -1);
     77                        strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1);
     78                        strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1);
     79                }
     80                else
     81                {
     82                        strncpy(logfile, logfilename, sizeof(logfile) -1);
     83                }
     84                // set the samba logging stuff
     85                do_logging = TRUE;
     86        } /* endif */
    8787
    8888        do
  • branches/client-2.0/src/ndpsmb.c

    r497 r507  
    904904
    905905        *pconn = (HCONNECTION)pConn;
    906         debuglocal(9,"NdpCreateConnection %d\n", rc);
     906        debuglocal(9,"NdpCreateConnection [%p] %d\n", pConn, rc);
    907907        return rc;
    908908}
     
    916916        int rc;
    917917
    918         debuglocal(9,"NdpFreeConnection in\n");
     918        debuglocal(9,"NdpFreeConnection in [%p]\n", pConn);
    919919        if (pConn->file.fd >= 0)
    920920        {
     
    958958        int retry = 0;
    959959
    960                 debuglocal(9,"NdpQueryPathInfo in <%s>, retry = %d\n", szPath, retry);
     960                debuglocal(9,"NdpQueryPathInfo in [%p] <%s>, retry = %d\n", pConn, szPath, retry);
    961961       
    962962                // is wildcard is specified, we suppose parent dir exist, so exit immediately
     
    10751075        char * p;
    10761076
    1077         debug_printf("NdpFindStart in\n");
     1077        debug_printf("NdpFindStart in [%p]\n", pConn);
    10781078
    10791079                StrNCpy(dir, szPath, sizeof(dir) - 1);
     
    11861186        smbwrp_fileinfo finfo;
    11871187
    1188         debug_printf("NdpSetPathInfo in FIXME\n");
     1188        debug_printf("NdpSetPathInfo in FIXME [%p]\n", pConn);
    11891189
    11901190        do {
     
    12961296        path = finfo->fname;
    12971297
    1298         debuglocal(9,"NdpEAQuery in <%s> %08x %d\n", path, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1298        debuglocal(9,"NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    12991299
    13001300        do {
     
    13421342        smbwrp_fileinfo *finfo;
    13431343
    1344         debuglocal(9,"NdpEASet in\n");
     1344        debuglocal(9,"NdpEASet in [%p]\n", pConn);
    13451345
    13461346        if (!pfi || !pfi->pszName || !pFEAList || pFEAList->cbList <= sizeof(long))
     
    14221422        }
    14231423
    1424         debuglocal(9,"NdpEASize in <%s> \n", path);
     1424        debuglocal(9,"NdpEASize in [%p] <%s>\n", pConn, path);
    14251425
    14261426        do {
     
    14621462        char path[CCHMAXPATH+1] = {0};
    14631463       
    1464         debuglocal(9,"NdpSetCurrentDir in\n");
     1464        debuglocal(9,"NdpSetCurrentDir in [%p]\n", pConn);
    14651465
    14661466        do {
     
    14981498        char path[CCHMAXPATH+1] = {0};
    14991499
    1500         debuglocal(9,"NdpForceDelete in\n");
     1500        debuglocal(9,"NdpForceDelete in [%p]\n", pConn);
    15011501
    15021502        dircache_invalidate(szFile, pRes->pdc, 1);
     
    15241524        char path[CCHMAXPATH+1] = {0};
    15251525
    1526         debuglocal(9,"NdpCreateDir in\n");
     1526        debuglocal(9,"NdpCreateDir in [%p]\n", pConn);
    15271527
    15281528        dircache_invalidate(szDirName, pRes->pdc, 1);
     
    15501550        char path[CCHMAXPATH+1] = {0};
    15511551
    1552         debuglocal(9,"NdpDeleteDir in\n");
     1552        debuglocal(9,"NdpDeleteDir in [%p]\n", pConn);
    15531553
    15541554        dircache_invalidate(szDir, pRes->pdc, 1);
     
    15781578        char * p = szDst;
    15791579
    1580         debuglocal(9,"NdpMove in from <%s> to <%s>\n", szSrc, szDst);
     1580        debuglocal(9,"NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
    15811581
    15821582        dircache_invalidate(szSrc, pRes->pdc, 1);
     
    16341634        char path[CCHMAXPATH+1] = {0};
    16351635
    1636         debuglocal(9,"smbopen in %d\n", pConn->file.fd);
     1636        debuglocal(9,"smbopen in [%p] %d\n", pConn, pConn->file.fd);
    16371637
    16381638        if (flags & O_CREAT)
     
    17151715        char path[CCHMAXPATH+1] = {0};
    17161716
    1717         debuglocal(9,"NdpSetFileAttribute in\n");
     1717        debuglocal(9,"NdpSetFileAttribute in [%p]\n", pConn);
    17181718        do {
    17191719                rc = pathparser(pRes, pConn, szFileName, path);
     
    17631763        smbwrp_fileinfo finfo;
    17641764
    1765         debug_printf("NdpFileQueryInfo in\n");
     1765        debug_printf("NdpFileQueryInfo in [%p]\n", pConn);
    17661766        do {
    17671767                if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    18011801        }
    18021802
    1803         debuglocal(9,"NdpFileEAQuery in <%s>/%d pGEAList=%08x\n", pConn->file.fname, pConn->file.fd, pGEAList);
     1803        debuglocal(9,"NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    18041804        do {
    18051805                if (pConn->file.fd < 0)
     
    18481848        unsigned long action;
    18491849
    1850         debuglocal(9,"NdpFileEASet in\n");
     1850        debuglocal(9,"NdpFileEASet in [%p]\n", pConn);
    18511851
    18521852        if (!pFEAList || pFEAList->cbList <= sizeof(long))
     
    19061906        }
    19071907
    1908         debuglocal(9,"NdpFileEASize in <%s>/%d \n", pConn->file.fname, pConn->file.fd);
     1908        debuglocal(9,"NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    19091909        do {
    19101910                if (pConn->file.fd < 0)
     
    19491949        unsigned long action, attrFile;
    19501950
    1951         debug_printf("NdpFileSetInfo in\n");
     1951        debug_printf("NdpFileSetInfo in [%p]\n", pConn);
    19521952        do {
    19531953                if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    19741974        unsigned long action;
    19751975
    1976         debuglocal(9,"NdpFileSetFilePtrl in\n");
     1976        debuglocal(9,"NdpFileSetFilePtrl in [%p]\n", pConn);
    19771977
    19781978        do {
     
    20092009        unsigned long action;
    20102010
    2011         debuglocal(9,"NdpFileClose in %d <%s>\n", pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
     2011        debuglocal(9,"NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
    20122012
    20132013        do {
     
    20482048        unsigned long action;
    20492049
    2050         debuglocal(9,"NdpFileNewSizeL in\n");
     2050        debuglocal(9,"NdpFileNewSizeL in [%p]\n", pConn);
    20512051
    20522052        do {
     
    20652065}
    20662066
     2067#define NDPSMB_READ_MAX_SIZE (65536 - 4096)
     2068
    20672069int APIENTRY NdpFileRead (HCONNECTION conn, NDFILEHANDLE handle, void *pBuffer, ULONG ulRead, ULONG *pulActual)
    20682070{
     
    20732075        unsigned long onedone;
    20742076        unsigned long action;
    2075 
    2076         debuglocal(9,"NdpFileRead in\n");
     2077        ULONG ulReadCompleted = 0;
     2078
     2079        debuglocal(9,"NdpFileRead in [%p]\n", pConn);
    20772080
    20782081        do {
     
    20822085                        break;
    20832086                }
    2084                 rc = smbwrp_read(pConn->cli, &pConn->file, pBuffer, ulRead, pulActual);
     2087
     2088                while (ulReadCompleted < ulRead)
     2089                {
     2090                        ULONG ulActual;
     2091                        ULONG ulToRead = ulRead - ulReadCompleted;
     2092                        debuglocal(9,"NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     2093                        if (ulToRead > NDPSMB_READ_MAX_SIZE)
     2094                        {
     2095                                ulToRead = NDPSMB_READ_MAX_SIZE;
     2096                        }
     2097                        rc = smbwrp_read(pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
     2098                        if (ulActual == 0 || rc != NO_ERROR)
     2099                        {
     2100                                break;
     2101                        }
     2102                        ulReadCompleted += ulActual;
     2103                }
     2104
    20852105                //*pulActual = ulRead;
    20862106                //DosSleep(0);
    20872107
    20882108        } while (0);
     2109
     2110        if (ulReadCompleted > 0)
     2111        {
     2112                rc = NO_ERROR; /* Still were able to read some data. */
     2113        }
     2114
     2115        if (rc == NO_ERROR)
     2116        {
     2117                *pulActual = ulReadCompleted;
     2118        }
     2119
    20892120        debuglocal(9,"NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
    20902121
     
    21012132        unsigned long action;
    21022133
    2103         debuglocal(9,"NdpFileWrite in\n");
     2134        debuglocal(9,"NdpFileWrite in [%p]\n", pConn);
    21042135
    21052136        do {
Note: See TracChangeset for help on using the changeset viewer.