source: cmedia/trunk/Include/Linux/dcache.h@ 354

Last change on this file since 354 was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 5.3 KB
Line 
1/* $Id: dcache.h,v 1.1 2000/04/23 14:55:30 ktk Exp $ */
2
3#ifndef __LINUX_DCACHE_H
4#define __LINUX_DCACHE_H
5
6#ifdef __KERNEL__
7
8/*
9 * linux/include/linux/dcache.h
10 *
11 * Dirent cache data structures
12 *
13 * (C) Copyright 1997 Thomas Schoebel-Theuer,
14 * with heavy changes by Linus Torvalds
15 */
16
17#define IS_ROOT(x) ((x) == (x)->d_parent)
18
19/*
20 * "quick string" -- eases parameter passing, but more importantly
21 * saves "metadata" about the string (ie length and the hash).
22 */
23struct qstr {
24 const unsigned char * name;
25 unsigned int len;
26 unsigned int hash;
27};
28
29/* Name hashing routines. Initial hash value */
30#define init_name_hash() 0
31
32/* partial hash update function. Assume roughly 4 bits per character */
33static __inline__ unsigned long partial_name_hash(unsigned long c, unsigned long prevhash)
34{
35 prevhash = (prevhash << 4) | (prevhash >> (8*sizeof(unsigned long)-4));
36 return prevhash ^ c;
37}
38
39/* Finally: cut down the number of bits to a int value (and try to avoid losing bits) */
40static __inline__ unsigned long end_name_hash(unsigned long hash)
41{
42// if (sizeof(hash) > sizeof(unsigned int))
43// hash += hash >> 4*sizeof(hash);
44 return (unsigned int) hash;
45}
46
47/* Compute the hash for a name string. */
48static __inline__ unsigned int full_name_hash(const unsigned char * name, unsigned int len)
49{
50 unsigned long hash = init_name_hash();
51 while (len--)
52 hash = partial_name_hash(*name++, hash);
53 return end_name_hash(hash);
54}
55
56#define DNAME_INLINE_LEN 16
57
58struct dentry {
59#ifdef TARGET_OS2
60 struct inode * d_inode; /* Where the name belongs to - NULL is negative */
61#else
62 int d_count;
63 unsigned int d_flags;
64 struct inode * d_inode; /* Where the name belongs to - NULL is negative */
65 struct dentry * d_parent; /* parent directory */
66 struct dentry * d_mounts; /* mount information */
67 struct dentry * d_covers;
68 struct list_head d_hash; /* lookup hash list */
69 struct list_head d_lru; /* d_count = 0 LRU list */
70 struct list_head d_child; /* child of parent list */
71 struct list_head d_subdirs; /* our children */
72 struct list_head d_alias; /* inode alias list */
73 struct qstr d_name;
74 unsigned long d_time; /* used by d_revalidate */
75 struct dentry_operations *d_op;
76 struct super_block * d_sb; /* The root of the dentry tree */
77 unsigned long d_reftime; /* last time referenced */
78 void * d_fsdata; /* fs-specific data */
79 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
80#endif
81};
82
83struct dentry_operations {
84 int (*d_revalidate)(struct dentry *, int);
85 int (*d_hash) (struct dentry *, struct qstr *);
86 int (*d_compare) (struct dentry *, struct qstr *, struct qstr *);
87 void (*d_delete)(struct dentry *);
88 void (*d_release)(struct dentry *);
89 void (*d_iput)(struct dentry *, struct inode *);
90};
91
92/* the dentry parameter passed to d_hash and d_compare is the parent
93 * directory of the entries to be compared. It is used in case these
94 * functions need any directory specific information for determining
95 * equivalency classes. Using the dentry itself might not work, as it
96 * might be a negative dentry which has no information associated with
97 * it */
98
99
100
101/* d_flags entries */
102#define DCACHE_AUTOFS_PENDING 0x0001 /* autofs: "under construction" */
103#define DCACHE_NFSFS_RENAMED 0x0002 /* this dentry has been "silly
104 * renamed" and has to be
105 * deleted on the last dput()
106 */
107
108
109/*
110 * These are the low-level FS interfaces to the dcache..
111 */
112extern void d_instantiate(struct dentry *, struct inode *);
113extern void d_delete(struct dentry *);
114
115/* allocate/de-allocate */
116extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
117extern void shrink_dcache_sb(struct super_block *);
118extern void shrink_dcache_parent(struct dentry *);
119extern int d_invalidate(struct dentry *);
120
121#define shrink_dcache() prune_dcache(0)
122
123/* dcache memory management */
124extern int shrink_dcache_memory(int, unsigned int);
125extern void prune_dcache(int);
126
127/* icache memory management (defined in linux/fs/inode.c) */
128extern int shrink_icache_memory(int, int);
129extern void prune_icache(int);
130
131/* only used at mount-time */
132extern struct dentry * d_alloc_root(struct inode *);
133
134/* test whether root is busy without destroying dcache */
135extern int is_root_busy(struct dentry *);
136
137/*
138 * This adds the entry to the hash queues.
139 */
140extern void d_rehash(struct dentry *);
141/*
142 * This adds the entry to the hash queues and initializes "d_inode".
143 * The entry was actually filled in earlier during "d_alloc()"
144 */
145static __inline__ void d_add(struct dentry * entry, struct inode * inode)
146{
147 d_rehash(entry);
148 d_instantiate(entry, inode);
149}
150
151/* used for rename() and baskets */
152extern void d_move(struct dentry *, struct dentry *);
153
154/* appendix may either be NULL or be used for transname suffixes */
155extern struct dentry * d_lookup(struct dentry *, struct qstr *);
156
157/* validate "insecure" dentry pointer */
158extern int d_validate(struct dentry *, struct dentry *, unsigned int, unsigned int);
159
160/* write full pathname into buffer and return start of pathname */
161extern char * d_path(struct dentry *, char *, int);
162
163/* Allocation counts.. */
164struct dentry * dget(struct dentry *dentry);
165//{
166// if (dentry)
167// dentry->d_count++;
168// return dentry;
169//}
170
171extern void dput(struct dentry *);
172
173#endif /* __KERNEL__ */
174
175#endif /* __LINUX_DCACHE_H */
Note: See TracBrowser for help on using the repository browser.