aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c71
1 files changed, 47 insertions, 24 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index a100fa35a48f..f1358e5c3a59 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -257,6 +257,7 @@ kill_it:
257 if (dentry) 257 if (dentry)
258 goto repeat; 258 goto repeat;
259} 259}
260EXPORT_SYMBOL(dput);
260 261
261/** 262/**
262 * d_invalidate - invalidate a dentry 263 * d_invalidate - invalidate a dentry
@@ -314,6 +315,7 @@ int d_invalidate(struct dentry * dentry)
314 spin_unlock(&dcache_lock); 315 spin_unlock(&dcache_lock);
315 return 0; 316 return 0;
316} 317}
318EXPORT_SYMBOL(d_invalidate);
317 319
318/* This should be called _only_ with dcache_lock held */ 320/* This should be called _only_ with dcache_lock held */
319 321
@@ -328,6 +330,7 @@ struct dentry * dget_locked(struct dentry *dentry)
328{ 330{
329 return __dget_locked(dentry); 331 return __dget_locked(dentry);
330} 332}
333EXPORT_SYMBOL(dget_locked);
331 334
332/** 335/**
333 * d_find_alias - grab a hashed alias of inode 336 * d_find_alias - grab a hashed alias of inode
@@ -384,6 +387,7 @@ struct dentry * d_find_alias(struct inode *inode)
384 } 387 }
385 return de; 388 return de;
386} 389}
390EXPORT_SYMBOL(d_find_alias);
387 391
388/* 392/*
389 * Try to kill dentries associated with this inode. 393 * Try to kill dentries associated with this inode.
@@ -408,6 +412,7 @@ restart:
408 } 412 }
409 spin_unlock(&dcache_lock); 413 spin_unlock(&dcache_lock);
410} 414}
415EXPORT_SYMBOL(d_prune_aliases);
411 416
412/* 417/*
413 * Throw away a dentry - free the inode, dput the parent. This requires that 418 * Throw away a dentry - free the inode, dput the parent. This requires that
@@ -610,6 +615,7 @@ void shrink_dcache_sb(struct super_block * sb)
610{ 615{
611 __shrink_dcache_sb(sb, NULL, 0); 616 __shrink_dcache_sb(sb, NULL, 0);
612} 617}
618EXPORT_SYMBOL(shrink_dcache_sb);
613 619
614/* 620/*
615 * destroy a single subtree of dentries for unmount 621 * destroy a single subtree of dentries for unmount
@@ -792,6 +798,7 @@ positive:
792 spin_unlock(&dcache_lock); 798 spin_unlock(&dcache_lock);
793 return 1; 799 return 1;
794} 800}
801EXPORT_SYMBOL(have_submounts);
795 802
796/* 803/*
797 * Search the dentry child list for the specified parent, 804 * Search the dentry child list for the specified parent,
@@ -876,6 +883,7 @@ void shrink_dcache_parent(struct dentry * parent)
876 while ((found = select_parent(parent)) != 0) 883 while ((found = select_parent(parent)) != 0)
877 __shrink_dcache_sb(sb, &found, 0); 884 __shrink_dcache_sb(sb, &found, 0);
878} 885}
886EXPORT_SYMBOL(shrink_dcache_parent);
879 887
880/* 888/*
881 * Scan `nr' dentries and return the number which remain. 889 * Scan `nr' dentries and return the number which remain.
@@ -968,6 +976,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
968 976
969 return dentry; 977 return dentry;
970} 978}
979EXPORT_SYMBOL(d_alloc);
971 980
972struct dentry *d_alloc_name(struct dentry *parent, const char *name) 981struct dentry *d_alloc_name(struct dentry *parent, const char *name)
973{ 982{
@@ -978,6 +987,7 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name)
978 q.hash = full_name_hash(q.name, q.len); 987 q.hash = full_name_hash(q.name, q.len);
979 return d_alloc(parent, &q); 988 return d_alloc(parent, &q);
980} 989}
990EXPORT_SYMBOL(d_alloc_name);
981 991
982/* the caller must hold dcache_lock */ 992/* the caller must hold dcache_lock */
983static void __d_instantiate(struct dentry *dentry, struct inode *inode) 993static void __d_instantiate(struct dentry *dentry, struct inode *inode)
@@ -1011,6 +1021,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
1011 spin_unlock(&dcache_lock); 1021 spin_unlock(&dcache_lock);
1012 security_d_instantiate(entry, inode); 1022 security_d_instantiate(entry, inode);
1013} 1023}
1024EXPORT_SYMBOL(d_instantiate);
1014 1025
1015/** 1026/**
1016 * d_instantiate_unique - instantiate a non-aliased dentry 1027 * d_instantiate_unique - instantiate a non-aliased dentry
@@ -1107,6 +1118,7 @@ struct dentry * d_alloc_root(struct inode * root_inode)
1107 } 1118 }
1108 return res; 1119 return res;
1109} 1120}
1121EXPORT_SYMBOL(d_alloc_root);
1110 1122
1111static inline struct hlist_head *d_hash(struct dentry *parent, 1123static inline struct hlist_head *d_hash(struct dentry *parent,
1112 unsigned long hash) 1124 unsigned long hash)
@@ -1210,7 +1222,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
1210 BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); 1222 BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED));
1211 spin_unlock(&dcache_lock); 1223 spin_unlock(&dcache_lock);
1212 security_d_instantiate(new, inode); 1224 security_d_instantiate(new, inode);
1213 d_rehash(dentry);
1214 d_move(new, dentry); 1225 d_move(new, dentry);
1215 iput(inode); 1226 iput(inode);
1216 } else { 1227 } else {
@@ -1224,6 +1235,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
1224 d_add(dentry, inode); 1235 d_add(dentry, inode);
1225 return new; 1236 return new;
1226} 1237}
1238EXPORT_SYMBOL(d_splice_alias);
1227 1239
1228/** 1240/**
1229 * d_add_ci - lookup or allocate new dentry with case-exact name 1241 * d_add_ci - lookup or allocate new dentry with case-exact name
@@ -1313,6 +1325,7 @@ err_out:
1313 iput(inode); 1325 iput(inode);
1314 return ERR_PTR(error); 1326 return ERR_PTR(error);
1315} 1327}
1328EXPORT_SYMBOL(d_add_ci);
1316 1329
1317/** 1330/**
1318 * d_lookup - search for a dentry 1331 * d_lookup - search for a dentry
@@ -1356,6 +1369,7 @@ struct dentry * d_lookup(struct dentry * parent, struct qstr * name)
1356 } while (read_seqretry(&rename_lock, seq)); 1369 } while (read_seqretry(&rename_lock, seq));
1357 return dentry; 1370 return dentry;
1358} 1371}
1372EXPORT_SYMBOL(d_lookup);
1359 1373
1360struct dentry * __d_lookup(struct dentry * parent, struct qstr * name) 1374struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
1361{ 1375{
@@ -1482,6 +1496,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
1482out: 1496out:
1483 return 0; 1497 return 0;
1484} 1498}
1499EXPORT_SYMBOL(d_validate);
1485 1500
1486/* 1501/*
1487 * When a file is deleted, we have two options: 1502 * When a file is deleted, we have two options:
@@ -1527,6 +1542,7 @@ void d_delete(struct dentry * dentry)
1527 1542
1528 fsnotify_nameremove(dentry, isdir); 1543 fsnotify_nameremove(dentry, isdir);
1529} 1544}
1545EXPORT_SYMBOL(d_delete);
1530 1546
1531static void __d_rehash(struct dentry * entry, struct hlist_head *list) 1547static void __d_rehash(struct dentry * entry, struct hlist_head *list)
1532{ 1548{
@@ -1555,6 +1571,7 @@ void d_rehash(struct dentry * entry)
1555 spin_unlock(&entry->d_lock); 1571 spin_unlock(&entry->d_lock);
1556 spin_unlock(&dcache_lock); 1572 spin_unlock(&dcache_lock);
1557} 1573}
1574EXPORT_SYMBOL(d_rehash);
1558 1575
1559/* 1576/*
1560 * When switching names, the actual string doesn't strictly have to 1577 * When switching names, the actual string doesn't strictly have to
@@ -1701,6 +1718,7 @@ void d_move(struct dentry * dentry, struct dentry * target)
1701 d_move_locked(dentry, target); 1718 d_move_locked(dentry, target);
1702 spin_unlock(&dcache_lock); 1719 spin_unlock(&dcache_lock);
1703} 1720}
1721EXPORT_SYMBOL(d_move);
1704 1722
1705/** 1723/**
1706 * d_ancestor - search for an ancestor 1724 * d_ancestor - search for an ancestor
@@ -1867,6 +1885,7 @@ shouldnt_be_hashed:
1867 spin_unlock(&dcache_lock); 1885 spin_unlock(&dcache_lock);
1868 BUG(); 1886 BUG();
1869} 1887}
1888EXPORT_SYMBOL_GPL(d_materialise_unique);
1870 1889
1871static int prepend(char **buffer, int *buflen, const char *str, int namelen) 1890static int prepend(char **buffer, int *buflen, const char *str, int namelen)
1872{ 1891{
@@ -2004,6 +2023,7 @@ char *d_path(const struct path *path, char *buf, int buflen)
2004 path_put(&root); 2023 path_put(&root);
2005 return res; 2024 return res;
2006} 2025}
2026EXPORT_SYMBOL(d_path);
2007 2027
2008/* 2028/*
2009 * Helper function for dentry_operations.d_dname() members 2029 * Helper function for dentry_operations.d_dname() members
@@ -2170,6 +2190,30 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
2170 return result; 2190 return result;
2171} 2191}
2172 2192
2193int path_is_under(struct path *path1, struct path *path2)
2194{
2195 struct vfsmount *mnt = path1->mnt;
2196 struct dentry *dentry = path1->dentry;
2197 int res;
2198 spin_lock(&vfsmount_lock);
2199 if (mnt != path2->mnt) {
2200 for (;;) {
2201 if (mnt->mnt_parent == mnt) {
2202 spin_unlock(&vfsmount_lock);
2203 return 0;
2204 }
2205 if (mnt->mnt_parent == path2->mnt)
2206 break;
2207 mnt = mnt->mnt_parent;
2208 }
2209 dentry = mnt->mnt_mountpoint;
2210 }
2211 res = is_subdir(dentry, path2->dentry);
2212 spin_unlock(&vfsmount_lock);
2213 return res;
2214}
2215EXPORT_SYMBOL(path_is_under);
2216
2173void d_genocide(struct dentry *root) 2217void d_genocide(struct dentry *root)
2174{ 2218{
2175 struct dentry *this_parent = root; 2219 struct dentry *this_parent = root;
@@ -2227,6 +2271,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name)
2227 } 2271 }
2228 return ino; 2272 return ino;
2229} 2273}
2274EXPORT_SYMBOL(find_inode_number);
2230 2275
2231static __initdata unsigned long dhash_entries; 2276static __initdata unsigned long dhash_entries;
2232static int __init set_dhash_entries(char *str) 2277static int __init set_dhash_entries(char *str)
@@ -2296,6 +2341,7 @@ static void __init dcache_init(void)
2296 2341
2297/* SLAB cache for __getname() consumers */ 2342/* SLAB cache for __getname() consumers */
2298struct kmem_cache *names_cachep __read_mostly; 2343struct kmem_cache *names_cachep __read_mostly;
2344EXPORT_SYMBOL(names_cachep);
2299 2345
2300EXPORT_SYMBOL(d_genocide); 2346EXPORT_SYMBOL(d_genocide);
2301 2347
@@ -2325,26 +2371,3 @@ void __init vfs_caches_init(unsigned long mempages)
2325 bdev_cache_init(); 2371 bdev_cache_init();
2326 chrdev_init(); 2372 chrdev_init();
2327} 2373}
2328
2329EXPORT_SYMBOL(d_alloc);
2330EXPORT_SYMBOL(d_alloc_root);
2331EXPORT_SYMBOL(d_delete);
2332EXPORT_SYMBOL(d_find_alias);
2333EXPORT_SYMBOL(d_instantiate);
2334EXPORT_SYMBOL(d_invalidate);
2335EXPORT_SYMBOL(d_lookup);
2336EXPORT_SYMBOL(d_move);
2337EXPORT_SYMBOL_GPL(d_materialise_unique);
2338EXPORT_SYMBOL(d_path);
2339EXPORT_SYMBOL(d_prune_aliases);
2340EXPORT_SYMBOL(d_rehash);
2341EXPORT_SYMBOL(d_splice_alias);
2342EXPORT_SYMBOL(d_add_ci);
2343EXPORT_SYMBOL(d_validate);
2344EXPORT_SYMBOL(dget_locked);
2345EXPORT_SYMBOL(dput);
2346EXPORT_SYMBOL(find_inode_number);
2347EXPORT_SYMBOL(have_submounts);
2348EXPORT_SYMBOL(names_cachep);
2349EXPORT_SYMBOL(shrink_dcache_parent);
2350EXPORT_SYMBOL(shrink_dcache_sb);