blob: 520f9ab0e9ef3b267b01be948251a643067ecf5f [file] [log] [blame]
Miklos Szeredie9be9d52014-10-24 00:14:38 +02001/*
2 *
3 * Copyright (C) 2011 Novell Inc.
4 *
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.
8 */
9
10#include <linux/fs.h>
11#include <linux/namei.h>
12#include <linux/xattr.h>
Miklos Szeredie9be9d52014-10-24 00:14:38 +020013#include <linux/mount.h>
Miklos Szeredie9be9d52014-10-24 00:14:38 +020014#include <linux/parser.h>
15#include <linux/module.h>
Andy Whitcroftcc259632014-10-24 00:14:38 +020016#include <linux/statfs.h>
Erez Zadokf45827e82014-10-24 00:14:38 +020017#include <linux/seq_file.h>
Miklos Szeredid837a492016-07-29 12:05:24 +020018#include <linux/posix_acl_xattr.h>
Miklos Szeredie9be9d52014-10-24 00:14:38 +020019#include "overlayfs.h"
Miklos Szeredibbb1e542016-12-16 11:02:56 +010020#include "ovl_entry.h"
Miklos Szeredie9be9d52014-10-24 00:14:38 +020021
22MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
23MODULE_DESCRIPTION("Overlay filesystem");
24MODULE_LICENSE("GPL");
25
Miklos Szeredie9be9d52014-10-24 00:14:38 +020026
27struct ovl_dir_cache;
28
Miklos Szeredia78d9f02014-12-13 00:59:52 +010029#define OVL_MAX_STACK 500
30
Miklos Szeredie9be9d52014-10-24 00:14:38 +020031
32static void ovl_dentry_release(struct dentry *dentry)
33{
34 struct ovl_entry *oe = dentry->d_fsdata;
35
36 if (oe) {
Miklos Szeredidd662662014-12-13 00:59:43 +010037 unsigned int i;
38
Miklos Szeredie9be9d52014-10-24 00:14:38 +020039 dput(oe->__upperdentry);
Miklos Szeredi02b69b22016-12-16 11:02:56 +010040 kfree(oe->redirect);
Miklos Szeredidd662662014-12-13 00:59:43 +010041 for (i = 0; i < oe->numlower; i++)
42 dput(oe->lowerstack[i].dentry);
Miklos Szeredie9be9d52014-10-24 00:14:38 +020043 kfree_rcu(oe, rcu);
44 }
45}
46
Miklos Szeredi2d902672016-06-30 08:53:27 +020047static struct dentry *ovl_d_real(struct dentry *dentry,
48 const struct inode *inode,
49 unsigned int open_flags)
Miklos Szeredid101a122016-03-26 16:14:37 -040050{
51 struct dentry *real;
52
Miklos Szeredica4c8a32016-12-16 11:02:55 +010053 if (!d_is_reg(dentry)) {
Miklos Szeredid101a122016-03-26 16:14:37 -040054 if (!inode || inode == d_inode(dentry))
55 return dentry;
56 goto bug;
57 }
58
Miklos Szeredi2d902672016-06-30 08:53:27 +020059 if (d_is_negative(dentry))
60 return dentry;
61
62 if (open_flags) {
63 int err = ovl_open_maybe_copy_up(dentry, open_flags);
64
65 if (err)
66 return ERR_PTR(err);
67 }
68
Miklos Szeredid101a122016-03-26 16:14:37 -040069 real = ovl_dentry_upper(dentry);
70 if (real && (!inode || inode == d_inode(real)))
71 return real;
72
73 real = ovl_dentry_lower(dentry);
74 if (!real)
75 goto bug;
76
Miklos Szeredic4fcfc12016-11-29 10:20:24 +010077 /* Handle recursion */
78 real = d_real(real, inode, open_flags);
79
Miklos Szeredid101a122016-03-26 16:14:37 -040080 if (!inode || inode == d_inode(real))
81 return real;
Miklos Szeredid101a122016-03-26 16:14:37 -040082bug:
Miklos Szeredi656189d2016-07-29 12:05:24 +020083 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
Miklos Szeredid101a122016-03-26 16:14:37 -040084 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
85 return dentry;
86}
87
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +020088static int ovl_dentry_revalidate(struct dentry *dentry, unsigned int flags)
89{
90 struct ovl_entry *oe = dentry->d_fsdata;
91 unsigned int i;
92 int ret = 1;
93
94 for (i = 0; i < oe->numlower; i++) {
95 struct dentry *d = oe->lowerstack[i].dentry;
96
97 if (d->d_flags & DCACHE_OP_REVALIDATE) {
98 ret = d->d_op->d_revalidate(d, flags);
99 if (ret < 0)
100 return ret;
101 if (!ret) {
102 if (!(flags & LOOKUP_RCU))
103 d_invalidate(d);
104 return -ESTALE;
105 }
106 }
107 }
108 return 1;
109}
110
111static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
112{
113 struct ovl_entry *oe = dentry->d_fsdata;
114 unsigned int i;
115 int ret = 1;
116
117 for (i = 0; i < oe->numlower; i++) {
118 struct dentry *d = oe->lowerstack[i].dentry;
119
120 if (d->d_flags & DCACHE_OP_WEAK_REVALIDATE) {
121 ret = d->d_op->d_weak_revalidate(d, flags);
122 if (ret <= 0)
123 break;
124 }
125 }
126 return ret;
127}
128
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200129static const struct dentry_operations ovl_dentry_operations = {
130 .d_release = ovl_dentry_release,
Miklos Szeredid101a122016-03-26 16:14:37 -0400131 .d_real = ovl_d_real,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200132};
133
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200134static const struct dentry_operations ovl_reval_dentry_operations = {
135 .d_release = ovl_dentry_release,
Miklos Szeredid101a122016-03-26 16:14:37 -0400136 .d_real = ovl_d_real,
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200137 .d_revalidate = ovl_dentry_revalidate,
138 .d_weak_revalidate = ovl_dentry_weak_revalidate,
139};
140
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200141static void ovl_put_super(struct super_block *sb)
142{
143 struct ovl_fs *ufs = sb->s_fs_info;
Miklos Szeredidd662662014-12-13 00:59:43 +0100144 unsigned i;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200145
146 dput(ufs->workdir);
147 mntput(ufs->upper_mnt);
Miklos Szeredidd662662014-12-13 00:59:43 +0100148 for (i = 0; i < ufs->numlower; i++)
149 mntput(ufs->lower_mnt[i]);
Konstantin Khlebnikov5ffdbe82015-08-24 15:57:19 +0300150 kfree(ufs->lower_mnt);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200151
Erez Zadokf45827e82014-10-24 00:14:38 +0200152 kfree(ufs->config.lowerdir);
153 kfree(ufs->config.upperdir);
154 kfree(ufs->config.workdir);
Antonio Murdaca3fe6e522016-04-07 15:48:25 +0200155 put_cred(ufs->creator_cred);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200156 kfree(ufs);
157}
158
Andy Whitcroftcc259632014-10-24 00:14:38 +0200159/**
160 * ovl_statfs
161 * @sb: The overlayfs super block
162 * @buf: The struct kstatfs to fill in with stats
163 *
164 * Get the filesystem statistics. As writes always target the upper layer
Miklos Szeredi4ebc5812014-12-13 00:59:46 +0100165 * filesystem pass the statfs to the upper filesystem (if it exists)
Andy Whitcroftcc259632014-10-24 00:14:38 +0200166 */
167static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
168{
169 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
170 struct dentry *root_dentry = dentry->d_sb->s_root;
171 struct path path;
172 int err;
173
Miklos Szeredi4ebc5812014-12-13 00:59:46 +0100174 ovl_path_real(root_dentry, &path);
Andy Whitcroftcc259632014-10-24 00:14:38 +0200175
176 err = vfs_statfs(&path, buf);
177 if (!err) {
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100178 buf->f_namelen = ofs->namelen;
Andy Whitcroftcc259632014-10-24 00:14:38 +0200179 buf->f_type = OVERLAYFS_SUPER_MAGIC;
180 }
181
182 return err;
183}
184
Erez Zadokf45827e82014-10-24 00:14:38 +0200185/**
186 * ovl_show_options
187 *
188 * Prints the mount options for a given superblock.
189 * Returns zero; does not fail.
190 */
191static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
192{
193 struct super_block *sb = dentry->d_sb;
194 struct ovl_fs *ufs = sb->s_fs_info;
195
Kees Cooka068acf2015-09-04 15:44:57 -0700196 seq_show_option(m, "lowerdir", ufs->config.lowerdir);
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100197 if (ufs->config.upperdir) {
Kees Cooka068acf2015-09-04 15:44:57 -0700198 seq_show_option(m, "upperdir", ufs->config.upperdir);
199 seq_show_option(m, "workdir", ufs->config.workdir);
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100200 }
Miklos Szeredi8d3095f2015-10-12 17:11:44 +0200201 if (ufs->config.default_permissions)
202 seq_puts(m, ",default_permissions");
Erez Zadokf45827e82014-10-24 00:14:38 +0200203 return 0;
204}
205
Seunghun Lee3cdf6fe2015-01-03 02:26:49 +0900206static int ovl_remount(struct super_block *sb, int *flags, char *data)
207{
208 struct ovl_fs *ufs = sb->s_fs_info;
209
Miklos Szeredicc6f67b2015-05-19 14:30:12 +0200210 if (!(*flags & MS_RDONLY) && (!ufs->upper_mnt || !ufs->workdir))
Seunghun Lee3cdf6fe2015-01-03 02:26:49 +0900211 return -EROFS;
212
213 return 0;
214}
215
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200216static const struct super_operations ovl_super_operations = {
217 .put_super = ovl_put_super,
Andy Whitcroftcc259632014-10-24 00:14:38 +0200218 .statfs = ovl_statfs,
Erez Zadokf45827e82014-10-24 00:14:38 +0200219 .show_options = ovl_show_options,
Seunghun Lee3cdf6fe2015-01-03 02:26:49 +0900220 .remount_fs = ovl_remount,
Miklos Szeredieead4f22016-07-29 12:05:22 +0200221 .drop_inode = generic_delete_inode,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200222};
223
224enum {
225 OPT_LOWERDIR,
226 OPT_UPPERDIR,
227 OPT_WORKDIR,
Miklos Szeredi8d3095f2015-10-12 17:11:44 +0200228 OPT_DEFAULT_PERMISSIONS,
Miklos Szeredia6c60652016-12-16 11:02:56 +0100229 OPT_REDIRECT_DIR_ON,
230 OPT_REDIRECT_DIR_OFF,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200231 OPT_ERR,
232};
233
234static const match_table_t ovl_tokens = {
235 {OPT_LOWERDIR, "lowerdir=%s"},
236 {OPT_UPPERDIR, "upperdir=%s"},
237 {OPT_WORKDIR, "workdir=%s"},
Miklos Szeredi8d3095f2015-10-12 17:11:44 +0200238 {OPT_DEFAULT_PERMISSIONS, "default_permissions"},
Miklos Szeredia6c60652016-12-16 11:02:56 +0100239 {OPT_REDIRECT_DIR_ON, "redirect_dir=on"},
240 {OPT_REDIRECT_DIR_OFF, "redirect_dir=off"},
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200241 {OPT_ERR, NULL}
242};
243
Miklos Szeredi91c77942014-11-20 16:40:00 +0100244static char *ovl_next_opt(char **s)
245{
246 char *sbegin = *s;
247 char *p;
248
249 if (sbegin == NULL)
250 return NULL;
251
252 for (p = sbegin; *p; p++) {
253 if (*p == '\\') {
254 p++;
255 if (!*p)
256 break;
257 } else if (*p == ',') {
258 *p = '\0';
259 *s = p + 1;
260 return sbegin;
261 }
262 }
263 *s = NULL;
264 return sbegin;
265}
266
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200267static int ovl_parse_opt(char *opt, struct ovl_config *config)
268{
269 char *p;
270
Miklos Szeredi91c77942014-11-20 16:40:00 +0100271 while ((p = ovl_next_opt(&opt)) != NULL) {
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200272 int token;
273 substring_t args[MAX_OPT_ARGS];
274
275 if (!*p)
276 continue;
277
278 token = match_token(p, ovl_tokens, args);
279 switch (token) {
280 case OPT_UPPERDIR:
281 kfree(config->upperdir);
282 config->upperdir = match_strdup(&args[0]);
283 if (!config->upperdir)
284 return -ENOMEM;
285 break;
286
287 case OPT_LOWERDIR:
288 kfree(config->lowerdir);
289 config->lowerdir = match_strdup(&args[0]);
290 if (!config->lowerdir)
291 return -ENOMEM;
292 break;
293
294 case OPT_WORKDIR:
295 kfree(config->workdir);
296 config->workdir = match_strdup(&args[0]);
297 if (!config->workdir)
298 return -ENOMEM;
299 break;
300
Miklos Szeredi8d3095f2015-10-12 17:11:44 +0200301 case OPT_DEFAULT_PERMISSIONS:
302 config->default_permissions = true;
303 break;
304
Miklos Szeredia6c60652016-12-16 11:02:56 +0100305 case OPT_REDIRECT_DIR_ON:
306 config->redirect_dir = true;
307 break;
308
309 case OPT_REDIRECT_DIR_OFF:
310 config->redirect_dir = false;
311 break;
312
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200313 default:
hujianyangbead55e2015-01-15 13:17:36 +0800314 pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200315 return -EINVAL;
316 }
317 }
hujianyang71cbad72015-01-15 13:20:57 +0800318
319 /* Workdir is useless in non-upper mount */
320 if (!config->upperdir && config->workdir) {
321 pr_info("overlayfs: option \"workdir=%s\" is useless in a non-upper mount, ignore\n",
322 config->workdir);
323 kfree(config->workdir);
324 config->workdir = NULL;
325 }
326
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200327 return 0;
328}
329
330#define OVL_WORKDIR_NAME "work"
331
332static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
333 struct dentry *dentry)
334{
335 struct inode *dir = dentry->d_inode;
336 struct dentry *work;
337 int err;
338 bool retried = false;
339
340 err = mnt_want_write(mnt);
341 if (err)
342 return ERR_PTR(err);
343
Al Viro59551022016-01-22 15:40:57 -0500344 inode_lock_nested(dir, I_MUTEX_PARENT);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200345retry:
346 work = lookup_one_len(OVL_WORKDIR_NAME, dentry,
347 strlen(OVL_WORKDIR_NAME));
348
349 if (!IS_ERR(work)) {
350 struct kstat stat = {
351 .mode = S_IFDIR | 0,
352 };
Miklos Szeredic11b9fd2016-09-01 11:11:59 +0200353 struct iattr attr = {
354 .ia_valid = ATTR_MODE,
355 .ia_mode = stat.mode,
356 };
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200357
358 if (work->d_inode) {
359 err = -EEXIST;
360 if (retried)
361 goto out_dput;
362
363 retried = true;
Miklos Szeredieea2fb42016-09-01 11:11:59 +0200364 ovl_workdir_cleanup(dir, mnt, work, 0);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200365 dput(work);
366 goto retry;
367 }
368
369 err = ovl_create_real(dir, work, &stat, NULL, NULL, true);
370 if (err)
371 goto out_dput;
Miklos Szeredic11b9fd2016-09-01 11:11:59 +0200372
Miklos Szeredicb348ed2016-10-04 14:40:44 +0200373 /*
374 * Try to remove POSIX ACL xattrs from workdir. We are good if:
375 *
376 * a) success (there was a POSIX ACL xattr and was removed)
377 * b) -ENODATA (there was no POSIX ACL xattr)
378 * c) -EOPNOTSUPP (POSIX ACL xattrs are not supported)
379 *
380 * There are various other error values that could effectively
381 * mean that the xattr doesn't exist (e.g. -ERANGE is returned
382 * if the xattr name is too long), but the set of filesystems
383 * allowed as upper are limited to "normal" ones, where checking
384 * for the above two errors is sufficient.
385 */
Miklos Szeredic11b9fd2016-09-01 11:11:59 +0200386 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT);
Miklos Szeredie1ff3dd2016-09-05 13:55:20 +0200387 if (err && err != -ENODATA && err != -EOPNOTSUPP)
Miklos Szeredic11b9fd2016-09-01 11:11:59 +0200388 goto out_dput;
389
390 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS);
Miklos Szeredie1ff3dd2016-09-05 13:55:20 +0200391 if (err && err != -ENODATA && err != -EOPNOTSUPP)
Miklos Szeredic11b9fd2016-09-01 11:11:59 +0200392 goto out_dput;
393
394 /* Clear any inherited mode bits */
395 inode_lock(work->d_inode);
396 err = notify_change(work, &attr, NULL);
397 inode_unlock(work->d_inode);
398 if (err)
399 goto out_dput;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200400 }
401out_unlock:
Al Viro59551022016-01-22 15:40:57 -0500402 inode_unlock(dir);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200403 mnt_drop_write(mnt);
404
405 return work;
406
407out_dput:
408 dput(work);
409 work = ERR_PTR(err);
410 goto out_unlock;
411}
412
Miklos Szeredi91c77942014-11-20 16:40:00 +0100413static void ovl_unescape(char *s)
414{
415 char *d = s;
416
417 for (;; s++, d++) {
418 if (*s == '\\')
419 s++;
420 *d = *s;
421 if (!*s)
422 break;
423 }
424}
425
Miklos Szerediab508822014-12-13 00:59:49 +0100426static int ovl_mount_dir_noesc(const char *name, struct path *path)
427{
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100428 int err = -EINVAL;
Miklos Szerediab508822014-12-13 00:59:49 +0100429
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100430 if (!*name) {
431 pr_err("overlayfs: empty lowerdir\n");
432 goto out;
433 }
Miklos Szerediab508822014-12-13 00:59:49 +0100434 err = kern_path(name, LOOKUP_FOLLOW, path);
435 if (err) {
436 pr_err("overlayfs: failed to resolve '%s': %i\n", name, err);
437 goto out;
438 }
439 err = -EINVAL;
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200440 if (ovl_dentry_weird(path->dentry)) {
Miklos Szerediab508822014-12-13 00:59:49 +0100441 pr_err("overlayfs: filesystem on '%s' not supported\n", name);
442 goto out_put;
443 }
Miklos Szeredi2b8c30e2016-12-16 11:02:56 +0100444 if (!d_is_dir(path->dentry)) {
Miklos Szerediab508822014-12-13 00:59:49 +0100445 pr_err("overlayfs: '%s' not a directory\n", name);
446 goto out_put;
447 }
448 return 0;
449
450out_put:
451 path_put(path);
452out:
453 return err;
454}
455
456static int ovl_mount_dir(const char *name, struct path *path)
457{
458 int err = -ENOMEM;
459 char *tmp = kstrdup(name, GFP_KERNEL);
460
461 if (tmp) {
462 ovl_unescape(tmp);
463 err = ovl_mount_dir_noesc(tmp, path);
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200464
465 if (!err)
466 if (ovl_dentry_remote(path->dentry)) {
467 pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
468 tmp);
469 path_put(path);
470 err = -EINVAL;
471 }
Miklos Szerediab508822014-12-13 00:59:49 +0100472 kfree(tmp);
473 }
474 return err;
475}
476
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100477static int ovl_check_namelen(struct path *path, struct ovl_fs *ofs,
478 const char *name)
479{
480 struct kstatfs statfs;
481 int err = vfs_statfs(path, &statfs);
482
483 if (err)
484 pr_err("overlayfs: statfs failed on '%s'\n", name);
485 else
486 ofs->namelen = max(ofs->namelen, statfs.f_namelen);
487
488 return err;
489}
490
491static int ovl_lower_dir(const char *name, struct path *path,
492 struct ovl_fs *ofs, int *stack_depth, bool *remote)
Miklos Szerediab508822014-12-13 00:59:49 +0100493{
494 int err;
Miklos Szerediab508822014-12-13 00:59:49 +0100495
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100496 err = ovl_mount_dir_noesc(name, path);
Miklos Szerediab508822014-12-13 00:59:49 +0100497 if (err)
498 goto out;
499
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100500 err = ovl_check_namelen(path, ofs, name);
501 if (err)
Miklos Szerediab508822014-12-13 00:59:49 +0100502 goto out_put;
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100503
Miklos Szerediab508822014-12-13 00:59:49 +0100504 *stack_depth = max(*stack_depth, path->mnt->mnt_sb->s_stack_depth);
505
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200506 if (ovl_dentry_remote(path->dentry))
507 *remote = true;
508
Miklos Szerediab508822014-12-13 00:59:49 +0100509 return 0;
510
511out_put:
512 path_put(path);
513out:
514 return err;
515}
516
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200517/* Workdir should not be subdir of upperdir and vice versa */
518static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir)
519{
520 bool ok = false;
521
522 if (workdir != upperdir) {
523 ok = (lock_rename(workdir, upperdir) == NULL);
524 unlock_rename(workdir, upperdir);
525 }
526 return ok;
527}
528
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100529static unsigned int ovl_split_lowerdirs(char *str)
530{
531 unsigned int ctr = 1;
532 char *s, *d;
533
534 for (s = d = str;; s++, d++) {
535 if (*s == '\\') {
536 s++;
537 } else if (*s == ':') {
538 *d = '\0';
539 ctr++;
540 continue;
541 }
542 *d = *s;
543 if (!*s)
544 break;
545 }
546 return ctr;
547}
548
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200549static int __maybe_unused
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200550ovl_posix_acl_xattr_get(const struct xattr_handler *handler,
551 struct dentry *dentry, struct inode *inode,
552 const char *name, void *buffer, size_t size)
553{
554 return ovl_xattr_get(dentry, handler->name, buffer, size);
555}
556
557static int __maybe_unused
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200558ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
559 struct dentry *dentry, struct inode *inode,
560 const char *name, const void *value,
561 size_t size, int flags)
Miklos Szeredid837a492016-07-29 12:05:24 +0200562{
563 struct dentry *workdir = ovl_workdir(dentry);
564 struct inode *realinode = ovl_inode_real(inode, NULL);
565 struct posix_acl *acl = NULL;
566 int err;
567
568 /* Check that everything is OK before copy-up */
569 if (value) {
570 acl = posix_acl_from_xattr(&init_user_ns, value, size);
571 if (IS_ERR(acl))
572 return PTR_ERR(acl);
573 }
574 err = -EOPNOTSUPP;
575 if (!IS_POSIXACL(d_inode(workdir)))
576 goto out_acl_release;
577 if (!realinode->i_op->set_acl)
578 goto out_acl_release;
579 if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) {
580 err = acl ? -EACCES : 0;
581 goto out_acl_release;
582 }
583 err = -EPERM;
584 if (!inode_owner_or_capable(inode))
585 goto out_acl_release;
586
587 posix_acl_release(acl);
588
Miklos Szeredifd3220d2016-10-31 14:42:14 +0100589 /*
590 * Check if sgid bit needs to be cleared (actual setacl operation will
591 * be done with mounter's capabilities and so that won't do it for us).
592 */
593 if (unlikely(inode->i_mode & S_ISGID) &&
594 handler->flags == ACL_TYPE_ACCESS &&
595 !in_group_p(inode->i_gid) &&
596 !capable_wrt_inode_uidgid(inode, CAP_FSETID)) {
597 struct iattr iattr = { .ia_valid = ATTR_KILL_SGID };
598
599 err = ovl_setattr(dentry, &iattr);
600 if (err)
601 return err;
602 }
603
Miklos Szeredice315132016-09-01 11:12:00 +0200604 err = ovl_xattr_set(dentry, handler->name, value, size, flags);
605 if (!err)
606 ovl_copyattr(ovl_inode_real(inode, NULL), inode);
607
608 return err;
Miklos Szeredid837a492016-07-29 12:05:24 +0200609
610out_acl_release:
611 posix_acl_release(acl);
612 return err;
613}
614
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200615static int ovl_own_xattr_get(const struct xattr_handler *handler,
616 struct dentry *dentry, struct inode *inode,
617 const char *name, void *buffer, size_t size)
618{
Amir Goldstein48fab5d2016-11-16 11:22:39 +0200619 return -EOPNOTSUPP;
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200620}
621
Miklos Szeredid837a492016-07-29 12:05:24 +0200622static int ovl_own_xattr_set(const struct xattr_handler *handler,
623 struct dentry *dentry, struct inode *inode,
624 const char *name, const void *value,
625 size_t size, int flags)
626{
Amir Goldstein48fab5d2016-11-16 11:22:39 +0200627 return -EOPNOTSUPP;
Miklos Szeredid837a492016-07-29 12:05:24 +0200628}
629
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200630static int ovl_other_xattr_get(const struct xattr_handler *handler,
631 struct dentry *dentry, struct inode *inode,
632 const char *name, void *buffer, size_t size)
633{
634 return ovl_xattr_get(dentry, name, buffer, size);
635}
636
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200637static int ovl_other_xattr_set(const struct xattr_handler *handler,
638 struct dentry *dentry, struct inode *inode,
639 const char *name, const void *value,
640 size_t size, int flags)
641{
642 return ovl_xattr_set(dentry, name, value, size, flags);
643}
644
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200645static const struct xattr_handler __maybe_unused
646ovl_posix_acl_access_xattr_handler = {
Miklos Szeredid837a492016-07-29 12:05:24 +0200647 .name = XATTR_NAME_POSIX_ACL_ACCESS,
648 .flags = ACL_TYPE_ACCESS,
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200649 .get = ovl_posix_acl_xattr_get,
Miklos Szeredid837a492016-07-29 12:05:24 +0200650 .set = ovl_posix_acl_xattr_set,
651};
652
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200653static const struct xattr_handler __maybe_unused
654ovl_posix_acl_default_xattr_handler = {
Miklos Szeredid837a492016-07-29 12:05:24 +0200655 .name = XATTR_NAME_POSIX_ACL_DEFAULT,
656 .flags = ACL_TYPE_DEFAULT,
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200657 .get = ovl_posix_acl_xattr_get,
Miklos Szeredid837a492016-07-29 12:05:24 +0200658 .set = ovl_posix_acl_xattr_set,
659};
660
661static const struct xattr_handler ovl_own_xattr_handler = {
662 .prefix = OVL_XATTR_PREFIX,
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200663 .get = ovl_own_xattr_get,
Miklos Szeredid837a492016-07-29 12:05:24 +0200664 .set = ovl_own_xattr_set,
665};
666
667static const struct xattr_handler ovl_other_xattr_handler = {
668 .prefix = "", /* catch all */
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200669 .get = ovl_other_xattr_get,
Miklos Szeredid837a492016-07-29 12:05:24 +0200670 .set = ovl_other_xattr_set,
671};
672
673static const struct xattr_handler *ovl_xattr_handlers[] = {
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200674#ifdef CONFIG_FS_POSIX_ACL
Miklos Szeredid837a492016-07-29 12:05:24 +0200675 &ovl_posix_acl_access_xattr_handler,
676 &ovl_posix_acl_default_xattr_handler,
Andreas Gruenbacher0c97be22016-08-22 16:36:49 +0200677#endif
Miklos Szeredid837a492016-07-29 12:05:24 +0200678 &ovl_own_xattr_handler,
679 &ovl_other_xattr_handler,
680 NULL
681};
682
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200683static int ovl_fill_super(struct super_block *sb, void *data, int silent)
684{
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100685 struct path upperpath = { NULL, NULL };
686 struct path workpath = { NULL, NULL };
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200687 struct dentry *root_dentry;
Miklos Szeredi39b681f2016-07-29 12:05:24 +0200688 struct inode *realinode;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200689 struct ovl_entry *oe;
690 struct ovl_fs *ufs;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100691 struct path *stack = NULL;
692 char *lowertmp;
693 char *lower;
694 unsigned int numlower;
695 unsigned int stacklen = 0;
Miklos Szeredidd662662014-12-13 00:59:43 +0100696 unsigned int i;
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200697 bool remote = false;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200698 int err;
699
Erez Zadokf45827e82014-10-24 00:14:38 +0200700 err = -ENOMEM;
701 ufs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
702 if (!ufs)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200703 goto out;
704
Erez Zadokf45827e82014-10-24 00:14:38 +0200705 err = ovl_parse_opt((char *) data, &ufs->config);
706 if (err)
707 goto out_free_config;
708
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200709 err = -EINVAL;
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100710 if (!ufs->config.lowerdir) {
Konstantin Khlebnikov07f2af72015-06-29 20:18:56 +0300711 if (!silent)
712 pr_err("overlayfs: missing 'lowerdir'\n");
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200713 goto out_free_config;
714 }
715
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100716 sb->s_stack_depth = 0;
Miklos Szeredicf9a6782015-12-11 16:30:49 +0100717 sb->s_maxbytes = MAX_LFS_FILESIZE;
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100718 if (ufs->config.upperdir) {
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100719 if (!ufs->config.workdir) {
720 pr_err("overlayfs: missing 'workdir'\n");
721 goto out_free_config;
722 }
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200723
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100724 err = ovl_mount_dir(ufs->config.upperdir, &upperpath);
725 if (err)
726 goto out_free_config;
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100727
hujianyang71cbad72015-01-15 13:20:57 +0800728 /* Upper fs should not be r/o */
729 if (upperpath.mnt->mnt_sb->s_flags & MS_RDONLY) {
730 pr_err("overlayfs: upper fs is r/o, try multi-lower layers mount\n");
731 err = -EINVAL;
732 goto out_put_upperpath;
733 }
734
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100735 err = ovl_check_namelen(&upperpath, ufs, ufs->config.upperdir);
736 if (err)
737 goto out_put_upperpath;
738
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100739 err = ovl_mount_dir(ufs->config.workdir, &workpath);
740 if (err)
741 goto out_put_upperpath;
742
hujianyang2f83fd82015-01-06 12:52:13 +0800743 err = -EINVAL;
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100744 if (upperpath.mnt != workpath.mnt) {
745 pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
746 goto out_put_workpath;
747 }
748 if (!ovl_workdir_ok(workpath.dentry, upperpath.dentry)) {
749 pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
750 goto out_put_workpath;
751 }
752 sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth;
Miklos Szerediab508822014-12-13 00:59:49 +0100753 }
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100754 err = -ENOMEM;
755 lowertmp = kstrdup(ufs->config.lowerdir, GFP_KERNEL);
756 if (!lowertmp)
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100757 goto out_put_workpath;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200758
759 err = -EINVAL;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100760 stacklen = ovl_split_lowerdirs(lowertmp);
hujianyang6be45062015-01-15 13:19:21 +0800761 if (stacklen > OVL_MAX_STACK) {
Colin Ian Kingfd365702016-08-18 16:58:35 +0100762 pr_err("overlayfs: too many lower directories, limit is %d\n",
hujianyang6be45062015-01-15 13:19:21 +0800763 OVL_MAX_STACK);
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100764 goto out_free_lowertmp;
hujianyang6be45062015-01-15 13:19:21 +0800765 } else if (!ufs->config.upperdir && stacklen == 1) {
766 pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
767 goto out_free_lowertmp;
768 }
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100769
770 stack = kcalloc(stacklen, sizeof(struct path), GFP_KERNEL);
771 if (!stack)
772 goto out_free_lowertmp;
773
774 lower = lowertmp;
775 for (numlower = 0; numlower < stacklen; numlower++) {
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +0100776 err = ovl_lower_dir(lower, &stack[numlower], ufs,
777 &sb->s_stack_depth, &remote);
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100778 if (err)
779 goto out_put_lowerpath;
780
781 lower = strchr(lower, '\0') + 1;
782 }
783
784 err = -EINVAL;
Miklos Szerediab508822014-12-13 00:59:49 +0100785 sb->s_stack_depth++;
Miklos Szeredi69c433e2014-10-24 00:14:39 +0200786 if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
787 pr_err("overlayfs: maximum fs stacking depth exceeded\n");
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100788 goto out_put_lowerpath;
Miklos Szeredi69c433e2014-10-24 00:14:39 +0200789 }
790
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100791 if (ufs->config.upperdir) {
792 ufs->upper_mnt = clone_private_mount(&upperpath);
793 err = PTR_ERR(ufs->upper_mnt);
794 if (IS_ERR(ufs->upper_mnt)) {
795 pr_err("overlayfs: failed to clone upperpath\n");
796 goto out_put_lowerpath;
797 }
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200798 /* Don't inherit atime flags */
799 ufs->upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME);
800
801 sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran;
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100802
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100803 ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
804 err = PTR_ERR(ufs->workdir);
805 if (IS_ERR(ufs->workdir)) {
Miklos Szeredicc6f67b2015-05-19 14:30:12 +0200806 pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
807 ufs->config.workdir, OVL_WORKDIR_NAME, -err);
808 sb->s_flags |= MS_RDONLY;
809 ufs->workdir = NULL;
Miklos Szeredi53a08cb2014-12-13 00:59:51 +0100810 }
Vivek Goyal45aebea2016-02-22 09:28:34 -0500811
812 /*
813 * Upper should support d_type, else whiteouts are visible.
814 * Given workdir and upper are on same fs, we can do
Vivek Goyal21765192016-05-20 09:04:26 -0400815 * iterate_dir() on workdir. This check requires successful
816 * creation of workdir in previous step.
Vivek Goyal45aebea2016-02-22 09:28:34 -0500817 */
Vivek Goyal21765192016-05-20 09:04:26 -0400818 if (ufs->workdir) {
819 err = ovl_check_d_type_supported(&workpath);
820 if (err < 0)
821 goto out_put_workdir;
Vivek Goyal45aebea2016-02-22 09:28:34 -0500822
Vivek Goyale7c0b592016-07-01 10:02:44 -0400823 /*
824 * We allowed this configuration and don't want to
825 * break users over kernel upgrade. So warn instead
826 * of erroring out.
827 */
828 if (!err)
829 pr_warn("overlayfs: upper fs needs to support d_type.\n");
Vivek Goyal45aebea2016-02-22 09:28:34 -0500830 }
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200831 }
832
hujianyang2f83fd82015-01-06 12:52:13 +0800833 err = -ENOMEM;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100834 ufs->lower_mnt = kcalloc(numlower, sizeof(struct vfsmount *), GFP_KERNEL);
Miklos Szeredidd662662014-12-13 00:59:43 +0100835 if (ufs->lower_mnt == NULL)
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100836 goto out_put_workdir;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100837 for (i = 0; i < numlower; i++) {
838 struct vfsmount *mnt = clone_private_mount(&stack[i]);
Miklos Szeredidd662662014-12-13 00:59:43 +0100839
hujianyang2f83fd82015-01-06 12:52:13 +0800840 err = PTR_ERR(mnt);
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100841 if (IS_ERR(mnt)) {
842 pr_err("overlayfs: failed to clone lowerpath\n");
843 goto out_put_lower_mnt;
844 }
845 /*
846 * Make lower_mnt R/O. That way fchmod/fchown on lower file
847 * will fail instead of modifying lower fs.
848 */
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200849 mnt->mnt_flags |= MNT_READONLY | MNT_NOATIME;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100850
851 ufs->lower_mnt[ufs->numlower] = mnt;
852 ufs->numlower++;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200853 }
854
hujianyang71cbad72015-01-15 13:20:57 +0800855 /* If the upper fs is nonexistent, we mark overlayfs r/o too */
856 if (!ufs->upper_mnt)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200857 sb->s_flags |= MS_RDONLY;
858
Miklos Szeredi7c03b5d2015-06-22 13:53:48 +0200859 if (remote)
860 sb->s_d_op = &ovl_reval_dentry_operations;
861 else
862 sb->s_d_op = &ovl_dentry_operations;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200863
Antonio Murdaca3fe6e522016-04-07 15:48:25 +0200864 ufs->creator_cred = prepare_creds();
865 if (!ufs->creator_cred)
866 goto out_put_lower_mnt;
867
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200868 err = -ENOMEM;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100869 oe = ovl_alloc_entry(numlower);
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100870 if (!oe)
Antonio Murdaca3fe6e522016-04-07 15:48:25 +0200871 goto out_put_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200872
Vivek Goyal655042c2016-10-14 03:03:36 +0200873 sb->s_magic = OVERLAYFS_SUPER_MAGIC;
874 sb->s_op = &ovl_super_operations;
875 sb->s_xattr = ovl_xattr_handlers;
876 sb->s_fs_info = ufs;
877 sb->s_flags |= MS_POSIXACL | MS_NOREMOTELOCK;
878
Miklos Szeredica4c8a32016-12-16 11:02:55 +0100879 root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0));
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200880 if (!root_dentry)
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100881 goto out_free_oe;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200882
883 mntput(upperpath.mnt);
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100884 for (i = 0; i < numlower; i++)
885 mntput(stack[i].mnt);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200886 path_put(&workpath);
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100887 kfree(lowertmp);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200888
889 oe->__upperdentry = upperpath.dentry;
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100890 for (i = 0; i < numlower; i++) {
891 oe->lowerstack[i].dentry = stack[i].dentry;
892 oe->lowerstack[i].mnt = ufs->lower_mnt[i];
893 }
Konstantin Khlebnikov0f955022015-08-24 15:57:18 +0300894 kfree(stack);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200895
896 root_dentry->d_fsdata = oe;
897
Miklos Szeredi39b681f2016-07-29 12:05:24 +0200898 realinode = d_inode(ovl_dentry_real(root_dentry));
899 ovl_inode_init(d_inode(root_dentry), realinode, !!upperpath.dentry);
900 ovl_copyattr(realinode, d_inode(root_dentry));
Miklos Szeredied06e062015-12-09 16:11:59 +0100901
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200902 sb->s_root = root_dentry;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200903
904 return 0;
905
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100906out_free_oe:
907 kfree(oe);
Antonio Murdaca3fe6e522016-04-07 15:48:25 +0200908out_put_cred:
909 put_cred(ufs->creator_cred);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200910out_put_lower_mnt:
Miklos Szeredidd662662014-12-13 00:59:43 +0100911 for (i = 0; i < ufs->numlower; i++)
912 mntput(ufs->lower_mnt[i]);
913 kfree(ufs->lower_mnt);
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100914out_put_workdir:
915 dput(ufs->workdir);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200916 mntput(ufs->upper_mnt);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200917out_put_lowerpath:
Miklos Szeredia78d9f02014-12-13 00:59:52 +0100918 for (i = 0; i < numlower; i++)
919 path_put(&stack[i]);
920 kfree(stack);
921out_free_lowertmp:
922 kfree(lowertmp);
Miklos Szeredi3b7a9a22014-12-13 00:59:48 +0100923out_put_workpath:
924 path_put(&workpath);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200925out_put_upperpath:
926 path_put(&upperpath);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200927out_free_config:
Erez Zadokf45827e82014-10-24 00:14:38 +0200928 kfree(ufs->config.lowerdir);
929 kfree(ufs->config.upperdir);
930 kfree(ufs->config.workdir);
931 kfree(ufs);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200932out:
933 return err;
934}
935
936static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
937 const char *dev_name, void *raw_data)
938{
939 return mount_nodev(fs_type, flags, raw_data, ovl_fill_super);
940}
941
942static struct file_system_type ovl_fs_type = {
943 .owner = THIS_MODULE,
Miklos Szeredief94b182014-11-20 16:39:59 +0100944 .name = "overlay",
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200945 .mount = ovl_mount,
946 .kill_sb = kill_anon_super,
947};
Miklos Szeredief94b182014-11-20 16:39:59 +0100948MODULE_ALIAS_FS("overlay");
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200949
950static int __init ovl_init(void)
951{
952 return register_filesystem(&ovl_fs_type);
953}
954
955static void __exit ovl_exit(void)
956{
957 unregister_filesystem(&ovl_fs_type);
958}
959
960module_init(ovl_init);
961module_exit(ovl_exit);