blob: ce5d7dfaf7693736ec08464677b78e0f40da26fb [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/slab.h>
12#include <linux/xattr.h>
Miklos Szeredi5201dc42016-09-01 11:11:59 +020013#include <linux/posix_acl.h>
Miklos Szeredie9be9d52014-10-24 00:14:38 +020014#include "overlayfs.h"
15
Al Viro0f7ff2d2015-12-06 12:31:07 -050016static int ovl_copy_up_truncate(struct dentry *dentry)
Miklos Szeredie9be9d52014-10-24 00:14:38 +020017{
18 int err;
19 struct dentry *parent;
20 struct kstat stat;
21 struct path lowerpath;
Vivek Goyal8eac98b2016-09-06 13:40:32 -040022 const struct cred *old_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +020023
24 parent = dget_parent(dentry);
25 err = ovl_copy_up(parent);
26 if (err)
27 goto out_dput_parent;
28
29 ovl_path_lower(dentry, &lowerpath);
Miklos Szeredie9be9d52014-10-24 00:14:38 +020030
Vivek Goyal8eac98b2016-09-06 13:40:32 -040031 old_cred = ovl_override_creds(dentry->d_sb);
32 err = vfs_getattr(&lowerpath, &stat);
33 if (!err) {
34 stat.size = 0;
35 err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat);
36 }
37 revert_creds(old_cred);
Miklos Szeredie9be9d52014-10-24 00:14:38 +020038
39out_dput_parent:
40 dput(parent);
41 return err;
42}
43
44int ovl_setattr(struct dentry *dentry, struct iattr *attr)
45{
46 int err;
47 struct dentry *upperdentry;
Vivek Goyal1175b6b2016-07-01 16:34:28 -040048 const struct cred *old_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +020049
Miklos Szeredicf9a6782015-12-11 16:30:49 +010050 /*
51 * Check for permissions before trying to copy-up. This is redundant
52 * since it will be rechecked later by ->setattr() on upper dentry. But
53 * without this, copy-up can be triggered by just about anybody.
54 *
55 * We don't initialize inode->size, which just means that
56 * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not
57 * check for a swapfile (which this won't be anyway).
58 */
59 err = inode_change_ok(dentry->d_inode, attr);
60 if (err)
61 return err;
62
Miklos Szeredie9be9d52014-10-24 00:14:38 +020063 err = ovl_want_write(dentry);
64 if (err)
65 goto out;
66
Miklos Szeredi03bea602016-06-29 16:03:55 +020067 if (attr->ia_valid & ATTR_SIZE) {
68 struct inode *realinode = d_inode(ovl_dentry_real(dentry));
69
70 err = -ETXTBSY;
71 if (atomic_read(&realinode->i_writecount) < 0)
72 goto out_drop_write;
73 }
74
Miklos Szerediacff81e2015-12-04 19:18:48 +010075 err = ovl_copy_up(dentry);
76 if (!err) {
Miklos Szeredi03bea602016-06-29 16:03:55 +020077 struct inode *winode = NULL;
78
Miklos Szerediacff81e2015-12-04 19:18:48 +010079 upperdentry = ovl_dentry_upper(dentry);
80
Miklos Szeredi03bea602016-06-29 16:03:55 +020081 if (attr->ia_valid & ATTR_SIZE) {
82 winode = d_inode(upperdentry);
83 err = get_write_access(winode);
84 if (err)
85 goto out_drop_write;
86 }
87
Miklos Szeredib99c2d92016-07-04 16:49:48 +020088 if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
89 attr->ia_valid &= ~ATTR_MODE;
90
Al Viro59551022016-01-22 15:40:57 -050091 inode_lock(upperdentry->d_inode);
Vivek Goyal1175b6b2016-07-01 16:34:28 -040092 old_cred = ovl_override_creds(dentry->d_sb);
Miklos Szeredie9be9d52014-10-24 00:14:38 +020093 err = notify_change(upperdentry, attr, NULL);
Vivek Goyal1175b6b2016-07-01 16:34:28 -040094 revert_creds(old_cred);
Konstantin Khlebnikovb81de062016-01-31 16:21:29 +030095 if (!err)
96 ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
Al Viro59551022016-01-22 15:40:57 -050097 inode_unlock(upperdentry->d_inode);
Miklos Szeredi03bea602016-06-29 16:03:55 +020098
99 if (winode)
100 put_write_access(winode);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200101 }
Miklos Szeredi03bea602016-06-29 16:03:55 +0200102out_drop_write:
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200103 ovl_drop_write(dentry);
104out:
105 return err;
106}
107
108static int ovl_getattr(struct vfsmount *mnt, struct dentry *dentry,
109 struct kstat *stat)
110{
111 struct path realpath;
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400112 const struct cred *old_cred;
113 int err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200114
115 ovl_path_real(dentry, &realpath);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400116 old_cred = ovl_override_creds(dentry->d_sb);
117 err = vfs_getattr(&realpath, stat);
118 revert_creds(old_cred);
119 return err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200120}
121
122int ovl_permission(struct inode *inode, int mask)
123{
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200124 bool is_upper;
Miklos Szeredi39b681f2016-07-29 12:05:24 +0200125 struct inode *realinode = ovl_inode_real(inode, &is_upper);
Vivek Goyalc0ca3d72016-07-01 16:34:27 -0400126 const struct cred *old_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200127 int err;
128
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200129 /* Careful in RCU walk mode */
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200130 if (!realinode) {
131 WARN_ON(!(mask & MAY_NOT_BLOCK));
Miklos Szeredia999d7e2016-07-29 12:05:23 +0200132 return -ECHILD;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200133 }
134
Vivek Goyalc0ca3d72016-07-01 16:34:27 -0400135 /*
136 * Check overlay inode with the creds of task and underlying inode
137 * with creds of mounter
138 */
139 err = generic_permission(inode, mask);
140 if (err)
141 return err;
142
143 old_cred = ovl_override_creds(inode->i_sb);
Vivek Goyal500cac32016-07-13 11:00:14 -0400144 if (!is_upper && !special_file(realinode->i_mode) && mask & MAY_WRITE) {
Vivek Goyal754f8cb2016-07-01 16:34:29 -0400145 mask &= ~(MAY_WRITE | MAY_APPEND);
Vivek Goyal500cac32016-07-13 11:00:14 -0400146 /* Make sure mounter can read file for copy up later */
147 mask |= MAY_READ;
148 }
Miklos Szeredi9c630eb2016-07-29 12:05:23 +0200149 err = inode_permission(realinode, mask);
Vivek Goyalc0ca3d72016-07-01 16:34:27 -0400150 revert_creds(old_cred);
151
152 return err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200153}
154
Al Viro6b255392015-11-17 10:20:54 -0500155static const char *ovl_get_link(struct dentry *dentry,
Al Virofceef392015-12-29 15:58:39 -0500156 struct inode *inode,
157 struct delayed_call *done)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200158{
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200159 struct dentry *realdentry;
160 struct inode *realinode;
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400161 const struct cred *old_cred;
162 const char *p;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200163
Al Viro6b255392015-11-17 10:20:54 -0500164 if (!dentry)
165 return ERR_PTR(-ECHILD);
166
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200167 realdentry = ovl_dentry_real(dentry);
168 realinode = realdentry->d_inode;
169
Al Viro6b255392015-11-17 10:20:54 -0500170 if (WARN_ON(!realinode->i_op->get_link))
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200171 return ERR_PTR(-EPERM);
172
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400173 old_cred = ovl_override_creds(dentry->d_sb);
174 p = realinode->i_op->get_link(realdentry, realinode, done);
175 revert_creds(old_cred);
176 return p;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200177}
178
179static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)
180{
181 struct path realpath;
182 struct inode *realinode;
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400183 const struct cred *old_cred;
184 int err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200185
186 ovl_path_real(dentry, &realpath);
187 realinode = realpath.dentry->d_inode;
188
189 if (!realinode->i_op->readlink)
190 return -EINVAL;
191
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400192 old_cred = ovl_override_creds(dentry->d_sb);
193 err = realinode->i_op->readlink(realpath.dentry, buf, bufsiz);
194 revert_creds(old_cred);
195 return err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200196}
197
Miklos Szeredi09562542016-08-08 15:08:49 +0200198bool ovl_is_private_xattr(const char *name)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200199{
Andreas Gruenbacherfe2b7592016-08-22 17:59:22 +0200200 return strncmp(name, OVL_XATTR_PREFIX,
201 sizeof(OVL_XATTR_PREFIX) - 1) == 0;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200202}
203
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200204int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
205 size_t size, int flags)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200206{
207 int err;
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200208 struct path realpath;
209 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400210 const struct cred *old_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200211
212 err = ovl_want_write(dentry);
213 if (err)
214 goto out;
215
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200216 if (!value && !OVL_TYPE_UPPER(type)) {
217 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
218 if (err < 0)
219 goto out_drop_write;
220 }
221
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200222 err = ovl_copy_up(dentry);
223 if (err)
224 goto out_drop_write;
225
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200226 if (!OVL_TYPE_UPPER(type))
227 ovl_path_upper(dentry, &realpath);
228
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400229 old_cred = ovl_override_creds(dentry->d_sb);
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200230 if (value)
231 err = vfs_setxattr(realpath.dentry, name, value, size, flags);
232 else {
233 WARN_ON(flags != XATTR_REPLACE);
234 err = vfs_removexattr(realpath.dentry, name);
235 }
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400236 revert_creds(old_cred);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200237
238out_drop_write:
239 ovl_drop_write(dentry);
240out:
241 return err;
242}
243
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200244int ovl_xattr_get(struct dentry *dentry, const char *name,
245 void *value, size_t size)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200246{
Miklos Szeredib5817552016-06-06 16:21:37 +0200247 struct dentry *realdentry = ovl_dentry_real(dentry);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400248 ssize_t res;
249 const struct cred *old_cred;
Miklos Szeredi52148462014-11-20 16:40:00 +0100250
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400251 old_cred = ovl_override_creds(dentry->d_sb);
252 res = vfs_getxattr(realdentry, name, value, size);
253 revert_creds(old_cred);
254 return res;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200255}
256
257ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
258{
Miklos Szeredib5817552016-06-06 16:21:37 +0200259 struct dentry *realdentry = ovl_dentry_real(dentry);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200260 ssize_t res;
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200261 size_t len;
262 char *s;
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400263 const struct cred *old_cred;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200264
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400265 old_cred = ovl_override_creds(dentry->d_sb);
Miklos Szeredib5817552016-06-06 16:21:37 +0200266 res = vfs_listxattr(realdentry, list, size);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400267 revert_creds(old_cred);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200268 if (res <= 0 || size == 0)
269 return res;
270
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200271 /* filter out private xattrs */
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200272 for (s = list, len = res; len;) {
273 size_t slen = strnlen(s, len) + 1;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200274
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200275 /* underlying fs providing us with an broken xattr list? */
276 if (WARN_ON(slen > len))
277 return -EIO;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200278
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200279 len -= slen;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200280 if (ovl_is_private_xattr(s)) {
281 res -= slen;
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200282 memmove(s, s + slen, len);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200283 } else {
Miklos Szeredi7cb35112016-09-01 11:12:00 +0200284 s += slen;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200285 }
286 }
287
288 return res;
289}
290
Vivek Goyal39a25b22016-07-01 16:34:26 -0400291struct posix_acl *ovl_get_acl(struct inode *inode, int type)
292{
Miklos Szeredi39b681f2016-07-29 12:05:24 +0200293 struct inode *realinode = ovl_inode_real(inode, NULL);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400294 const struct cred *old_cred;
295 struct posix_acl *acl;
Vivek Goyal39a25b22016-07-01 16:34:26 -0400296
Miklos Szeredi5201dc42016-09-01 11:11:59 +0200297 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
Vivek Goyal39a25b22016-07-01 16:34:26 -0400298 return NULL;
299
300 if (!realinode->i_op->get_acl)
301 return NULL;
302
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400303 old_cred = ovl_override_creds(inode->i_sb);
Miklos Szeredi5201dc42016-09-01 11:11:59 +0200304 acl = get_acl(realinode, type);
Vivek Goyal1175b6b2016-07-01 16:34:28 -0400305 revert_creds(old_cred);
306
307 return acl;
Vivek Goyal39a25b22016-07-01 16:34:26 -0400308}
309
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200310static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
311 struct dentry *realdentry)
312{
Miklos Szeredi1afaba12014-12-13 00:59:42 +0100313 if (OVL_TYPE_UPPER(type))
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200314 return false;
315
316 if (special_file(realdentry->d_inode->i_mode))
317 return false;
318
319 if (!(OPEN_FMODE(flags) & FMODE_WRITE) && !(flags & O_TRUNC))
320 return false;
321
322 return true;
323}
324
Miklos Szeredi2d902672016-06-30 08:53:27 +0200325int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200326{
Miklos Szeredi2d902672016-06-30 08:53:27 +0200327 int err = 0;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200328 struct path realpath;
329 enum ovl_path_type type;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200330
331 type = ovl_path_real(dentry, &realpath);
David Howells4bacc9c2015-06-18 14:32:31 +0100332 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200333 err = ovl_want_write(dentry);
Miklos Szeredi2d902672016-06-30 08:53:27 +0200334 if (!err) {
335 if (file_flags & O_TRUNC)
336 err = ovl_copy_up_truncate(dentry);
337 else
338 err = ovl_copy_up(dentry);
339 ovl_drop_write(dentry);
340 }
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200341 }
342
Miklos Szeredi2d902672016-06-30 08:53:27 +0200343 return err;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200344}
345
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200346int ovl_update_time(struct inode *inode, struct timespec *ts, int flags)
347{
348 struct dentry *alias;
349 struct path upperpath;
350
351 if (!(flags & S_ATIME))
352 return 0;
353
354 alias = d_find_any_alias(inode);
355 if (!alias)
356 return 0;
357
358 ovl_path_upper(alias, &upperpath);
359 if (upperpath.dentry) {
360 touch_atime(&upperpath);
361 inode->i_atime = d_inode(upperpath.dentry)->i_atime;
362 }
363
364 dput(alias);
365
366 return 0;
367}
368
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200369static const struct inode_operations ovl_file_inode_operations = {
370 .setattr = ovl_setattr,
371 .permission = ovl_permission,
372 .getattr = ovl_getattr,
Miklos Szeredid837a492016-07-29 12:05:24 +0200373 .setxattr = generic_setxattr,
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200374 .getxattr = generic_getxattr,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200375 .listxattr = ovl_listxattr,
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200376 .removexattr = generic_removexattr,
Vivek Goyal39a25b22016-07-01 16:34:26 -0400377 .get_acl = ovl_get_acl,
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200378 .update_time = ovl_update_time,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200379};
380
381static const struct inode_operations ovl_symlink_inode_operations = {
382 .setattr = ovl_setattr,
Al Viro6b255392015-11-17 10:20:54 -0500383 .get_link = ovl_get_link,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200384 .readlink = ovl_readlink,
385 .getattr = ovl_getattr,
Miklos Szeredid837a492016-07-29 12:05:24 +0200386 .setxattr = generic_setxattr,
Andreas Gruenbacher0eb45fc2016-08-22 17:52:55 +0200387 .getxattr = generic_getxattr,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200388 .listxattr = ovl_listxattr,
Andreas Gruenbacher0e585cc2016-08-22 17:22:11 +0200389 .removexattr = generic_removexattr,
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200390 .update_time = ovl_update_time,
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200391};
392
Miklos Szeredi51f7e522016-07-29 12:05:24 +0200393static void ovl_fill_inode(struct inode *inode, umode_t mode)
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200394{
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200395 inode->i_ino = get_next_ino();
396 inode->i_mode = mode;
Miklos Szeredid719e8f2016-07-29 12:05:23 +0200397 inode->i_flags |= S_NOCMTIME;
Miklos Szeredi2a3a2a32016-09-01 11:11:59 +0200398#ifdef CONFIG_FS_POSIX_ACL
399 inode->i_acl = inode->i_default_acl = ACL_DONT_CACHE;
400#endif
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200401
Vivek Goyal07a2daa2016-07-01 16:34:25 -0400402 mode &= S_IFMT;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200403 switch (mode) {
404 case S_IFDIR:
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200405 inode->i_op = &ovl_dir_inode_operations;
406 inode->i_fop = &ovl_dir_operations;
407 break;
408
409 case S_IFLNK:
410 inode->i_op = &ovl_symlink_inode_operations;
411 break;
412
Miklos Szeredi51f7e522016-07-29 12:05:24 +0200413 default:
414 WARN(1, "illegal file type: %i\n", mode);
415 /* Fall through */
416
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200417 case S_IFREG:
418 case S_IFSOCK:
419 case S_IFBLK:
420 case S_IFCHR:
421 case S_IFIFO:
422 inode->i_op = &ovl_file_inode_operations;
423 break;
Miklos Szeredi51f7e522016-07-29 12:05:24 +0200424 }
425}
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200426
Miklos Szeredi51f7e522016-07-29 12:05:24 +0200427struct inode *ovl_new_inode(struct super_block *sb, umode_t mode)
428{
429 struct inode *inode;
430
431 inode = new_inode(sb);
432 if (inode)
433 ovl_fill_inode(inode, mode);
434
435 return inode;
436}
437
438static int ovl_inode_test(struct inode *inode, void *data)
439{
440 return ovl_inode_real(inode, NULL) == data;
441}
442
443static int ovl_inode_set(struct inode *inode, void *data)
444{
445 inode->i_private = (void *) (((unsigned long) data) | OVL_ISUPPER_MASK);
446 return 0;
447}
448
449struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode)
450
451{
452 struct inode *inode;
453
454 inode = iget5_locked(sb, (unsigned long) realinode,
455 ovl_inode_test, ovl_inode_set, realinode);
456 if (inode && inode->i_state & I_NEW) {
457 ovl_fill_inode(inode, realinode->i_mode);
458 set_nlink(inode, realinode->i_nlink);
459 unlock_new_inode(inode);
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200460 }
461
462 return inode;
Miklos Szeredie9be9d52014-10-24 00:14:38 +0200463}