Changeset 533 for trunk/client
- Timestamp:
- Jan 26, 2011, 3:31:18 PM (15 years ago)
- Location:
- trunk/client/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/src/debug.c
r508 r533 32 32 33 33 int debuglevel = 9; // we set it to 9, so we get all messages 34 char logfile[_MAX_PATH +1] = {0};35 char debugfile[_MAX_PATH +1] = {0};34 char logfile[_MAX_PATH +1]; 35 char debugfile[_MAX_PATH +1]; 36 36 char logfilename[] = "log.ndpsmb"; 37 BOOL do_logging = FALSE; 38 BOOL firstLogLine = TRUE; 37 BOOL do_logging; 38 BOOL firstLogLine; 39 HMTX logMutex; 40 char nameMutex[] = "\\SEM32\\NDPSMB"; 39 41 40 42 int debuglvl(int level) … … 48 50 } 49 51 52 void debugInit() 53 { 54 *logfile = '\0'; 55 *debugfile = '\0'; 56 do_logging = FALSE; 57 firstLogLine = TRUE; 58 logMutex = NULLHANDLE; 59 struct stat filestat; 60 APIRET rc = NO_ERROR; 61 62 // create the debugfile name 63 strncat(debugfile, getenv("ETC"), 2); 64 strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1); 65 strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1); 66 67 // is the file around? if not we have no debug 68 if (stat(debugfile, &filestat) !=0) 69 return; 70 71 //create the logfile variable 72 char *env = getenv("LOGFILES"); 73 if (env != NULL) 74 { 75 strncat(logfile, env, sizeof(logfile) -1); 76 strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1); 77 strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1); 78 } 79 else 80 { 81 strncat(logfile, logfilename, sizeof(logfile) -1); 82 } 83 // set the samba logging stuff 84 do_logging = TRUE; 85 86 // now we create a sem, so that logging from different threads works 87 rc = DosCreateMutexSem(nameMutex, &logMutex, 0, FALSE); 88 if (rc == ERROR_DUPLICATE_NAME) 89 { 90 rc = DosOpenMutexSem(nameMutex, &logMutex); 91 } 92 93 return; 94 } 95 96 void debugDelete() 97 { 98 DosCloseMutexSem(logMutex); 99 return; 100 } 101 50 102 void debuglocal(int level, const char * fmt, ...) 51 103 { 52 104 FILE *f=NULL; 53 struct stat filestat;54 105 55 // do we have to log at all (not needed atm)56 /* if (!debuglvl(level))106 // do we have to log at all 107 if (!do_logging) 57 108 { 58 109 return; 59 } */110 } 60 111 61 // if the file ndpsmb.dbg is around we write a logfile62 if ( !debugfile[0])112 // if the sem is created we request it 113 if (logMutex) 63 114 { 64 strncpy(debugfile, getenv("ETC"), 2); 65 strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1); 66 strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1); 67 } /* endif */ 68 69 if (stat(debugfile, &filestat) !=0) 70 return; 71 72 //we create the logfile variable only once 73 if (!logfile[0]) 74 { 75 char *env = getenv("LOGFILES"); 76 if (env != NULL) 77 { 78 strncpy(logfile, env, sizeof(logfile) -1); 79 strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1); 80 strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1); 81 } 82 else 83 { 84 strncpy(logfile, logfilename, sizeof(logfile) -1); 85 } 86 // set the samba logging stuff 87 do_logging = TRUE; 88 } /* endif */ 115 DosRequestMutexSem(logMutex, (ULONG) SEM_INDEFINITE_WAIT); 116 } 89 117 90 118 do … … 121 149 if (logfile) 122 150 { 123 fclose(f); 151 // fflush(f); 152 fclose(f); 124 153 } 125 154 } 126 155 while (0); 156 157 // if the sem is created we release it 158 if (logMutex) 159 { 160 DosReleaseMutexSem(logMutex); 161 } 162 163 return; 127 164 } -
trunk/client/src/ndpsmb.c
r531 r533 150 150 ifL = 1; 151 151 } 152 debugInit(); 152 153 debuglocal(9,"Working with %s bit fileio NDFS\n", ifL ? "64" : "32"); 153 154 return NO_ERROR; … … 157 158 int APIENTRY NdpPluginFree (void) 158 159 { 160 debugDelete(); 159 161 return NO_ERROR; 160 162 } … … 982 984 { 983 985 rc = (finfo.attr & FILE_DIRECTORY) !=0 ? 984 ERROR_ PATH_NOT_FOUND:985 ERROR_ INVALID_PARAMETER;986 ERROR_FILE_NOT_FOUND: 987 ERROR_PATH_NOT_FOUND; 986 988 } 987 989 else if (rc != ERROR_REM_NOT_LIST) … … 1217 1219 NDDATABUF fdata = {0}; 1218 1220 smbwrp_fileinfo *finfo; 1219 c har pBuffer[64*1024];1221 const int cbBuffer = 64*1024; 1220 1222 1221 1223 if (!pfi || !pfi->pszName || !pFEAList) … … 1239 1241 debuglocal(9,"NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0); 1240 1242 1243 char *pchBuffer = (char *)malloc(cbBuffer); 1244 if (!pchBuffer) 1245 return ERROR_NOT_ENOUGH_MEMORY; 1246 1241 1247 do { 1242 rc = smbwrp_listea( pConn->cli, path, p Buffer, sizeof( pBuffer));1243 pFEASrc = (FEALIST*) p Buffer;1248 rc = smbwrp_listea( pConn->cli, path, pchBuffer, cbBuffer); 1249 pFEASrc = (FEALIST*) pchBuffer; 1244 1250 if (rc) 1245 1251 { … … 1268 1274 } 1269 1275 } while (0); 1276 free(pchBuffer); 1270 1277 debuglocal(9,"NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList); 1271 1278 … … 1334 1341 NDDATABUF fdata = {0}; 1335 1342 smbwrp_fileinfo *finfo; 1336 c har pBuffer[64*1024];1343 const int cbBuffer = 64*1024; 1337 1344 int easize; 1338 1345 … … 1352 1359 return ERROR_EAS_NOT_SUPPORTED; 1353 1360 } 1361 1354 1362 finfo = (smbwrp_fileinfo *)fdata.pData; 1355 1363 easize = finfo->easize; … … 1365 1373 debuglocal(9,"NdpEASize in [%p] <%s> \n", pConn, path); 1366 1374 1375 char *pchBuffer = (char *)malloc(cbBuffer); 1376 if (!pchBuffer) 1377 return ERROR_NOT_ENOUGH_MEMORY; 1378 1367 1379 do { 1368 rc = smbwrp_listea(pConn->cli, path, p Buffer, sizeof( pBuffer));1369 pfealist = (FEALIST*)p Buffer;1380 rc = smbwrp_listea(pConn->cli, path, pchBuffer, cbBuffer); 1381 pfealist = (FEALIST*)pchBuffer; 1370 1382 if (rc) 1371 1383 { … … 1390 1402 *pulEASize = pfealist->cbList; 1391 1403 } while (0); 1404 free(pchBuffer); 1392 1405 debuglocal(9,"NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc); 1393 1406 … … 1740 1753 int rc = 0; 1741 1754 unsigned long action; 1742 c har pBuffer[64*1024];1755 const int cbBuffer = 64*1024; 1743 1756 FEALIST * pFEASrc; 1744 1757 … … 1753 1766 1754 1767 debuglocal(9,"NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList); 1768 1769 char *pchBuffer = (char *)malloc(cbBuffer); 1770 if (!pchBuffer) 1771 return ERROR_NOT_ENOUGH_MEMORY; 1772 1755 1773 do { 1756 1774 if (pConn->file.fd < 0) … … 1759 1777 break; 1760 1778 } 1761 rc = smbwrp_flistea(pConn->cli, &pConn->file, p Buffer, sizeof( pBuffer));1762 pFEASrc = (FEALIST *) pBuffer;1779 rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer); 1780 pFEASrc = (FEALIST *)pchBuffer; 1763 1781 if (rc) 1764 1782 { … … 1787 1805 } 1788 1806 } while (0); 1807 free(pchBuffer); 1789 1808 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); 1790 1809 … … 1846 1865 char path[CCHMAXPATH+1] = {0}; 1847 1866 FEALIST * pFEAList; 1848 c har pBuffer[64*1024];1867 const int cbBuffer = 64*1024; 1849 1868 1850 1869 if (!pulEASize) … … 1858 1877 1859 1878 debuglocal(9,"NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd); 1879 1880 char *pchBuffer = (char *)malloc(cbBuffer); 1881 if (!pchBuffer) 1882 return ERROR_NOT_ENOUGH_MEMORY; 1883 1860 1884 do { 1861 1885 if (pConn->file.fd < 0) … … 1864 1888 break; 1865 1889 } 1866 rc = smbwrp_flistea(pConn->cli, &pConn->file, p Buffer, sizeof(pBuffer));1867 pFEAList = (FEALIST*) pBuffer;1890 rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer); 1891 pFEAList = (FEALIST*)pchBuffer; 1868 1892 if (rc) 1869 1893 { … … 1888 1912 *pulEASize = pFEAList->cbList; 1889 1913 } while (0); 1914 free(pchBuffer); 1890 1915 debuglocal(9,"NdpFileEASize %d %d\n", *pulEASize, rc); 1891 1916 -
trunk/client/src/smbwrp.c
r528 r533 1113 1113 } 1114 1114 1115 ZERO_STRUCTP(finfo); 1115 /* ZERO_STRUCTP(finfo); */ 1116 finfo->atime = 0; 1117 finfo->ctime = 0; 1118 finfo->mtime = 0; 1119 *finfo->fname = '\0'; 1116 1120 1117 1121 switch (level) { … … 1157 1161 p += ret; 1158 1162 finfo->easize = -1; 1159 strnc py(finfo->fname, fname, sizeof(finfo->fname) -1);1163 strncat(finfo->fname, fname, sizeof(finfo->fname) -1); 1160 1164 return PTR_DIFF(p, base); 1161 1165 … … 1185 1189 } 1186 1190 p += ret; 1187 strnc py(finfo->fname, fname, sizeof(finfo->fname) -1);1191 strncat(finfo->fname, fname, sizeof(finfo->fname) -1); 1188 1192 return PTR_DIFF(p, base) + 1; 1189 1193 … … 1246 1250 return pdata_end - base; 1247 1251 } 1248 strnc py(finfo->fname, fname, sizeof(finfo->fname) -1);1252 strncat(finfo->fname, fname, sizeof(finfo->fname) -1); 1249 1253 1250 1254 /* To be robust in the face of unicode conversion failures … … 1469 1473 &resume_key, &last_name_raw); 1470 1474 1475 debuglocal(9, "fname %s (remove me 1)\n", finfo.fname); 1471 1476 if (!finfo.fname) { 1472 1477 debuglocal(0,"Error: unable to parse name from info level %d\n", … … 1537 1542 p += _os2_interpret_long_filename(frame, cli, info_level, p, rdata_end, 1538 1543 &finfo,NULL,NULL); 1544 debuglocal(9, "fname %s (remove me 2)\n", finfo.fname); 1539 1545 if (!finfo.fname) { 1540 1546 debuglocal(0,"list_new: unable to parse name from info level %d\n",
Note:
See TracChangeset
for help on using the changeset viewer.