Changeset 966


Ignore:
Timestamp:
Aug 19, 2016, 2:24:06 PM (9 years ago)
Author:
Yuri Dario
Message:

Samba code changes for using new dircache API. ticket#274.

Location:
trunk/client/src
Files:
3 edited

Legend:

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

    r964 r966  
    2929#define INCL_LONGLONG
    3030#include <ndextpl2.h>
     31#include "dircache.h"
    3132#include "smbwrp.h"
    3233#include "util.h"
     
    499500         * the above values come from the gui. default: timeout 10; listings: 32
    500501        */
    501         dircache_create(pRes);
     502        dircache_create(&pRes->pdc, (void*) pRes,
     503                        pRes->cachetimeout, pRes->cachedepth);
    502504
    503505        return rc;
     
    715717        Resource *pRes = (Resource *)resource;
    716718        ENTER();
    717         dircache_delete(pRes);
     719
     720        // free cache dir
     721        dircache_delete(pRes->pdc);
     722
     723        // free local resources
    718724        memset(&pRes->srv, 0, sizeof(pRes->srv));
    719725        debuglocal(pRes, 9, "NdpFreeResource %d\n", NO_ERROR);
     
    957963           // First check if there is information in the directory cache.
    958964           unsigned long ulAge = 0;
    959            if (dircache_find_path(pRes, szPath, &finfo, &ulAge))
     965           if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
    960966           {
    961967              if (ulAge <= 15) /* @todo configurable. */
     
    12011207
    12021208        // delete the dir cache
    1203         dircache_invalidate(szPathName, pRes, 1);
     1209        dircache_invalidate(pRes->pdc, szPathName, 1);
    12041210
    12051211        do {
     
    15141520        debuglocal(pRes, 9, "NdpForceDelete in [%p]\n", pConn);
    15151521
    1516         dircache_invalidate(szFile, pRes, 1);
     1522        dircache_invalidate(pRes->pdc, szFile, 1);
    15171523
    15181524        do {
     
    15431549        debuglocal(pRes, 9, "NdpCreateDir in [%p]\n", pConn);
    15441550
    1545         dircache_invalidate(szDirName, pRes, 1);
     1551        dircache_invalidate(pRes->pdc, szDirName, 1);
    15461552
    15471553        do {
     
    15751581        debuglocal(pRes, 9, "NdpDeleteDir in [%p]\n", pConn);
    15761582
    1577         dircache_invalidate(szDir, pRes, 1);
     1583        dircache_invalidate(pRes->pdc, szDir, 1);
    15781584
    15791585        do {
     
    16051611        debuglocal(pRes, 9, "NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
    16061612
    1607         dircache_invalidate(szSrc, pRes, 1);
    1608         dircache_invalidate(szDst, pRes, 1);
     1613        dircache_invalidate(pRes->pdc, szSrc, 1);
     1614        dircache_invalidate(pRes->pdc, szDst, 1);
    16091615
    16101616        do
     
    16691675
    16701676        if (flags & O_CREAT)
    1671            dircache_invalidate(szFileName, pRes, 1);
     1677           dircache_invalidate(pRes->pdc, szFileName, 1);
    16721678
    16731679        do {
     
    20152021
    20162022        // delete the dir cache
    2017         dircache_invalidate(pConn->file.fullname, pRes, 1);
     2023        dircache_invalidate(pRes->pdc, pConn->file.fullname, 1);
    20182024
    20192025        do {
     
    22222228         * a new function needs to be done to update only one file in the cache
    22232229        */
    2224         dircache_invalidate(pConn->file.fullname, pRes, 1);
     2230        dircache_invalidate(pRes->pdc, pConn->file.fullname, 1);
    22252231
    22262232        do {
  • trunk/client/src/smbwrp.c

    r960 r966  
    2626#include "libsmb/clirap.h"
    2727#include "trans2.h"
     28
     29#include "dircache.h"
    2830#include "smbwrp.h"
    2931
     
    806808
    807809        // Try to get the listing from cache.
    808         if (dircache_list_files(fn, state, &num_finfo))
     810        if (dircache_list_files(pRes->pdc, fn, state->plist,
     811                                state->mask, (char*) state->fullpath, &num_finfo))
    809812           return(num_finfo); // Got from cache
    810813
     
    838841           goto fail;
    839842
    840         dircachectx = dircache_write_begin(state, num_finfo);
     843        dircachectx = dircache_write_begin(pRes->pdc, state->mask,
     844                                           (char*) state->fullpath, num_finfo);
    841845
    842846        debuglocal(pRes, 4,"list_files: got %d files\n", num_finfo);
     
    854858           fn(cli->dfs_mountpoint, &wrpfinfo, mask, state);
    855859           // Also add the entry to the cache.
    856            dircache_write_entry(pRes, dircachectx, &wrpfinfo);
    857         }
    858 
    859         dircache_write_end(pRes, dircachectx);
     860           dircache_write_entry(pRes->pdc, dircachectx, &wrpfinfo);
     861        }
     862
     863        dircache_write_end(pRes->pdc, dircachectx);
     864
    860865 fail:
    861866        TALLOC_FREE(frame);
     
    988993}
    989994
    990 
    991 #pragma pack(1)
    992 typedef struct _FEA
    993 {
    994         unsigned char fEA;      // flags
    995         unsigned char cbName;   // name length not including NULL
    996         unsigned short cbValue; // value length
    997 } FEA;
    998 
    999 typedef struct _FEALIST
    1000 {
    1001         unsigned long cbList;   // total bytes of structure including full list
    1002         FEA list[1];            // variable length FEA structures
    1003 } FEALIST;
    1004 #pragma pack()
    1005995
    1006996static int unilistea(Resource *pRes, cli_state * cli, char *fname, void * buffer, unsigned long size)
  • trunk/client/src/smbwrp.h

    r960 r966  
    130130} FSALLOCATE;
    131131#endif
    132 
    133 struct DirectoryCache;
    134132
    135133typedef struct _Resource
     
    203201int _System smbwrp_dskattr(Resource *pRes, cli_state * cli, FSALLOCATE *pfsa);
    204202
    205 /* Directory cache helpers. */
    206 int dircache_create(Resource *pRes);
    207 void dircache_delete(Resource *pRes);
    208 
    209 typedef void FNADDDIRENTRY(const char*, smbwrp_fileinfo *, const char *, void *);
    210 typedef FNADDDIRENTRY *PFNADDDIRENTRY;
    211 
    212 /* Note: dircache_list_files or dircache_write_begin construct the directory path
    213  *       using information in the filelist_state structure.
    214  */
    215 int dircache_list_files(PFNADDDIRENTRY fn,
    216                         filelist_state *state,
    217                         int *ptotal_received);
    218 
    219 void *dircache_write_begin(filelist_state *state,
    220                            int cFiles);
    221 void dircache_write_entry(Resource *pRes, void *dircachectx, const smbwrp_fileinfo *finfo);
    222 void dircache_write_end(Resource *pRes, void *dircachectx);
    223 
    224 void dircache_invalidate(const char *path,
    225                          Resource *pRes,
    226                          int fParent);
    227 
    228 int dircache_find_path(Resource *pRes,
    229                        const char *path,
    230                        smbwrp_fileinfo *finfo,
    231                        unsigned long *pulAge);
    232 
    233203/* Prototype the debug log helper. */
    234204void debuglocal(Resource *pRes, int level, const char * fmt, ...);
Note: See TracChangeset for help on using the changeset viewer.