inode.c (fe2b75952347762a21f67d9df1199137ae5988b2) inode.c (0e585ccc13b3edbb187fb4f1b7cc9397f17d64a9)
1/*
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 */

--- 184 unchanged lines hidden (view full) ---

193}
194
195bool ovl_is_private_xattr(const char *name)
196{
197 return strncmp(name, OVL_XATTR_PREFIX,
198 sizeof(OVL_XATTR_PREFIX) - 1) == 0;
199}
200
1/*
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 */

--- 184 unchanged lines hidden (view full) ---

193}
194
195bool ovl_is_private_xattr(const char *name)
196{
197 return strncmp(name, OVL_XATTR_PREFIX,
198 sizeof(OVL_XATTR_PREFIX) - 1) == 0;
199}
200
201int ovl_setxattr(struct dentry *dentry, struct inode *inode,
202 const char *name, const void *value,
203 size_t size, int flags)
201int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
202 size_t size, int flags)
204{
205 int err;
203{
204 int err;
206 struct dentry *upperdentry;
205 struct path realpath;
206 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
207 const struct cred *old_cred;
208
209 err = ovl_want_write(dentry);
210 if (err)
211 goto out;
212
207 const struct cred *old_cred;
208
209 err = ovl_want_write(dentry);
210 if (err)
211 goto out;
212
213 if (!value && !OVL_TYPE_UPPER(type)) {
214 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
215 if (err < 0)
216 goto out_drop_write;
217 }
218
213 err = ovl_copy_up(dentry);
214 if (err)
215 goto out_drop_write;
216
219 err = ovl_copy_up(dentry);
220 if (err)
221 goto out_drop_write;
222
217 upperdentry = ovl_dentry_upper(dentry);
223 if (!OVL_TYPE_UPPER(type))
224 ovl_path_upper(dentry, &realpath);
225
218 old_cred = ovl_override_creds(dentry->d_sb);
226 old_cred = ovl_override_creds(dentry->d_sb);
219 err = vfs_setxattr(upperdentry, name, value, size, flags);
227 if (value)
228 err = vfs_setxattr(realpath.dentry, name, value, size, flags);
229 else {
230 WARN_ON(flags != XATTR_REPLACE);
231 err = vfs_removexattr(realpath.dentry, name);
232 }
220 revert_creds(old_cred);
221
222out_drop_write:
223 ovl_drop_write(dentry);
224out:
225 return err;
226}
227

--- 39 unchanged lines hidden (view full) ---

267 } else {
268 off += slen;
269 }
270 }
271
272 return res;
273}
274
233 revert_creds(old_cred);
234
235out_drop_write:
236 ovl_drop_write(dentry);
237out:
238 return err;
239}
240

--- 39 unchanged lines hidden (view full) ---

280 } else {
281 off += slen;
282 }
283 }
284
285 return res;
286}
287
275int ovl_removexattr(struct dentry *dentry, const char *name)
276{
277 int err;
278 struct path realpath;
279 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
280 const struct cred *old_cred;
281
282 err = ovl_want_write(dentry);
283 if (err)
284 goto out;
285
286 err = -ENODATA;
287 if (ovl_is_private_xattr(name))
288 goto out_drop_write;
289
290 if (!OVL_TYPE_UPPER(type)) {
291 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
292 if (err < 0)
293 goto out_drop_write;
294
295 err = ovl_copy_up(dentry);
296 if (err)
297 goto out_drop_write;
298
299 ovl_path_upper(dentry, &realpath);
300 }
301
302 old_cred = ovl_override_creds(dentry->d_sb);
303 err = vfs_removexattr(realpath.dentry, name);
304 revert_creds(old_cred);
305out_drop_write:
306 ovl_drop_write(dentry);
307out:
308 return err;
309}
310
311struct posix_acl *ovl_get_acl(struct inode *inode, int type)
312{
313 struct inode *realinode = ovl_inode_real(inode, NULL);
314 const struct cred *old_cred;
315 struct posix_acl *acl;
316
317 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
318 return NULL;

--- 69 unchanged lines hidden (view full) ---

388
389static const struct inode_operations ovl_file_inode_operations = {
390 .setattr = ovl_setattr,
391 .permission = ovl_permission,
392 .getattr = ovl_getattr,
393 .setxattr = generic_setxattr,
394 .getxattr = ovl_getxattr,
395 .listxattr = ovl_listxattr,
288struct posix_acl *ovl_get_acl(struct inode *inode, int type)
289{
290 struct inode *realinode = ovl_inode_real(inode, NULL);
291 const struct cred *old_cred;
292 struct posix_acl *acl;
293
294 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
295 return NULL;

--- 69 unchanged lines hidden (view full) ---

365
366static const struct inode_operations ovl_file_inode_operations = {
367 .setattr = ovl_setattr,
368 .permission = ovl_permission,
369 .getattr = ovl_getattr,
370 .setxattr = generic_setxattr,
371 .getxattr = ovl_getxattr,
372 .listxattr = ovl_listxattr,
396 .removexattr = ovl_removexattr,
373 .removexattr = generic_removexattr,
397 .get_acl = ovl_get_acl,
398 .update_time = ovl_update_time,
399};
400
401static const struct inode_operations ovl_symlink_inode_operations = {
402 .setattr = ovl_setattr,
403 .get_link = ovl_get_link,
404 .readlink = ovl_readlink,
405 .getattr = ovl_getattr,
406 .setxattr = generic_setxattr,
407 .getxattr = ovl_getxattr,
408 .listxattr = ovl_listxattr,
374 .get_acl = ovl_get_acl,
375 .update_time = ovl_update_time,
376};
377
378static const struct inode_operations ovl_symlink_inode_operations = {
379 .setattr = ovl_setattr,
380 .get_link = ovl_get_link,
381 .readlink = ovl_readlink,
382 .getattr = ovl_getattr,
383 .setxattr = generic_setxattr,
384 .getxattr = ovl_getxattr,
385 .listxattr = ovl_listxattr,
409 .removexattr = ovl_removexattr,
386 .removexattr = generic_removexattr,
410 .update_time = ovl_update_time,
411};
412
413static void ovl_fill_inode(struct inode *inode, umode_t mode)
414{
415 inode->i_ino = get_next_ino();
416 inode->i_mode = mode;
417 inode->i_flags |= S_NOCMTIME;

--- 66 unchanged lines hidden ---
387 .update_time = ovl_update_time,
388};
389
390static void ovl_fill_inode(struct inode *inode, umode_t mode)
391{
392 inode->i_ino = get_next_ino();
393 inode->i_mode = mode;
394 inode->i_flags |= S_NOCMTIME;

--- 66 unchanged lines hidden ---