/ Check-in [ae2f1627]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further work on getting ssdsim to run. This is an incremental checkin to save my place while jumping off to work on other things.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | ssdsim
Files: files | file ages | folders
SHA1: ae2f1627b1672e511be1ff132f2a3fb8f8bb7169
User & Date: drh 2012-10-25 23:47:27
Context
2012-10-25
23:47
Further work on getting ssdsim to run. This is an incremental checkin to save my place while jumping off to work on other things. Leaf check-in: ae2f1627 user: drh tags: ssdsim
15:32
Merge the command-line shell enhancements from trunk. Other edits toward trying to get ssdsim to run. check-in: 848f87e2 user: drh tags: ssdsim
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_ssdsim.c.

   306    306     void *zBuf, 
   307    307     int iAmt, 
   308    308     sqlite_int64 iOfst
   309    309   ){
   310    310     ssdsim_file *p = (ssdsim_file *)pFile;
   311    311     ssdsim_inode *pInode = p->pInode;
   312    312     int rc = SQLITE_OK;
   313         -  int lpn, ppn, n;
          313  +  int lpn, ppn, n, mx;
   314    314     unsigned char *pOut = (unsigned char*)zBuf;
   315    315     unsigned char *pContent;
   316    316     while( iAmt>0 ){
   317    317       if( iAmt+iOfst>pInode->len ){
   318    318         rc = SQLITE_IOERR_SHORT_READ;
   319    319         iAmt = pInode->len - iOfst;
   320    320         if( iAmt<=0 ) break;
   321    321       }
   322    322       lpn = pInode->aiPage[iOfst/g.szPage];
   323    323       ppn = ssdsimCoreLpnToPpn(lpn, 0);
   324    324       n = iAmt;
   325         -    if( (iOfst+n-1)*g.szPage > lpn ){
   326         -      n = (lpn+1)*g.szPage - iOfst;
   327         -    }
          325  +    mx = g.szPage - iOfst%g.szPage;
          326  +    if( n>mx ) n = mx;
   328    327       if( ppn>=0 && ppn<g.nPage && (pContent = g.apPage[ppn])!=0 ){
   329    328         memcpy(pOut, &pContent[iOfst%g.szPage], n);
   330    329       }else{
   331    330         memset(pOut, 0, n);
   332    331       }
   333    332       iOfst += n;
   334    333       iAmt -= n;
................................................................................
   356    355   
   357    356     lenNew = iOfst+iAmt;
   358    357     if( lenNew <= pInode->len ){
   359    358       lenNew = pInode->len;
   360    359     }else{
   361    360       int nOld, nNew;
   362    361       int *aiPage;
   363         -    nOld = pInode->len/g.szPage;
   364         -    nNew = (iOfst+iAmt)/g.szPage;
          362  +    nOld = (pInode->len+g.szPage-1)/g.szPage;
          363  +    nNew = (iOfst+iAmt+g.szPage-1)/g.szPage;
   365    364       if( nOld<nNew ){
   366    365         aiPage = sqlite3_realloc(pInode->aiPage, nNew*sizeof(int));
   367    366         if( aiPage==0 ) return SQLITE_NOMEM;
   368    367         memset(aiPage+nOld, 0xff, sizeof(int)*(nNew - nOld));
   369    368         pInode->aiPage = aiPage;
   370    369       }
   371    370     }
   372    371     while( iAmt>0 ){
   373         -    int n;
          372  +    int n, mx;
   374    373       lpn = pInode->aiPage[iOfst/g.szPage];
   375    374       if( lpn<0 ){
   376    375         lpn = ssdsimCoreLpnAlloc();
   377    376         if( lpn<0 ) return SQLITE_FULL;
   378         -      pInode->aiPage[iOfst/g.szPage];
   379    377       }
   380    378       ppn = ssdsimCoreLpnToPpn(lpn, 1);
   381    379       if( ppn<0 ) return SQLITE_NOMEM;
   382    380       n = iAmt;
   383         -    if( (iOfst+n-1)*g.szPage > lpn ){
   384         -      n = (lpn+1)*g.szPage - iOfst;
   385         -    }
          381  +    mx = g.szPage - iOfst%g.szPage;
          382  +    if( n>mx ) n = mx;
   386    383       pDest = g.apPage[ppn];
   387    384       memcpy(pDest, pIn, n);
   388    385       iOfst += n;
   389    386       iAmt -= n;
   390    387       pIn += n;
   391    388     }
   392    389     pInode->len = lenNew;
................................................................................
   748    745   ** returning.
   749    746   */
   750    747   static int ssdsimDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
   751    748     ssdsim_inode *pInode;
   752    749   
   753    750     if( ssdsimInit() ) return SQLITE_CANTOPEN;
   754    751     pInode = ssdsimFindInode(zPath);
   755         -  if( pInode==0 ) return SQLITE_NOTFOUND;
   756         -  ssdsimDeleteInode(pInode);
          752  +  if( pInode ) ssdsimDeleteInode(pInode);
   757    753     return SQLITE_OK;
   758    754   }
   759    755   
   760    756   /*
   761    757   ** Test for access permissions. Return true if the requested permission
   762    758   ** is available, or false otherwise.
   763    759   */