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/pagemap.h>
20 #include <linux/sched.h>
21 #include <linux/statfs.h>
22 #include <linux/seq_file.h>
23 #include "overlayfs.h"
26 MODULE_DESCRIPTION("Overlay filesystem");
27 MODULE_LICENSE("GPL");
33 bool default_permissions;
36 /* private information held for overlayfs's superblock */
38 struct vfsmount *upper_mnt;
40 struct vfsmount **lower_mnt;
41 struct dentry *workdir;
43 /* pathnames of lower and upper dirs, for show_options */
44 struct ovl_config config;
49 /* private information held for every overlayfs dentry */
51 struct dentry *__upperdentry;
52 struct ovl_dir_cache *cache;
61 struct path lowerstack[];
64 #define OVL_MAX_STACK 500
66 static struct dentry *__ovl_dentry_lower(struct ovl_entry *oe)
68 return oe->numlower ? oe->lowerstack[0].dentry : NULL;
71 enum ovl_path_type ovl_path_type(struct dentry *dentry)
73 struct ovl_entry *oe = dentry->d_fsdata;
74 enum ovl_path_type type = 0;
76 if (oe->__upperdentry) {
77 type = __OVL_PATH_UPPER;
80 * Non-dir dentry can hold lower dentry from previous
81 * location. Its purity depends only on opaque flag.
83 if (oe->numlower && S_ISDIR(dentry->d_inode->i_mode))
84 type |= __OVL_PATH_MERGE;
86 type |= __OVL_PATH_PURE;
89 type |= __OVL_PATH_MERGE;
94 static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
96 return lockless_dereference(oe->__upperdentry);
99 void ovl_path_upper(struct dentry *dentry, struct path *path)
101 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
102 struct ovl_entry *oe = dentry->d_fsdata;
104 path->mnt = ofs->upper_mnt;
105 path->dentry = ovl_upperdentry_dereference(oe);
108 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
110 enum ovl_path_type type = ovl_path_type(dentry);
112 if (!OVL_TYPE_UPPER(type))
113 ovl_path_lower(dentry, path);
115 ovl_path_upper(dentry, path);
120 struct dentry *ovl_dentry_upper(struct dentry *dentry)
122 struct ovl_entry *oe = dentry->d_fsdata;
124 return ovl_upperdentry_dereference(oe);
127 struct dentry *ovl_dentry_lower(struct dentry *dentry)
129 struct ovl_entry *oe = dentry->d_fsdata;
131 return __ovl_dentry_lower(oe);
134 struct dentry *ovl_dentry_real(struct dentry *dentry)
136 struct ovl_entry *oe = dentry->d_fsdata;
137 struct dentry *realdentry;
139 realdentry = ovl_upperdentry_dereference(oe);
141 realdentry = __ovl_dentry_lower(oe);
146 struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
148 struct dentry *realdentry;
150 realdentry = ovl_upperdentry_dereference(oe);
154 realdentry = __ovl_dentry_lower(oe);
160 struct vfsmount *ovl_entry_mnt_real(struct ovl_entry *oe, struct inode *inode,
164 struct ovl_fs *ofs = inode->i_sb->s_fs_info;
166 return ofs->upper_mnt;
168 return oe->numlower ? oe->lowerstack[0].mnt : NULL;
172 struct ovl_dir_cache *ovl_dir_cache(struct dentry *dentry)
174 struct ovl_entry *oe = dentry->d_fsdata;
179 bool ovl_is_default_permissions(struct inode *inode)
181 struct ovl_fs *ofs = inode->i_sb->s_fs_info;
183 return ofs->config.default_permissions;
186 void ovl_set_dir_cache(struct dentry *dentry, struct ovl_dir_cache *cache)
188 struct ovl_entry *oe = dentry->d_fsdata;
193 void ovl_path_lower(struct dentry *dentry, struct path *path)
195 struct ovl_entry *oe = dentry->d_fsdata;
197 *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
200 int ovl_want_write(struct dentry *dentry)
202 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
203 return mnt_want_write(ofs->upper_mnt);
206 void ovl_drop_write(struct dentry *dentry)
208 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
209 mnt_drop_write(ofs->upper_mnt);
212 struct dentry *ovl_workdir(struct dentry *dentry)
214 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
218 bool ovl_dentry_is_opaque(struct dentry *dentry)
220 struct ovl_entry *oe = dentry->d_fsdata;
224 void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque)
226 struct ovl_entry *oe = dentry->d_fsdata;
230 void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
232 struct ovl_entry *oe = dentry->d_fsdata;
234 WARN_ON(!inode_is_locked(upperdentry->d_parent->d_inode));
235 WARN_ON(oe->__upperdentry);
236 BUG_ON(!upperdentry->d_inode);
238 * Make sure upperdentry is consistent before making it visible to
239 * ovl_upperdentry_dereference().
242 oe->__upperdentry = upperdentry;
245 void ovl_dentry_version_inc(struct dentry *dentry)
247 struct ovl_entry *oe = dentry->d_fsdata;
249 WARN_ON(!inode_is_locked(dentry->d_inode));
253 u64 ovl_dentry_version_get(struct dentry *dentry)
255 struct ovl_entry *oe = dentry->d_fsdata;
257 WARN_ON(!inode_is_locked(dentry->d_inode));
261 bool ovl_is_whiteout(struct dentry *dentry)
263 struct inode *inode = dentry->d_inode;
265 return inode && IS_WHITEOUT(inode);
268 static bool ovl_is_opaquedir(struct dentry *dentry)
272 struct inode *inode = dentry->d_inode;
274 if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
277 res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);
278 if (res == 1 && val == 'y')
284 static void ovl_dentry_release(struct dentry *dentry)
286 struct ovl_entry *oe = dentry->d_fsdata;
291 dput(oe->__upperdentry);
292 for (i = 0; i < oe->numlower; i++)
293 dput(oe->lowerstack[i].dentry);
298 static int ovl_dentry_revalidate(struct dentry *dentry, unsigned int flags)
300 struct ovl_entry *oe = dentry->d_fsdata;
304 for (i = 0; i < oe->numlower; i++) {
305 struct dentry *d = oe->lowerstack[i].dentry;
307 if (d->d_flags & DCACHE_OP_REVALIDATE) {
308 ret = d->d_op->d_revalidate(d, flags);
312 if (!(flags & LOOKUP_RCU))
321 static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
323 struct ovl_entry *oe = dentry->d_fsdata;
327 for (i = 0; i < oe->numlower; i++) {
328 struct dentry *d = oe->lowerstack[i].dentry;
330 if (d->d_flags & DCACHE_OP_WEAK_REVALIDATE) {
331 ret = d->d_op->d_weak_revalidate(d, flags);
339 static const struct dentry_operations ovl_dentry_operations = {
340 .d_release = ovl_dentry_release,
341 .d_select_inode = ovl_d_select_inode,
344 static const struct dentry_operations ovl_reval_dentry_operations = {
345 .d_release = ovl_dentry_release,
346 .d_select_inode = ovl_d_select_inode,
347 .d_revalidate = ovl_dentry_revalidate,
348 .d_weak_revalidate = ovl_dentry_weak_revalidate,
351 static struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
353 size_t size = offsetof(struct ovl_entry, lowerstack[numlower]);
354 struct ovl_entry *oe = kzalloc(size, GFP_KERNEL);
357 oe->numlower = numlower;
362 static bool ovl_dentry_remote(struct dentry *dentry)
364 return dentry->d_flags &
365 (DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE);
368 static bool ovl_dentry_weird(struct dentry *dentry)
370 return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT |
371 DCACHE_MANAGE_TRANSIT |
376 static inline struct dentry *ovl_lookup_real(struct dentry *dir,
379 struct dentry *dentry;
381 inode_lock(dir->d_inode);
382 dentry = lookup_one_len(name->name, dir, name->len);
383 inode_unlock(dir->d_inode);
385 if (IS_ERR(dentry)) {
386 if (PTR_ERR(dentry) == -ENOENT)
388 } else if (!dentry->d_inode) {
391 } else if (ovl_dentry_weird(dentry)) {
393 /* Don't support traversing automounts and other weirdness */
394 dentry = ERR_PTR(-EREMOTE);
400 * Returns next layer in stack starting from top.
401 * Returns -1 if this is the last layer.
403 int ovl_path_next(int idx, struct dentry *dentry, struct path *path)
405 struct ovl_entry *oe = dentry->d_fsdata;
409 ovl_path_upper(dentry, path);
411 return oe->numlower ? 1 : -1;
414 BUG_ON(idx > oe->numlower);
415 *path = oe->lowerstack[idx - 1];
417 return (idx < oe->numlower) ? idx + 1 : -1;
420 struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
423 struct ovl_entry *oe;
424 struct ovl_entry *poe = dentry->d_parent->d_fsdata;
425 struct path *stack = NULL;
426 struct dentry *upperdir, *upperdentry = NULL;
427 unsigned int ctr = 0;
428 struct inode *inode = NULL;
429 bool upperopaque = false;
430 struct dentry *this, *prev = NULL;
434 upperdir = ovl_upperdentry_dereference(poe);
436 this = ovl_lookup_real(upperdir, &dentry->d_name);
442 if (unlikely(ovl_dentry_remote(this))) {
447 if (ovl_is_whiteout(this)) {
451 } else if (poe->numlower && ovl_is_opaquedir(this)) {
455 upperdentry = prev = this;
458 if (!upperopaque && poe->numlower) {
460 stack = kcalloc(poe->numlower, sizeof(struct path), GFP_KERNEL);
465 for (i = 0; !upperopaque && i < poe->numlower; i++) {
467 struct path lowerpath = poe->lowerstack[i];
469 this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name);
473 * If it's positive, then treat ENAMETOOLONG as ENOENT.
475 if (err == -ENAMETOOLONG && (upperdentry || ctr))
481 if (ovl_is_whiteout(this)) {
486 * Only makes sense to check opaque dir if this is not the
489 if (i < poe->numlower - 1 && ovl_is_opaquedir(this))
492 if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
493 !S_ISDIR(this->d_inode->i_mode))) {
495 * FIXME: check for upper-opaqueness maybe better done
498 if (prev == upperdentry)
504 * If this is a non-directory then stop here.
506 if (!S_ISDIR(this->d_inode->i_mode))
509 stack[ctr].dentry = this;
510 stack[ctr].mnt = lowerpath.mnt;
517 oe = ovl_alloc_entry(ctr);
522 if (upperdentry || ctr) {
523 struct dentry *realdentry;
525 realdentry = upperdentry ? upperdentry : stack[0].dentry;
528 inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode,
532 ovl_copyattr(realdentry->d_inode, inode);
535 oe->opaque = upperopaque;
536 oe->__upperdentry = upperdentry;
537 memcpy(oe->lowerstack, stack, sizeof(struct path) * ctr);
539 dentry->d_fsdata = oe;
540 d_add(dentry, inode);
547 for (i = 0; i < ctr; i++)
548 dput(stack[i].dentry);
556 struct file *ovl_path_open(struct path *path, int flags)
558 return dentry_open(path, flags, current_cred());
561 static void ovl_put_super(struct super_block *sb)
563 struct ovl_fs *ufs = sb->s_fs_info;
567 mntput(ufs->upper_mnt);
568 for (i = 0; i < ufs->numlower; i++)
569 mntput(ufs->lower_mnt[i]);
570 kfree(ufs->lower_mnt);
572 kfree(ufs->config.lowerdir);
573 kfree(ufs->config.upperdir);
574 kfree(ufs->config.workdir);
580 * @sb: The overlayfs super block
581 * @buf: The struct kstatfs to fill in with stats
583 * Get the filesystem statistics. As writes always target the upper layer
584 * filesystem pass the statfs to the upper filesystem (if it exists)
586 static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
588 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
589 struct dentry *root_dentry = dentry->d_sb->s_root;
593 ovl_path_real(root_dentry, &path);
595 err = vfs_statfs(&path, buf);
597 buf->f_namelen = max(buf->f_namelen, ofs->lower_namelen);
598 buf->f_type = OVERLAYFS_SUPER_MAGIC;
607 * Prints the mount options for a given superblock.
608 * Returns zero; does not fail.
610 static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
612 struct super_block *sb = dentry->d_sb;
613 struct ovl_fs *ufs = sb->s_fs_info;
615 seq_show_option(m, "lowerdir", ufs->config.lowerdir);
616 if (ufs->config.upperdir) {
617 seq_show_option(m, "upperdir", ufs->config.upperdir);
618 seq_show_option(m, "workdir", ufs->config.workdir);
620 if (ufs->config.default_permissions)
621 seq_puts(m, ",default_permissions");
625 static int ovl_remount(struct super_block *sb, int *flags, char *data)
627 struct ovl_fs *ufs = sb->s_fs_info;
629 if (!(*flags & MS_RDONLY) && (!ufs->upper_mnt || !ufs->workdir))
635 static const struct super_operations ovl_super_operations = {
636 .put_super = ovl_put_super,
637 .statfs = ovl_statfs,
638 .show_options = ovl_show_options,
639 .remount_fs = ovl_remount,
646 OPT_DEFAULT_PERMISSIONS,
650 static const match_table_t ovl_tokens = {
651 {OPT_LOWERDIR, "lowerdir=%s"},
652 {OPT_UPPERDIR, "upperdir=%s"},
653 {OPT_WORKDIR, "workdir=%s"},
654 {OPT_DEFAULT_PERMISSIONS, "default_permissions"},
658 static char *ovl_next_opt(char **s)
666 for (p = sbegin; *p; p++) {
671 } else if (*p == ',') {
681 static int ovl_parse_opt(char *opt, struct ovl_config *config)
685 while ((p = ovl_next_opt(&opt)) != NULL) {
687 substring_t args[MAX_OPT_ARGS];
692 token = match_token(p, ovl_tokens, args);
695 kfree(config->upperdir);
696 config->upperdir = match_strdup(&args[0]);
697 if (!config->upperdir)
702 kfree(config->lowerdir);
703 config->lowerdir = match_strdup(&args[0]);
704 if (!config->lowerdir)
709 kfree(config->workdir);
710 config->workdir = match_strdup(&args[0]);
711 if (!config->workdir)
715 case OPT_DEFAULT_PERMISSIONS:
716 config->default_permissions = true;
720 pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p);
725 /* Workdir is useless in non-upper mount */
726 if (!config->upperdir && config->workdir) {
727 pr_info("overlayfs: option \"workdir=%s\" is useless in a non-upper mount, ignore\n",
729 kfree(config->workdir);
730 config->workdir = NULL;
736 #define OVL_WORKDIR_NAME "work"
738 static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
739 struct dentry *dentry)
741 struct inode *dir = dentry->d_inode;
744 bool retried = false;
746 err = mnt_want_write(mnt);
750 inode_lock_nested(dir, I_MUTEX_PARENT);
752 work = lookup_one_len(OVL_WORKDIR_NAME, dentry,
753 strlen(OVL_WORKDIR_NAME));
756 struct kstat stat = {
766 ovl_cleanup(dir, work);
771 err = ovl_create_real(dir, work, &stat, NULL, NULL, true);
787 static void ovl_unescape(char *s)
800 static int ovl_mount_dir_noesc(const char *name, struct path *path)
805 pr_err("overlayfs: empty lowerdir\n");
808 err = kern_path(name, LOOKUP_FOLLOW, path);
810 pr_err("overlayfs: failed to resolve '%s': %i\n", name, err);
814 if (ovl_dentry_weird(path->dentry)) {
815 pr_err("overlayfs: filesystem on '%s' not supported\n", name);
818 if (!S_ISDIR(path->dentry->d_inode->i_mode)) {
819 pr_err("overlayfs: '%s' not a directory\n", name);
830 static int ovl_mount_dir(const char *name, struct path *path)
833 char *tmp = kstrdup(name, GFP_KERNEL);
837 err = ovl_mount_dir_noesc(tmp, path);
840 if (ovl_dentry_remote(path->dentry)) {
841 pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
851 static int ovl_lower_dir(const char *name, struct path *path, long *namelen,
852 int *stack_depth, bool *remote)
855 struct kstatfs statfs;
857 err = ovl_mount_dir_noesc(name, path);
861 err = vfs_statfs(path, &statfs);
863 pr_err("overlayfs: statfs failed on '%s'\n", name);
866 *namelen = max(*namelen, statfs.f_namelen);
867 *stack_depth = max(*stack_depth, path->mnt->mnt_sb->s_stack_depth);
869 if (ovl_dentry_remote(path->dentry))
880 /* Workdir should not be subdir of upperdir and vice versa */
881 static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir)
885 if (workdir != upperdir) {
886 ok = (lock_rename(workdir, upperdir) == NULL);
887 unlock_rename(workdir, upperdir);
892 static unsigned int ovl_split_lowerdirs(char *str)
894 unsigned int ctr = 1;
897 for (s = d = str;; s++, d++) {
900 } else if (*s == ':') {
912 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
914 struct path upperpath = { NULL, NULL };
915 struct path workpath = { NULL, NULL };
916 struct dentry *root_dentry;
917 struct ovl_entry *oe;
919 struct path *stack = NULL;
922 unsigned int numlower;
923 unsigned int stacklen = 0;
929 ufs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
933 err = ovl_parse_opt((char *) data, &ufs->config);
935 goto out_free_config;
938 if (!ufs->config.lowerdir) {
939 pr_err("overlayfs: missing 'lowerdir'\n");
940 goto out_free_config;
943 sb->s_stack_depth = 0;
944 sb->s_maxbytes = MAX_LFS_FILESIZE;
945 if (ufs->config.upperdir) {
946 if (!ufs->config.workdir) {
947 pr_err("overlayfs: missing 'workdir'\n");
948 goto out_free_config;
951 err = ovl_mount_dir(ufs->config.upperdir, &upperpath);
953 goto out_free_config;
955 /* Upper fs should not be r/o */
956 if (upperpath.mnt->mnt_sb->s_flags & MS_RDONLY) {
957 pr_err("overlayfs: upper fs is r/o, try multi-lower layers mount\n");
959 goto out_put_upperpath;
962 err = ovl_mount_dir(ufs->config.workdir, &workpath);
964 goto out_put_upperpath;
967 if (upperpath.mnt != workpath.mnt) {
968 pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
969 goto out_put_workpath;
971 if (!ovl_workdir_ok(workpath.dentry, upperpath.dentry)) {
972 pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
973 goto out_put_workpath;
975 sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth;
978 lowertmp = kstrdup(ufs->config.lowerdir, GFP_KERNEL);
980 goto out_put_workpath;
983 stacklen = ovl_split_lowerdirs(lowertmp);
984 if (stacklen > OVL_MAX_STACK) {
985 pr_err("overlayfs: too many lower directries, limit is %d\n",
987 goto out_free_lowertmp;
988 } else if (!ufs->config.upperdir && stacklen == 1) {
989 pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
990 goto out_free_lowertmp;
993 stack = kcalloc(stacklen, sizeof(struct path), GFP_KERNEL);
995 goto out_free_lowertmp;
998 for (numlower = 0; numlower < stacklen; numlower++) {
999 err = ovl_lower_dir(lower, &stack[numlower],
1000 &ufs->lower_namelen, &sb->s_stack_depth,
1003 goto out_put_lowerpath;
1005 lower = strchr(lower, '\0') + 1;
1009 sb->s_stack_depth++;
1010 if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
1011 pr_err("overlayfs: maximum fs stacking depth exceeded\n");
1012 goto out_put_lowerpath;
1015 if (ufs->config.upperdir) {
1016 ufs->upper_mnt = clone_private_mount(&upperpath);
1017 err = PTR_ERR(ufs->upper_mnt);
1018 if (IS_ERR(ufs->upper_mnt)) {
1019 pr_err("overlayfs: failed to clone upperpath\n");
1020 goto out_put_lowerpath;
1023 ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
1024 err = PTR_ERR(ufs->workdir);
1025 if (IS_ERR(ufs->workdir)) {
1026 pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
1027 ufs->config.workdir, OVL_WORKDIR_NAME, -err);
1028 sb->s_flags |= MS_RDONLY;
1029 ufs->workdir = NULL;
1034 ufs->lower_mnt = kcalloc(numlower, sizeof(struct vfsmount *), GFP_KERNEL);
1035 if (ufs->lower_mnt == NULL)
1036 goto out_put_workdir;
1037 for (i = 0; i < numlower; i++) {
1038 struct vfsmount *mnt = clone_private_mount(&stack[i]);
1042 pr_err("overlayfs: failed to clone lowerpath\n");
1043 goto out_put_lower_mnt;
1046 * Make lower_mnt R/O. That way fchmod/fchown on lower file
1047 * will fail instead of modifying lower fs.
1049 mnt->mnt_flags |= MNT_READONLY;
1051 ufs->lower_mnt[ufs->numlower] = mnt;
1055 /* If the upper fs is nonexistent, we mark overlayfs r/o too */
1056 if (!ufs->upper_mnt)
1057 sb->s_flags |= MS_RDONLY;
1060 sb->s_d_op = &ovl_reval_dentry_operations;
1062 sb->s_d_op = &ovl_dentry_operations;
1065 oe = ovl_alloc_entry(numlower);
1067 goto out_put_lower_mnt;
1069 root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, oe));
1073 mntput(upperpath.mnt);
1074 for (i = 0; i < numlower; i++)
1075 mntput(stack[i].mnt);
1076 path_put(&workpath);
1079 oe->__upperdentry = upperpath.dentry;
1080 for (i = 0; i < numlower; i++) {
1081 oe->lowerstack[i].dentry = stack[i].dentry;
1082 oe->lowerstack[i].mnt = ufs->lower_mnt[i];
1086 root_dentry->d_fsdata = oe;
1088 ovl_copyattr(ovl_dentry_real(root_dentry)->d_inode,
1089 root_dentry->d_inode);
1091 sb->s_magic = OVERLAYFS_SUPER_MAGIC;
1092 sb->s_op = &ovl_super_operations;
1093 sb->s_root = root_dentry;
1094 sb->s_fs_info = ufs;
1101 for (i = 0; i < ufs->numlower; i++)
1102 mntput(ufs->lower_mnt[i]);
1103 kfree(ufs->lower_mnt);
1106 mntput(ufs->upper_mnt);
1108 for (i = 0; i < numlower; i++)
1109 path_put(&stack[i]);
1114 path_put(&workpath);
1116 path_put(&upperpath);
1118 kfree(ufs->config.lowerdir);
1119 kfree(ufs->config.upperdir);
1120 kfree(ufs->config.workdir);
1126 static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
1127 const char *dev_name, void *raw_data)
1129 return mount_nodev(fs_type, flags, raw_data, ovl_fill_super);
1132 static struct file_system_type ovl_fs_type = {
1133 .owner = THIS_MODULE,
1136 .kill_sb = kill_anon_super,
1138 MODULE_ALIAS_FS("overlay");
1140 static int __init ovl_init(void)
1142 return register_filesystem(&ovl_fs_type);
1145 static void __exit ovl_exit(void)
1147 unregister_filesystem(&ovl_fs_type);
1150 module_init(ovl_init);
1151 module_exit(ovl_exit);