3 * Copyright (C) 2011 Novell Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
11 #include <linux/namei.h>
12 #include <linux/pagemap.h>
13 #include <linux/xattr.h>
14 #include <linux/security.h>
15 #include <linux/mount.h>
16 #include <linux/slab.h>
17 #include <linux/parser.h>
18 #include <linux/module.h>
19 #include <linux/sched.h>
20 #include <linux/statfs.h>
21 #include <linux/seq_file.h>
22 #include "overlayfs.h"
24 MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
25 MODULE_DESCRIPTION("Overlay filesystem");
26 MODULE_LICENSE("GPL");
32 bool default_permissions;
35 /* private information held for overlayfs's superblock */
37 struct vfsmount *upper_mnt;
39 struct vfsmount **lower_mnt;
40 struct dentry *workdir;
42 /* pathnames of lower and upper dirs, for show_options */
43 struct ovl_config config;
48 /* private information held for every overlayfs dentry */
50 struct dentry *__upperdentry;
51 struct ovl_dir_cache *cache;
60 struct path lowerstack[];
63 #define OVL_MAX_STACK 500
65 static struct dentry *__ovl_dentry_lower(struct ovl_entry *oe)
67 return oe->numlower ? oe->lowerstack[0].dentry : NULL;
70 enum ovl_path_type ovl_path_type(struct dentry *dentry)
72 struct ovl_entry *oe = dentry->d_fsdata;
73 enum ovl_path_type type = 0;
75 if (oe->__upperdentry) {
76 type = __OVL_PATH_UPPER;
79 if (S_ISDIR(dentry->d_inode->i_mode))
80 type |= __OVL_PATH_MERGE;
81 } else if (!oe->opaque) {
82 type |= __OVL_PATH_PURE;
86 type |= __OVL_PATH_MERGE;
91 static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
93 return lockless_dereference(oe->__upperdentry);
96 void ovl_path_upper(struct dentry *dentry, struct path *path)
98 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
99 struct ovl_entry *oe = dentry->d_fsdata;
101 path->mnt = ofs->upper_mnt;
102 path->dentry = ovl_upperdentry_dereference(oe);
105 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
107 enum ovl_path_type type = ovl_path_type(dentry);
109 if (!OVL_TYPE_UPPER(type))
110 ovl_path_lower(dentry, path);
112 ovl_path_upper(dentry, path);
117 struct dentry *ovl_dentry_upper(struct dentry *dentry)
119 struct ovl_entry *oe = dentry->d_fsdata;
121 return ovl_upperdentry_dereference(oe);
124 struct dentry *ovl_dentry_lower(struct dentry *dentry)
126 struct ovl_entry *oe = dentry->d_fsdata;
128 return __ovl_dentry_lower(oe);
131 struct dentry *ovl_dentry_real(struct dentry *dentry)
133 struct ovl_entry *oe = dentry->d_fsdata;
134 struct dentry *realdentry;
136 realdentry = ovl_upperdentry_dereference(oe);
138 realdentry = __ovl_dentry_lower(oe);
143 struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
145 struct dentry *realdentry;
147 realdentry = ovl_upperdentry_dereference(oe);
151 realdentry = __ovl_dentry_lower(oe);
157 struct vfsmount *ovl_entry_mnt_real(struct ovl_entry *oe, struct inode *inode,
161 struct ovl_fs *ofs = inode->i_sb->s_fs_info;
163 return ofs->upper_mnt;
165 return oe->numlower ? oe->lowerstack[0].mnt : NULL;
169 struct ovl_dir_cache *ovl_dir_cache(struct dentry *dentry)
171 struct ovl_entry *oe = dentry->d_fsdata;
176 bool ovl_is_default_permissions(struct inode *inode)
178 struct ovl_fs *ofs = inode->i_sb->s_fs_info;
180 return ofs->config.default_permissions;
183 void ovl_set_dir_cache(struct dentry *dentry, struct ovl_dir_cache *cache)
185 struct ovl_entry *oe = dentry->d_fsdata;
190 void ovl_path_lower(struct dentry *dentry, struct path *path)
192 struct ovl_entry *oe = dentry->d_fsdata;
194 *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
197 int ovl_want_write(struct dentry *dentry)
199 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
200 return mnt_want_write(ofs->upper_mnt);
203 void ovl_drop_write(struct dentry *dentry)
205 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
206 mnt_drop_write(ofs->upper_mnt);
209 struct dentry *ovl_workdir(struct dentry *dentry)
211 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
215 bool ovl_dentry_is_opaque(struct dentry *dentry)
217 struct ovl_entry *oe = dentry->d_fsdata;
221 void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque)
223 struct ovl_entry *oe = dentry->d_fsdata;
227 void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
229 struct ovl_entry *oe = dentry->d_fsdata;
231 WARN_ON(!mutex_is_locked(&upperdentry->d_parent->d_inode->i_mutex));
232 WARN_ON(oe->__upperdentry);
233 BUG_ON(!upperdentry->d_inode);
235 * Make sure upperdentry is consistent before making it visible to
236 * ovl_upperdentry_dereference().
239 oe->__upperdentry = upperdentry;
242 void ovl_dentry_version_inc(struct dentry *dentry)
244 struct ovl_entry *oe = dentry->d_fsdata;
246 WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
250 u64 ovl_dentry_version_get(struct dentry *dentry)
252 struct ovl_entry *oe = dentry->d_fsdata;
254 WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
258 bool ovl_is_whiteout(struct dentry *dentry)
260 struct inode *inode = dentry->d_inode;
262 return inode && IS_WHITEOUT(inode);
265 static bool ovl_is_opaquedir(struct dentry *dentry)
269 struct inode *inode = dentry->d_inode;
271 if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
274 res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);
275 if (res == 1 && val == 'y')
281 static void ovl_dentry_release(struct dentry *dentry)
283 struct ovl_entry *oe = dentry->d_fsdata;
288 dput(oe->__upperdentry);
289 for (i = 0; i < oe->numlower; i++)
290 dput(oe->lowerstack[i].dentry);
295 static int ovl_dentry_revalidate(struct dentry *dentry, unsigned int flags)
297 struct ovl_entry *oe = dentry->d_fsdata;
301 for (i = 0; i < oe->numlower; i++) {
302 struct dentry *d = oe->lowerstack[i].dentry;
304 if (d->d_flags & DCACHE_OP_REVALIDATE) {
305 ret = d->d_op->d_revalidate(d, flags);
309 if (!(flags & LOOKUP_RCU))
318 static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
320 struct ovl_entry *oe = dentry->d_fsdata;
324 for (i = 0; i < oe->numlower; i++) {
325 struct dentry *d = oe->lowerstack[i].dentry;
327 if (d->d_flags & DCACHE_OP_WEAK_REVALIDATE) {
328 ret = d->d_op->d_weak_revalidate(d, flags);
336 static const struct dentry_operations ovl_dentry_operations = {
337 .d_release = ovl_dentry_release,
338 .d_select_inode = ovl_d_select_inode,
341 static const struct dentry_operations ovl_reval_dentry_operations = {
342 .d_release = ovl_dentry_release,
343 .d_revalidate = ovl_dentry_revalidate,
344 .d_weak_revalidate = ovl_dentry_weak_revalidate,
347 static struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
349 size_t size = offsetof(struct ovl_entry, lowerstack[numlower]);
350 struct ovl_entry *oe = kzalloc(size, GFP_KERNEL);
353 oe->numlower = numlower;
358 static bool ovl_dentry_remote(struct dentry *dentry)
360 return dentry->d_flags &
361 (DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE);
364 static bool ovl_dentry_weird(struct dentry *dentry)
366 return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT |
367 DCACHE_MANAGE_TRANSIT |
372 static inline struct dentry *ovl_lookup_real(struct dentry *dir,
375 struct dentry *dentry;
377 mutex_lock(&dir->d_inode->i_mutex);
378 dentry = lookup_one_len(name->name, dir, name->len);
379 mutex_unlock(&dir->d_inode->i_mutex);
381 if (IS_ERR(dentry)) {
382 if (PTR_ERR(dentry) == -ENOENT)
384 } else if (!dentry->d_inode) {
387 } else if (ovl_dentry_weird(dentry)) {
389 /* Don't support traversing automounts and other weirdness */
390 dentry = ERR_PTR(-EREMOTE);
396 * Returns next layer in stack starting from top.
397 * Returns -1 if this is the last layer.
399 int ovl_path_next(int idx, struct dentry *dentry, struct path *path)
401 struct ovl_entry *oe = dentry->d_fsdata;
405 ovl_path_upper(dentry, path);
407 return oe->numlower ? 1 : -1;
410 BUG_ON(idx > oe->numlower);
411 *path = oe->lowerstack[idx - 1];
413 return (idx < oe->numlower) ? idx + 1 : -1;
416 struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
419 struct ovl_entry *oe;
420 struct ovl_entry *poe = dentry->d_parent->d_fsdata;
421 struct path *stack = NULL;
422 struct dentry *upperdir, *upperdentry = NULL;
423 unsigned int ctr = 0;
424 struct inode *inode = NULL;
425 bool upperopaque = false;
426 struct dentry *this, *prev = NULL;
430 upperdir = ovl_upperdentry_dereference(poe);
432 this = ovl_lookup_real(upperdir, &dentry->d_name);
438 if (unlikely(ovl_dentry_remote(this))) {
443 if (ovl_is_whiteout(this)) {
447 } else if (poe->numlower && ovl_is_opaquedir(this)) {
451 upperdentry = prev = this;
454 if (!upperopaque && poe->numlower) {
456 stack = kcalloc(poe->numlower, sizeof(struct path), GFP_KERNEL);
461 for (i = 0; !upperopaque && i < poe->numlower; i++) {
463 struct path lowerpath = poe->lowerstack[i];
465 this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name);
469 * If it's positive, then treat ENAMETOOLONG as ENOENT.
471 if (err == -ENAMETOOLONG && (upperdentry || ctr))
477 if (ovl_is_whiteout(this)) {
482 * Only makes sense to check opaque dir if this is not the
485 if (i < poe->numlower - 1 && ovl_is_opaquedir(this))
488 if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
489 !S_ISDIR(this->d_inode->i_mode))) {
491 * FIXME: check for upper-opaqueness maybe better done
494 if (prev == upperdentry)
500 * If this is a non-directory then stop here.
502 if (!S_ISDIR(this->d_inode->i_mode))
505 stack[ctr].dentry = this;
506 stack[ctr].mnt = lowerpath.mnt;
513 oe = ovl_alloc_entry(ctr);
518 if (upperdentry || ctr) {
519 struct dentry *realdentry;
521 realdentry = upperdentry ? upperdentry : stack[0].dentry;
524 inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode,
528 ovl_copyattr(realdentry->d_inode, inode);
531 oe->opaque = upperopaque;
532 oe->__upperdentry = upperdentry;
533 memcpy(oe->lowerstack, stack, sizeof(struct path) * ctr);
535 dentry->d_fsdata = oe;
536 d_add(dentry, inode);
543 for (i = 0; i < ctr; i++)
544 dput(stack[i].dentry);
552 struct file *ovl_path_open(struct path *path, int flags)
554 return dentry_open(path, flags, current_cred());
557 static void ovl_put_super(struct super_block *sb)
559 struct ovl_fs *ufs = sb->s_fs_info;
563 mntput(ufs->upper_mnt);
564 for (i = 0; i < ufs->numlower; i++)
565 mntput(ufs->lower_mnt[i]);
566 kfree(ufs->lower_mnt);
568 kfree(ufs->config.lowerdir);
569 kfree(ufs->config.upperdir);
570 kfree(ufs->config.workdir);
576 * @sb: The overlayfs super block
577 * @buf: The struct kstatfs to fill in with stats
579 * Get the filesystem statistics. As writes always target the upper layer
580 * filesystem pass the statfs to the upper filesystem (if it exists)
582 static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
584 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
585 struct dentry *root_dentry = dentry->d_sb->s_root;
589 ovl_path_real(root_dentry, &path);
591 err = vfs_statfs(&path, buf);
593 buf->f_namelen = max(buf->f_namelen, ofs->lower_namelen);
594 buf->f_type = OVERLAYFS_SUPER_MAGIC;
603 * Prints the mount options for a given superblock.
604 * Returns zero; does not fail.
606 static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
608 struct super_block *sb = dentry->d_sb;
609 struct ovl_fs *ufs = sb->s_fs_info;
611 seq_show_option(m, "lowerdir", ufs->config.lowerdir);
612 if (ufs->config.upperdir) {
613 seq_show_option(m, "upperdir", ufs->config.upperdir);
614 seq_show_option(m, "workdir", ufs->config.workdir);
616 if (ufs->config.default_permissions)
617 seq_puts(m, ",default_permissions");
621 static int ovl_remount(struct super_block *sb, int *flags, char *data)
623 struct ovl_fs *ufs = sb->s_fs_info;
625 if (!(*flags & MS_RDONLY) && (!ufs->upper_mnt || !ufs->workdir))
631 static const struct super_operations ovl_super_operations = {
632 .put_super = ovl_put_super,
633 .statfs = ovl_statfs,
634 .show_options = ovl_show_options,
635 .remount_fs = ovl_remount,
642 OPT_DEFAULT_PERMISSIONS,
646 static const match_table_t ovl_tokens = {
647 {OPT_LOWERDIR, "lowerdir=%s"},
648 {OPT_UPPERDIR, "upperdir=%s"},
649 {OPT_WORKDIR, "workdir=%s"},
650 {OPT_DEFAULT_PERMISSIONS, "default_permissions"},
654 static char *ovl_next_opt(char **s)
662 for (p = sbegin; *p; p++) {
667 } else if (*p == ',') {
677 static int ovl_parse_opt(char *opt, struct ovl_config *config)
681 while ((p = ovl_next_opt(&opt)) != NULL) {
683 substring_t args[MAX_OPT_ARGS];
688 token = match_token(p, ovl_tokens, args);
691 kfree(config->upperdir);
692 config->upperdir = match_strdup(&args[0]);
693 if (!config->upperdir)
698 kfree(config->lowerdir);
699 config->lowerdir = match_strdup(&args[0]);
700 if (!config->lowerdir)
705 kfree(config->workdir);
706 config->workdir = match_strdup(&args[0]);
707 if (!config->workdir)
711 case OPT_DEFAULT_PERMISSIONS:
712 config->default_permissions = true;
716 pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p);
721 /* Workdir is useless in non-upper mount */
722 if (!config->upperdir && config->workdir) {
723 pr_info("overlayfs: option \"workdir=%s\" is useless in a non-upper mount, ignore\n",
725 kfree(config->workdir);
726 config->workdir = NULL;
732 #define OVL_WORKDIR_NAME "work"
734 static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
735 struct dentry *dentry)
737 struct inode *dir = dentry->d_inode;
740 bool retried = false;
742 err = mnt_want_write(mnt);
746 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
748 work = lookup_one_len(OVL_WORKDIR_NAME, dentry,
749 strlen(OVL_WORKDIR_NAME));
752 struct kstat stat = {
762 ovl_cleanup(dir, work);
767 err = ovl_create_real(dir, work, &stat, NULL, NULL, true);
772 mutex_unlock(&dir->i_mutex);
783 static void ovl_unescape(char *s)
796 static int ovl_mount_dir_noesc(const char *name, struct path *path)
801 pr_err("overlayfs: empty lowerdir\n");
804 err = kern_path(name, LOOKUP_FOLLOW, path);
806 pr_err("overlayfs: failed to resolve '%s': %i\n", name, err);
810 if (ovl_dentry_weird(path->dentry)) {
811 pr_err("overlayfs: filesystem on '%s' not supported\n", name);
814 if (!S_ISDIR(path->dentry->d_inode->i_mode)) {
815 pr_err("overlayfs: '%s' not a directory\n", name);
826 static int ovl_mount_dir(const char *name, struct path *path)
829 char *tmp = kstrdup(name, GFP_KERNEL);
833 err = ovl_mount_dir_noesc(tmp, path);
836 if (ovl_dentry_remote(path->dentry)) {
837 pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
847 static int ovl_lower_dir(const char *name, struct path *path, long *namelen,
848 int *stack_depth, bool *remote)
851 struct kstatfs statfs;
853 err = ovl_mount_dir_noesc(name, path);
857 err = vfs_statfs(path, &statfs);
859 pr_err("overlayfs: statfs failed on '%s'\n", name);
862 *namelen = max(*namelen, statfs.f_namelen);
863 *stack_depth = max(*stack_depth, path->mnt->mnt_sb->s_stack_depth);
865 if (ovl_dentry_remote(path->dentry))
876 /* Workdir should not be subdir of upperdir and vice versa */
877 static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir)
881 if (workdir != upperdir) {
882 ok = (lock_rename(workdir, upperdir) == NULL);
883 unlock_rename(workdir, upperdir);
888 static unsigned int ovl_split_lowerdirs(char *str)
890 unsigned int ctr = 1;
893 for (s = d = str;; s++, d++) {
896 } else if (*s == ':') {
908 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
910 struct path upperpath = { NULL, NULL };
911 struct path workpath = { NULL, NULL };
912 struct dentry *root_dentry;
913 struct ovl_entry *oe;
915 struct path *stack = NULL;
918 unsigned int numlower;
919 unsigned int stacklen = 0;
925 ufs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
929 err = ovl_parse_opt((char *) data, &ufs->config);
931 goto out_free_config;
934 if (!ufs->config.lowerdir) {
935 pr_err("overlayfs: missing 'lowerdir'\n");
936 goto out_free_config;
939 sb->s_stack_depth = 0;
940 sb->s_maxbytes = MAX_LFS_FILESIZE;
941 if (ufs->config.upperdir) {
942 if (!ufs->config.workdir) {
943 pr_err("overlayfs: missing 'workdir'\n");
944 goto out_free_config;
947 err = ovl_mount_dir(ufs->config.upperdir, &upperpath);
949 goto out_free_config;
951 /* Upper fs should not be r/o */
952 if (upperpath.mnt->mnt_sb->s_flags & MS_RDONLY) {
953 pr_err("overlayfs: upper fs is r/o, try multi-lower layers mount\n");
955 goto out_put_upperpath;
958 err = ovl_mount_dir(ufs->config.workdir, &workpath);
960 goto out_put_upperpath;
963 if (upperpath.mnt != workpath.mnt) {
964 pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
965 goto out_put_workpath;
967 if (!ovl_workdir_ok(workpath.dentry, upperpath.dentry)) {
968 pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
969 goto out_put_workpath;
971 sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth;
974 lowertmp = kstrdup(ufs->config.lowerdir, GFP_KERNEL);
976 goto out_put_workpath;
979 stacklen = ovl_split_lowerdirs(lowertmp);
980 if (stacklen > OVL_MAX_STACK) {
981 pr_err("overlayfs: too many lower directries, limit is %d\n",
983 goto out_free_lowertmp;
984 } else if (!ufs->config.upperdir && stacklen == 1) {
985 pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
986 goto out_free_lowertmp;
989 stack = kcalloc(stacklen, sizeof(struct path), GFP_KERNEL);
991 goto out_free_lowertmp;
994 for (numlower = 0; numlower < stacklen; numlower++) {
995 err = ovl_lower_dir(lower, &stack[numlower],
996 &ufs->lower_namelen, &sb->s_stack_depth,
999 goto out_put_lowerpath;
1001 lower = strchr(lower, '\0') + 1;
1005 sb->s_stack_depth++;
1006 if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
1007 pr_err("overlayfs: maximum fs stacking depth exceeded\n");
1008 goto out_put_lowerpath;
1011 if (ufs->config.upperdir) {
1012 ufs->upper_mnt = clone_private_mount(&upperpath);
1013 err = PTR_ERR(ufs->upper_mnt);
1014 if (IS_ERR(ufs->upper_mnt)) {
1015 pr_err("overlayfs: failed to clone upperpath\n");
1016 goto out_put_lowerpath;
1019 ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
1020 err = PTR_ERR(ufs->workdir);
1021 if (IS_ERR(ufs->workdir)) {
1022 pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
1023 ufs->config.workdir, OVL_WORKDIR_NAME, -err);
1024 sb->s_flags |= MS_RDONLY;
1025 ufs->workdir = NULL;
1030 ufs->lower_mnt = kcalloc(numlower, sizeof(struct vfsmount *), GFP_KERNEL);
1031 if (ufs->lower_mnt == NULL)
1032 goto out_put_workdir;
1033 for (i = 0; i < numlower; i++) {
1034 struct vfsmount *mnt = clone_private_mount(&stack[i]);
1038 pr_err("overlayfs: failed to clone lowerpath\n");
1039 goto out_put_lower_mnt;
1042 * Make lower_mnt R/O. That way fchmod/fchown on lower file
1043 * will fail instead of modifying lower fs.
1045 mnt->mnt_flags |= MNT_READONLY;
1047 ufs->lower_mnt[ufs->numlower] = mnt;
1051 /* If the upper fs is nonexistent, we mark overlayfs r/o too */
1052 if (!ufs->upper_mnt)
1053 sb->s_flags |= MS_RDONLY;
1056 sb->s_d_op = &ovl_reval_dentry_operations;
1058 sb->s_d_op = &ovl_dentry_operations;
1061 oe = ovl_alloc_entry(numlower);
1063 goto out_put_lower_mnt;
1065 root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, oe));
1069 mntput(upperpath.mnt);
1070 for (i = 0; i < numlower; i++)
1071 mntput(stack[i].mnt);
1072 path_put(&workpath);
1075 oe->__upperdentry = upperpath.dentry;
1076 for (i = 0; i < numlower; i++) {
1077 oe->lowerstack[i].dentry = stack[i].dentry;
1078 oe->lowerstack[i].mnt = ufs->lower_mnt[i];
1082 root_dentry->d_fsdata = oe;
1084 ovl_copyattr(ovl_dentry_real(root_dentry)->d_inode,
1085 root_dentry->d_inode);
1087 sb->s_magic = OVERLAYFS_SUPER_MAGIC;
1088 sb->s_op = &ovl_super_operations;
1089 sb->s_root = root_dentry;
1090 sb->s_fs_info = ufs;
1097 for (i = 0; i < ufs->numlower; i++)
1098 mntput(ufs->lower_mnt[i]);
1099 kfree(ufs->lower_mnt);
1102 mntput(ufs->upper_mnt);
1104 for (i = 0; i < numlower; i++)
1105 path_put(&stack[i]);
1110 path_put(&workpath);
1112 path_put(&upperpath);
1114 kfree(ufs->config.lowerdir);
1115 kfree(ufs->config.upperdir);
1116 kfree(ufs->config.workdir);
1122 static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
1123 const char *dev_name, void *raw_data)
1125 return mount_nodev(fs_type, flags, raw_data, ovl_fill_super);
1128 static struct file_system_type ovl_fs_type = {
1129 .owner = THIS_MODULE,
1132 .kill_sb = kill_anon_super,
1134 MODULE_ALIAS_FS("overlay");
1136 static int __init ovl_init(void)
1138 return register_filesystem(&ovl_fs_type);
1141 static void __exit ovl_exit(void)
1143 unregister_filesystem(&ovl_fs_type);
1146 module_init(ovl_init);
1147 module_exit(ovl_exit);