diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2014-12-12 18:59:43 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2014-12-12 18:59:43 -0500 |
commit | 5ef88da56a77bfb3b9631f5e5775f3bff86b6219 (patch) | |
tree | d09b7c8612f7652576ae3b75b80f7aaec303143e /fs/overlayfs | |
parent | dd662667e6d3e55b42798a6e6e7f37dddc639460 (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')
-rw-r--r-- | fs/overlayfs/overlayfs.h | 1 | ||||
-rw-r--r-- | fs/overlayfs/super.c | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index d39eaa8f5e47..d176b679f526 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -135,6 +135,7 @@ void ovl_dentry_version_inc(struct dentry *dentry); | |||
135 | void ovl_path_upper(struct dentry *dentry, struct path *path); | 135 | void ovl_path_upper(struct dentry *dentry, struct path *path); |
136 | void ovl_path_lower(struct dentry *dentry, struct path *path); | 136 | void ovl_path_lower(struct dentry *dentry, struct path *path); |
137 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); | 137 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); |
138 | int ovl_path_next(int idx, struct dentry *dentry, struct path *path); | ||
138 | struct dentry *ovl_dentry_upper(struct dentry *dentry); | 139 | struct dentry *ovl_dentry_upper(struct dentry *dentry); |
139 | struct dentry *ovl_dentry_lower(struct dentry *dentry); | 140 | struct dentry *ovl_dentry_lower(struct dentry *dentry); |
140 | struct dentry *ovl_dentry_real(struct dentry *dentry); | 141 | struct dentry *ovl_dentry_real(struct dentry *dentry); |
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 | */ | ||
312 | int 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 | |||
308 | struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, | 329 | struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, |
309 | unsigned int flags) | 330 | unsigned int flags) |
310 | { | 331 | { |