diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-04-08 09:06:41 +0300 |
|---|---|---|
| committer | Tyler Hicks <code@tyhicks.com> | 2026-04-09 02:54:03 +0300 |
| commit | 5d1f0e8cd9482ddb5318f765f7ca508ce707cf83 (patch) | |
| tree | bc20d87d4a51d3c4f9289a60e725d29396f2a1d4 | |
| parent | 081447ecfc255cb63b6e392cd01d9f684d4df5b8 (diff) | |
| download | linux-5d1f0e8cd9482ddb5318f765f7ca508ce707cf83.tar.xz | |
ecryptfs: factor out a ecryptfs_iattr_to_lower helper
Prepare for using the code to create a lower struct iattr in multiple
places.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tyler Hicks <code@tyhicks.com>
| -rw-r--r-- | fs/ecryptfs/inode.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 4ec3e76f0562..a06b84033ff3 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -677,6 +677,20 @@ static const char *ecryptfs_get_link(struct dentry *dentry, return buf; } +static void ecryptfs_iattr_to_lower(struct iattr *lower_ia, + const struct iattr *ia) +{ + memcpy(lower_ia, ia, sizeof(*lower_ia)); + if (ia->ia_valid & ATTR_FILE) + lower_ia->ia_file = ecryptfs_file_to_lower(ia->ia_file); + /* + * If the mode change is for clearing setuid/setgid bits, allow the lower + * file system to interpret this in its own way. + */ + if (lower_ia->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) + lower_ia->ia_valid &= ~ATTR_MODE; +} + /** * upper_size_to_lower_size * @crypt_stat: Crypt_stat associated with file @@ -921,21 +935,13 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap, if (rc) goto out; - memcpy(&lower_ia, ia, sizeof(lower_ia)); - if (ia->ia_valid & ATTR_FILE) - lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file); + ecryptfs_iattr_to_lower(&lower_ia, ia); if (ia->ia_valid & ATTR_SIZE) { rc = truncate_upper(dentry, ia, &lower_ia); if (rc < 0) goto out; } - /* - * mode change is for clearing setuid/setgid bits. Allow lower fs - * to interpret this in its own way. - */ - if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) - lower_ia.ia_valid &= ~ATTR_MODE; inode_lock(d_inode(lower_dentry)); rc = notify_change(&nop_mnt_idmap, lower_dentry, &lower_ia, NULL); |
