source: trunk/client/src/dircache.h@ 968

Last change on this file since 968 was 967, checked in by Yuri Dario, 9 years ago

Since pdc field is already known to upper layer, avoid storing it in
each cache entry. ticket#274.

File size: 2.7 KB
Line 
1/*
2 Directory caching code for Netdrive plugins.
3 Copyright (C) netlabs.org 2010-2016
4*/
5
6#ifndef __DIRCACHE_H__
7#define __DIRCACHE_H__
8
9#include <limits.h>
10
11#define NDPL_LARGEFILES
12#define INCL_LONGLONG
13#include <ndextpl2.h>
14
15#include "smbwrp.h"
16
17//
18// enable if not defined in your plugin
19//
20// dircache code uses only the fname field to scan the directory listing.
21// other fields are just passed to FNADD callback as are.
22//
23#if 0
24typedef struct smbwrp_fileinfo
25{
26 unsigned long long size;
27 unsigned long mtime;
28 unsigned type;
29 char fname[PATH_MAX];
30} smbwrp_fileinfo;
31#endif
32
33/*
34 * An entry in the directory cache contains one directory listing.
35 */
36typedef struct DirectoryCacheEntry
37{
38 struct DirectoryCacheEntry *pNext;
39 struct DirectoryCacheEntry *pPrev;
40
41 smbwrp_fileinfo *aInfos;
42 int cInfos;
43 int cInfosAllocated;
44
45 char *pszPath;
46 ULONG ulHash;
47 ULONG ulLastUpdateTime;
48 int fInvalid;
49} DirectoryCacheEntry;
50
51typedef struct DirectoryCache
52{
53 NDMUTEX mutex;
54
55 DirectoryCacheEntry *pEntriesHead;
56 DirectoryCacheEntry *pEntriesTail;
57 int cEntries;
58 int fEnabled;
59 unsigned long ulExpirationTime;
60 int cMaxEntries;
61 // resource handle, used only for per-share logging
62 void* resource;
63} DirectoryCache;
64
65enum {
66 CacheFault = 0,
67 CacheOk = 1
68};
69
70
71/* Directory cache helpers. */
72int dircache_create(DirectoryCache **ppdc, void* pRes, int cachetimeout, int cachedepth);
73void dircache_delete(DirectoryCache *pdc);
74
75/* callback for fsphAddFile32L */
76typedef void FNADDDIRENTRY(const char *mnt, smbwrp_fileinfo *finfo,
77 const char *mask, void *state);
78typedef FNADDDIRENTRY *PFNADDDIRENTRY;
79
80/* directory cache scanning */
81int dircache_list_files(DirectoryCache *pdc, PFNADDDIRENTRY fn,
82 void *plist,
83 char* dir_mask, char* fullpath,
84 int *ptotal_received);
85int dircache_find_path(DirectoryCache *pdc,
86 const char *path,
87 smbwrp_fileinfo *finfo,
88 unsigned long *pulAge);
89
90/* directory cache creation */
91void *dircache_write_begin(DirectoryCache *pdc,
92 char* dir_mask, char* fullpath,
93 int cFiles);
94void dircache_write_entry(DirectoryCache *pdc, void *dircachectx,
95 const smbwrp_fileinfo *finfo);
96void dircache_write_end(DirectoryCache *pdc, void *dircachectx);
97
98/* directory cache invalidation */
99void dircache_invalidate(DirectoryCache *pdc,
100 const char *path,
101 int fParent);
102
103#endif // __DIRCACHE_H__
Note: See TracBrowser for help on using the repository browser.