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.
10 #include <uapi/linux/magic.h>
12 #include <linux/namei.h>
13 #include <linux/xattr.h>
14 #include <linux/mount.h>
15 #include <linux/parser.h>
16 #include <linux/module.h>
17 #include <linux/statfs.h>
18 #include <linux/seq_file.h>
19 #include <linux/posix_acl_xattr.h>
20 #include "overlayfs.h"
21 #include "ovl_entry.h"
23 MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
24 MODULE_DESCRIPTION("Overlay filesystem");
25 MODULE_LICENSE("GPL");
30 #define OVL_MAX_STACK 500
32 static bool ovl_redirect_dir_def
= IS_ENABLED(CONFIG_OVERLAY_FS_REDIRECT_DIR
);
33 module_param_named(redirect_dir
, ovl_redirect_dir_def
, bool, 0644);
34 MODULE_PARM_DESC(ovl_redirect_dir_def
,
35 "Default to on or off for the redirect_dir feature");
37 static void ovl_dentry_release(struct dentry
*dentry
)
39 struct ovl_entry
*oe
= dentry
->d_fsdata
;
44 dput(oe
->__upperdentry
);
46 for (i
= 0; i
< oe
->numlower
; i
++)
47 dput(oe
->lowerstack
[i
].dentry
);
52 static struct dentry
*ovl_d_real(struct dentry
*dentry
,
53 const struct inode
*inode
,
54 unsigned int open_flags
)
58 if (!d_is_reg(dentry
)) {
59 if (!inode
|| inode
== d_inode(dentry
))
64 if (d_is_negative(dentry
))
68 int err
= ovl_open_maybe_copy_up(dentry
, open_flags
);
74 real
= ovl_dentry_upper(dentry
);
75 if (real
&& (!inode
|| inode
== d_inode(real
)))
78 real
= ovl_dentry_lower(dentry
);
82 /* Handle recursion */
83 real
= d_real(real
, inode
, open_flags
);
85 if (!inode
|| inode
== d_inode(real
))
88 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry
,
89 inode
? inode
->i_sb
->s_id
: "NULL", inode
? inode
->i_ino
: 0);
93 static int ovl_dentry_revalidate(struct dentry
*dentry
, unsigned int flags
)
95 struct ovl_entry
*oe
= dentry
->d_fsdata
;
99 for (i
= 0; i
< oe
->numlower
; i
++) {
100 struct dentry
*d
= oe
->lowerstack
[i
].dentry
;
102 if (d
->d_flags
& DCACHE_OP_REVALIDATE
) {
103 ret
= d
->d_op
->d_revalidate(d
, flags
);
107 if (!(flags
& LOOKUP_RCU
))
116 static int ovl_dentry_weak_revalidate(struct dentry
*dentry
, unsigned int flags
)
118 struct ovl_entry
*oe
= dentry
->d_fsdata
;
122 for (i
= 0; i
< oe
->numlower
; i
++) {
123 struct dentry
*d
= oe
->lowerstack
[i
].dentry
;
125 if (d
->d_flags
& DCACHE_OP_WEAK_REVALIDATE
) {
126 ret
= d
->d_op
->d_weak_revalidate(d
, flags
);
134 static const struct dentry_operations ovl_dentry_operations
= {
135 .d_release
= ovl_dentry_release
,
136 .d_real
= ovl_d_real
,
139 static const struct dentry_operations ovl_reval_dentry_operations
= {
140 .d_release
= ovl_dentry_release
,
141 .d_real
= ovl_d_real
,
142 .d_revalidate
= ovl_dentry_revalidate
,
143 .d_weak_revalidate
= ovl_dentry_weak_revalidate
,
146 static void ovl_put_super(struct super_block
*sb
)
148 struct ovl_fs
*ufs
= sb
->s_fs_info
;
152 mntput(ufs
->upper_mnt
);
153 for (i
= 0; i
< ufs
->numlower
; i
++)
154 mntput(ufs
->lower_mnt
[i
]);
155 kfree(ufs
->lower_mnt
);
157 kfree(ufs
->config
.lowerdir
);
158 kfree(ufs
->config
.upperdir
);
159 kfree(ufs
->config
.workdir
);
160 put_cred(ufs
->creator_cred
);
166 * @sb: The overlayfs super block
167 * @buf: The struct kstatfs to fill in with stats
169 * Get the filesystem statistics. As writes always target the upper layer
170 * filesystem pass the statfs to the upper filesystem (if it exists)
172 static int ovl_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
174 struct ovl_fs
*ofs
= dentry
->d_sb
->s_fs_info
;
175 struct dentry
*root_dentry
= dentry
->d_sb
->s_root
;
179 ovl_path_real(root_dentry
, &path
);
181 err
= vfs_statfs(&path
, buf
);
183 buf
->f_namelen
= ofs
->namelen
;
184 buf
->f_type
= OVERLAYFS_SUPER_MAGIC
;
193 * Prints the mount options for a given superblock.
194 * Returns zero; does not fail.
196 static int ovl_show_options(struct seq_file
*m
, struct dentry
*dentry
)
198 struct super_block
*sb
= dentry
->d_sb
;
199 struct ovl_fs
*ufs
= sb
->s_fs_info
;
201 seq_show_option(m
, "lowerdir", ufs
->config
.lowerdir
);
202 if (ufs
->config
.upperdir
) {
203 seq_show_option(m
, "upperdir", ufs
->config
.upperdir
);
204 seq_show_option(m
, "workdir", ufs
->config
.workdir
);
206 if (ufs
->config
.default_permissions
)
207 seq_puts(m
, ",default_permissions");
208 if (ufs
->config
.redirect_dir
!= ovl_redirect_dir_def
)
209 seq_printf(m
, ",redirect_dir=%s",
210 ufs
->config
.redirect_dir
? "on" : "off");
214 static int ovl_remount(struct super_block
*sb
, int *flags
, char *data
)
216 struct ovl_fs
*ufs
= sb
->s_fs_info
;
218 if (!(*flags
& MS_RDONLY
) && (!ufs
->upper_mnt
|| !ufs
->workdir
))
224 static const struct super_operations ovl_super_operations
= {
225 .put_super
= ovl_put_super
,
226 .statfs
= ovl_statfs
,
227 .show_options
= ovl_show_options
,
228 .remount_fs
= ovl_remount
,
229 .drop_inode
= generic_delete_inode
,
236 OPT_DEFAULT_PERMISSIONS
,
238 OPT_REDIRECT_DIR_OFF
,
242 static const match_table_t ovl_tokens
= {
243 {OPT_LOWERDIR
, "lowerdir=%s"},
244 {OPT_UPPERDIR
, "upperdir=%s"},
245 {OPT_WORKDIR
, "workdir=%s"},
246 {OPT_DEFAULT_PERMISSIONS
, "default_permissions"},
247 {OPT_REDIRECT_DIR_ON
, "redirect_dir=on"},
248 {OPT_REDIRECT_DIR_OFF
, "redirect_dir=off"},
252 static char *ovl_next_opt(char **s
)
260 for (p
= sbegin
; *p
; p
++) {
265 } else if (*p
== ',') {
275 static int ovl_parse_opt(char *opt
, struct ovl_config
*config
)
279 while ((p
= ovl_next_opt(&opt
)) != NULL
) {
281 substring_t args
[MAX_OPT_ARGS
];
286 token
= match_token(p
, ovl_tokens
, args
);
289 kfree(config
->upperdir
);
290 config
->upperdir
= match_strdup(&args
[0]);
291 if (!config
->upperdir
)
296 kfree(config
->lowerdir
);
297 config
->lowerdir
= match_strdup(&args
[0]);
298 if (!config
->lowerdir
)
303 kfree(config
->workdir
);
304 config
->workdir
= match_strdup(&args
[0]);
305 if (!config
->workdir
)
309 case OPT_DEFAULT_PERMISSIONS
:
310 config
->default_permissions
= true;
313 case OPT_REDIRECT_DIR_ON
:
314 config
->redirect_dir
= true;
317 case OPT_REDIRECT_DIR_OFF
:
318 config
->redirect_dir
= false;
322 pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p
);
327 /* Workdir is useless in non-upper mount */
328 if (!config
->upperdir
&& config
->workdir
) {
329 pr_info("overlayfs: option \"workdir=%s\" is useless in a non-upper mount, ignore\n",
331 kfree(config
->workdir
);
332 config
->workdir
= NULL
;
338 #define OVL_WORKDIR_NAME "work"
340 static struct dentry
*ovl_workdir_create(struct vfsmount
*mnt
,
341 struct dentry
*dentry
)
343 struct inode
*dir
= dentry
->d_inode
;
346 bool retried
= false;
348 err
= mnt_want_write(mnt
);
352 inode_lock_nested(dir
, I_MUTEX_PARENT
);
354 work
= lookup_one_len(OVL_WORKDIR_NAME
, dentry
,
355 strlen(OVL_WORKDIR_NAME
));
358 struct iattr attr
= {
359 .ia_valid
= ATTR_MODE
,
360 .ia_mode
= S_IFDIR
| 0,
369 ovl_workdir_cleanup(dir
, mnt
, work
, 0);
374 err
= ovl_create_real(dir
, work
,
375 &(struct cattr
){.mode
= S_IFDIR
| 0},
381 * Try to remove POSIX ACL xattrs from workdir. We are good if:
383 * a) success (there was a POSIX ACL xattr and was removed)
384 * b) -ENODATA (there was no POSIX ACL xattr)
385 * c) -EOPNOTSUPP (POSIX ACL xattrs are not supported)
387 * There are various other error values that could effectively
388 * mean that the xattr doesn't exist (e.g. -ERANGE is returned
389 * if the xattr name is too long), but the set of filesystems
390 * allowed as upper are limited to "normal" ones, where checking
391 * for the above two errors is sufficient.
393 err
= vfs_removexattr(work
, XATTR_NAME_POSIX_ACL_DEFAULT
);
394 if (err
&& err
!= -ENODATA
&& err
!= -EOPNOTSUPP
)
397 err
= vfs_removexattr(work
, XATTR_NAME_POSIX_ACL_ACCESS
);
398 if (err
&& err
!= -ENODATA
&& err
!= -EOPNOTSUPP
)
401 /* Clear any inherited mode bits */
402 inode_lock(work
->d_inode
);
403 err
= notify_change(work
, &attr
, NULL
);
404 inode_unlock(work
->d_inode
);
420 static void ovl_unescape(char *s
)
433 static int ovl_mount_dir_noesc(const char *name
, struct path
*path
)
438 pr_err("overlayfs: empty lowerdir\n");
441 err
= kern_path(name
, LOOKUP_FOLLOW
, path
);
443 pr_err("overlayfs: failed to resolve '%s': %i\n", name
, err
);
447 if (ovl_dentry_weird(path
->dentry
)) {
448 pr_err("overlayfs: filesystem on '%s' not supported\n", name
);
451 if (!d_is_dir(path
->dentry
)) {
452 pr_err("overlayfs: '%s' not a directory\n", name
);
463 static int ovl_mount_dir(const char *name
, struct path
*path
)
466 char *tmp
= kstrdup(name
, GFP_KERNEL
);
470 err
= ovl_mount_dir_noesc(tmp
, path
);
473 if (ovl_dentry_remote(path
->dentry
)) {
474 pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
484 static int ovl_check_namelen(struct path
*path
, struct ovl_fs
*ofs
,
487 struct kstatfs statfs
;
488 int err
= vfs_statfs(path
, &statfs
);
491 pr_err("overlayfs: statfs failed on '%s'\n", name
);
493 ofs
->namelen
= max(ofs
->namelen
, statfs
.f_namelen
);
498 static int ovl_lower_dir(const char *name
, struct path
*path
,
499 struct ovl_fs
*ofs
, int *stack_depth
, bool *remote
)
503 err
= ovl_mount_dir_noesc(name
, path
);
507 err
= ovl_check_namelen(path
, ofs
, name
);
511 *stack_depth
= max(*stack_depth
, path
->mnt
->mnt_sb
->s_stack_depth
);
513 if (ovl_dentry_remote(path
->dentry
))
524 /* Workdir should not be subdir of upperdir and vice versa */
525 static bool ovl_workdir_ok(struct dentry
*workdir
, struct dentry
*upperdir
)
529 if (workdir
!= upperdir
) {
530 ok
= (lock_rename(workdir
, upperdir
) == NULL
);
531 unlock_rename(workdir
, upperdir
);
536 static unsigned int ovl_split_lowerdirs(char *str
)
538 unsigned int ctr
= 1;
541 for (s
= d
= str
;; s
++, d
++) {
544 } else if (*s
== ':') {
556 static int __maybe_unused
557 ovl_posix_acl_xattr_get(const struct xattr_handler
*handler
,
558 struct dentry
*dentry
, struct inode
*inode
,
559 const char *name
, void *buffer
, size_t size
)
561 return ovl_xattr_get(dentry
, handler
->name
, buffer
, size
);
564 static int __maybe_unused
565 ovl_posix_acl_xattr_set(const struct xattr_handler
*handler
,
566 struct dentry
*dentry
, struct inode
*inode
,
567 const char *name
, const void *value
,
568 size_t size
, int flags
)
570 struct dentry
*workdir
= ovl_workdir(dentry
);
571 struct inode
*realinode
= ovl_inode_real(inode
, NULL
);
572 struct posix_acl
*acl
= NULL
;
575 /* Check that everything is OK before copy-up */
577 acl
= posix_acl_from_xattr(&init_user_ns
, value
, size
);
582 if (!IS_POSIXACL(d_inode(workdir
)))
583 goto out_acl_release
;
584 if (!realinode
->i_op
->set_acl
)
585 goto out_acl_release
;
586 if (handler
->flags
== ACL_TYPE_DEFAULT
&& !S_ISDIR(inode
->i_mode
)) {
587 err
= acl
? -EACCES
: 0;
588 goto out_acl_release
;
591 if (!inode_owner_or_capable(inode
))
592 goto out_acl_release
;
594 posix_acl_release(acl
);
597 * Check if sgid bit needs to be cleared (actual setacl operation will
598 * be done with mounter's capabilities and so that won't do it for us).
600 if (unlikely(inode
->i_mode
& S_ISGID
) &&
601 handler
->flags
== ACL_TYPE_ACCESS
&&
602 !in_group_p(inode
->i_gid
) &&
603 !capable_wrt_inode_uidgid(inode
, CAP_FSETID
)) {
604 struct iattr iattr
= { .ia_valid
= ATTR_KILL_SGID
};
606 err
= ovl_setattr(dentry
, &iattr
);
611 err
= ovl_xattr_set(dentry
, handler
->name
, value
, size
, flags
);
613 ovl_copyattr(ovl_inode_real(inode
, NULL
), inode
);
618 posix_acl_release(acl
);
622 static int ovl_own_xattr_get(const struct xattr_handler
*handler
,
623 struct dentry
*dentry
, struct inode
*inode
,
624 const char *name
, void *buffer
, size_t size
)
629 static int ovl_own_xattr_set(const struct xattr_handler
*handler
,
630 struct dentry
*dentry
, struct inode
*inode
,
631 const char *name
, const void *value
,
632 size_t size
, int flags
)
637 static int ovl_other_xattr_get(const struct xattr_handler
*handler
,
638 struct dentry
*dentry
, struct inode
*inode
,
639 const char *name
, void *buffer
, size_t size
)
641 return ovl_xattr_get(dentry
, name
, buffer
, size
);
644 static int ovl_other_xattr_set(const struct xattr_handler
*handler
,
645 struct dentry
*dentry
, struct inode
*inode
,
646 const char *name
, const void *value
,
647 size_t size
, int flags
)
649 return ovl_xattr_set(dentry
, name
, value
, size
, flags
);
652 static const struct xattr_handler __maybe_unused
653 ovl_posix_acl_access_xattr_handler
= {
654 .name
= XATTR_NAME_POSIX_ACL_ACCESS
,
655 .flags
= ACL_TYPE_ACCESS
,
656 .get
= ovl_posix_acl_xattr_get
,
657 .set
= ovl_posix_acl_xattr_set
,
660 static const struct xattr_handler __maybe_unused
661 ovl_posix_acl_default_xattr_handler
= {
662 .name
= XATTR_NAME_POSIX_ACL_DEFAULT
,
663 .flags
= ACL_TYPE_DEFAULT
,
664 .get
= ovl_posix_acl_xattr_get
,
665 .set
= ovl_posix_acl_xattr_set
,
668 static const struct xattr_handler ovl_own_xattr_handler
= {
669 .prefix
= OVL_XATTR_PREFIX
,
670 .get
= ovl_own_xattr_get
,
671 .set
= ovl_own_xattr_set
,
674 static const struct xattr_handler ovl_other_xattr_handler
= {
675 .prefix
= "", /* catch all */
676 .get
= ovl_other_xattr_get
,
677 .set
= ovl_other_xattr_set
,
680 static const struct xattr_handler
*ovl_xattr_handlers
[] = {
681 #ifdef CONFIG_FS_POSIX_ACL
682 &ovl_posix_acl_access_xattr_handler
,
683 &ovl_posix_acl_default_xattr_handler
,
685 &ovl_own_xattr_handler
,
686 &ovl_other_xattr_handler
,
690 static int ovl_fill_super(struct super_block
*sb
, void *data
, int silent
)
692 struct path upperpath
= { NULL
, NULL
};
693 struct path workpath
= { NULL
, NULL
};
694 struct dentry
*root_dentry
;
695 struct inode
*realinode
;
696 struct ovl_entry
*oe
;
698 struct path
*stack
= NULL
;
701 unsigned int numlower
;
702 unsigned int stacklen
= 0;
708 ufs
= kzalloc(sizeof(struct ovl_fs
), GFP_KERNEL
);
712 ufs
->config
.redirect_dir
= ovl_redirect_dir_def
;
713 err
= ovl_parse_opt((char *) data
, &ufs
->config
);
715 goto out_free_config
;
718 if (!ufs
->config
.lowerdir
) {
720 pr_err("overlayfs: missing 'lowerdir'\n");
721 goto out_free_config
;
724 sb
->s_stack_depth
= 0;
725 sb
->s_maxbytes
= MAX_LFS_FILESIZE
;
726 if (ufs
->config
.upperdir
) {
727 if (!ufs
->config
.workdir
) {
728 pr_err("overlayfs: missing 'workdir'\n");
729 goto out_free_config
;
732 err
= ovl_mount_dir(ufs
->config
.upperdir
, &upperpath
);
734 goto out_free_config
;
736 /* Upper fs should not be r/o */
737 if (upperpath
.mnt
->mnt_sb
->s_flags
& MS_RDONLY
) {
738 pr_err("overlayfs: upper fs is r/o, try multi-lower layers mount\n");
740 goto out_put_upperpath
;
743 err
= ovl_check_namelen(&upperpath
, ufs
, ufs
->config
.upperdir
);
745 goto out_put_upperpath
;
747 err
= ovl_mount_dir(ufs
->config
.workdir
, &workpath
);
749 goto out_put_upperpath
;
752 if (upperpath
.mnt
!= workpath
.mnt
) {
753 pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
754 goto out_put_workpath
;
756 if (!ovl_workdir_ok(workpath
.dentry
, upperpath
.dentry
)) {
757 pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
758 goto out_put_workpath
;
760 sb
->s_stack_depth
= upperpath
.mnt
->mnt_sb
->s_stack_depth
;
763 lowertmp
= kstrdup(ufs
->config
.lowerdir
, GFP_KERNEL
);
765 goto out_put_workpath
;
768 stacklen
= ovl_split_lowerdirs(lowertmp
);
769 if (stacklen
> OVL_MAX_STACK
) {
770 pr_err("overlayfs: too many lower directories, limit is %d\n",
772 goto out_free_lowertmp
;
773 } else if (!ufs
->config
.upperdir
&& stacklen
== 1) {
774 pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
775 goto out_free_lowertmp
;
779 stack
= kcalloc(stacklen
, sizeof(struct path
), GFP_KERNEL
);
781 goto out_free_lowertmp
;
785 for (numlower
= 0; numlower
< stacklen
; numlower
++) {
786 err
= ovl_lower_dir(lower
, &stack
[numlower
], ufs
,
787 &sb
->s_stack_depth
, &remote
);
789 goto out_put_lowerpath
;
791 lower
= strchr(lower
, '\0') + 1;
796 if (sb
->s_stack_depth
> FILESYSTEM_MAX_STACK_DEPTH
) {
797 pr_err("overlayfs: maximum fs stacking depth exceeded\n");
798 goto out_put_lowerpath
;
801 if (ufs
->config
.upperdir
) {
802 ufs
->upper_mnt
= clone_private_mount(&upperpath
);
803 err
= PTR_ERR(ufs
->upper_mnt
);
804 if (IS_ERR(ufs
->upper_mnt
)) {
805 pr_err("overlayfs: failed to clone upperpath\n");
806 goto out_put_lowerpath
;
808 /* Don't inherit atime flags */
809 ufs
->upper_mnt
->mnt_flags
&= ~(MNT_NOATIME
| MNT_NODIRATIME
| MNT_RELATIME
);
811 sb
->s_time_gran
= ufs
->upper_mnt
->mnt_sb
->s_time_gran
;
813 ufs
->workdir
= ovl_workdir_create(ufs
->upper_mnt
, workpath
.dentry
);
814 err
= PTR_ERR(ufs
->workdir
);
815 if (IS_ERR(ufs
->workdir
)) {
816 pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
817 ufs
->config
.workdir
, OVL_WORKDIR_NAME
, -err
);
818 sb
->s_flags
|= MS_RDONLY
;
823 * Upper should support d_type, else whiteouts are visible.
824 * Given workdir and upper are on same fs, we can do
825 * iterate_dir() on workdir. This check requires successful
826 * creation of workdir in previous step.
829 err
= ovl_check_d_type_supported(&workpath
);
831 goto out_put_workdir
;
834 * We allowed this configuration and don't want to
835 * break users over kernel upgrade. So warn instead
839 pr_warn("overlayfs: upper fs needs to support d_type.\n");
844 ufs
->lower_mnt
= kcalloc(numlower
, sizeof(struct vfsmount
*), GFP_KERNEL
);
845 if (ufs
->lower_mnt
== NULL
)
846 goto out_put_workdir
;
847 for (i
= 0; i
< numlower
; i
++) {
848 struct vfsmount
*mnt
= clone_private_mount(&stack
[i
]);
852 pr_err("overlayfs: failed to clone lowerpath\n");
853 goto out_put_lower_mnt
;
856 * Make lower_mnt R/O. That way fchmod/fchown on lower file
857 * will fail instead of modifying lower fs.
859 mnt
->mnt_flags
|= MNT_READONLY
| MNT_NOATIME
;
861 ufs
->lower_mnt
[ufs
->numlower
] = mnt
;
865 /* If the upper fs is nonexistent, we mark overlayfs r/o too */
867 sb
->s_flags
|= MS_RDONLY
;
870 sb
->s_d_op
= &ovl_reval_dentry_operations
;
872 sb
->s_d_op
= &ovl_dentry_operations
;
874 ufs
->creator_cred
= prepare_creds();
875 if (!ufs
->creator_cred
)
876 goto out_put_lower_mnt
;
879 oe
= ovl_alloc_entry(numlower
);
883 sb
->s_magic
= OVERLAYFS_SUPER_MAGIC
;
884 sb
->s_op
= &ovl_super_operations
;
885 sb
->s_xattr
= ovl_xattr_handlers
;
887 sb
->s_flags
|= MS_POSIXACL
| MS_NOREMOTELOCK
;
889 root_dentry
= d_make_root(ovl_new_inode(sb
, S_IFDIR
, 0));
893 mntput(upperpath
.mnt
);
894 for (i
= 0; i
< numlower
; i
++)
895 mntput(stack
[i
].mnt
);
899 oe
->__upperdentry
= upperpath
.dentry
;
900 for (i
= 0; i
< numlower
; i
++) {
901 oe
->lowerstack
[i
].dentry
= stack
[i
].dentry
;
902 oe
->lowerstack
[i
].mnt
= ufs
->lower_mnt
[i
];
906 root_dentry
->d_fsdata
= oe
;
908 realinode
= d_inode(ovl_dentry_real(root_dentry
));
909 ovl_inode_init(d_inode(root_dentry
), realinode
, !!upperpath
.dentry
);
910 ovl_copyattr(realinode
, d_inode(root_dentry
));
912 sb
->s_root
= root_dentry
;
919 put_cred(ufs
->creator_cred
);
921 for (i
= 0; i
< ufs
->numlower
; i
++)
922 mntput(ufs
->lower_mnt
[i
]);
923 kfree(ufs
->lower_mnt
);
926 mntput(ufs
->upper_mnt
);
928 for (i
= 0; i
< numlower
; i
++)
936 path_put(&upperpath
);
938 kfree(ufs
->config
.lowerdir
);
939 kfree(ufs
->config
.upperdir
);
940 kfree(ufs
->config
.workdir
);
946 static struct dentry
*ovl_mount(struct file_system_type
*fs_type
, int flags
,
947 const char *dev_name
, void *raw_data
)
949 return mount_nodev(fs_type
, flags
, raw_data
, ovl_fill_super
);
952 static struct file_system_type ovl_fs_type
= {
953 .owner
= THIS_MODULE
,
956 .kill_sb
= kill_anon_super
,
958 MODULE_ALIAS_FS("overlay");
960 static int __init
ovl_init(void)
962 return register_filesystem(&ovl_fs_type
);
965 static void __exit
ovl_exit(void)
967 unregister_filesystem(&ovl_fs_type
);
970 module_init(ovl_init
);
971 module_exit(ovl_exit
);