aboutsummaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/super.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-12-12 18:59:43 -0500
committerMiklos Szeredi <mszeredi@suse.cz>2014-12-12 18:59:43 -0500
commit5ef88da56a77bfb3b9631f5e5775f3bff86b6219 (patch)
treed09b7c8612f7652576ae3b75b80f7aaec303143e /fs/overlayfs/super.c
parentdd662667e6d3e55b42798a6e6e7f37dddc639460 (diff)
ovl: helper to iterate layers
Add helper to iterate through all the layers, starting from the upper layer (if exists) and continuing down through the lower layers. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/overlayfs/super.c')
-rw-r--r--fs/overlayfs/super.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 460d866b97a2..07e4c576e93e 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -305,6 +305,27 @@ static inline struct dentry *ovl_lookup_real(struct dentry *dir,
305 return dentry; 305 return dentry;
306} 306}
307 307
308/*
309 * Returns next layer in stack starting from top.
310 * Returns -1 if this is the last layer.
311 */
312int ovl_path_next(int idx, struct dentry *dentry, struct path *path)
313{
314 struct ovl_entry *oe = dentry->d_fsdata;
315
316 BUG_ON(idx < 0);
317 if (idx == 0) {
318 ovl_path_upper(dentry, path);
319 if (path->dentry)
320 return oe->numlower ? 1 : -1;
321 idx++;
322 }
323 BUG_ON(idx > oe->numlower);
324 *path = oe->lowerstack[idx - 1];
325
326 return (idx < oe->numlower) ? idx + 1 : -1;
327}
328
308struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, 329struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
309 unsigned int flags) 330 unsigned int flags)
310{ 331{