diff options
author | Amir Goldstein <amir73il@gmail.com> | 2016-11-12 22:36:03 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2016-12-16 13:02:57 +0300 |
commit | 9aba652190f8cdced66967c97d6159de0cc8478e (patch) | |
tree | 374a40798a4d0f690e00c80b2b5108603d7ffb78 /fs/overlayfs/copy_up.c | |
parent | 97c684cc911060ba7f97c0925eaf842f159a39e8 (diff) | |
download | linux-9aba652190f8cdced66967c97d6159de0cc8478e.tar.xz |
ovl: fold ovl_copy_up_truncate() into ovl_copy_up()
This removes code duplication.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/copy_up.c')
-rw-r--r-- | fs/overlayfs/copy_up.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 6c3aaf45e9cf..e8cacf7a8dcc 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -324,8 +324,8 @@ out_cleanup: * is possible that the copy up will lock the old parent. At that point * the file will have already been copied up anyway. */ -int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, - struct path *lowerpath, struct kstat *stat) +static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, + struct path *lowerpath, struct kstat *stat) { DEFINE_DELAYED_CALL(done); struct dentry *workdir = ovl_workdir(dentry); @@ -378,7 +378,7 @@ out_unlock: return err; } -int ovl_copy_up(struct dentry *dentry) +int ovl_copy_up_flags(struct dentry *dentry, int flags) { int err = 0; const struct cred *old_cred = ovl_override_creds(dentry->d_sb); @@ -408,6 +408,9 @@ int ovl_copy_up(struct dentry *dentry) ovl_path_lower(next, &lowerpath); err = vfs_getattr(&lowerpath, &stat); + /* maybe truncate regular file. this has no effect on dirs */ + if (flags & O_TRUNC) + stat.size = 0; if (!err) err = ovl_copy_up_one(parent, next, &lowerpath, &stat); @@ -418,3 +421,8 @@ int ovl_copy_up(struct dentry *dentry) return err; } + +int ovl_copy_up(struct dentry *dentry) +{ + return ovl_copy_up_flags(dentry, 0); +} |