diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2005-10-04 11:01:06 -0400 |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2005-10-04 11:01:06 -0400 |
commit | e9438250b635f7832e99a8c8d2e394dd1522ce65 (patch) | |
tree | e91de9667aa45e9f02387a2dc013982af245d029 /fs/ntfs/inode.c | |
parent | dd072330d1a60be11a5c284fa1e645350750a4fc (diff) |
NTFS: Enable ATTR_SIZE attribute changes in ntfs_setattr(). This completes
the initial implementation of file truncation. Now both open(2)ing
a file with the O_TRUNC flag and the {,f}truncate(2) system calls
will resize a file appropriately. The limitations are that only
uncompressed and unencrypted files are supported. Also, there is
only very limited support for highly fragmented files (the ones whose
$DATA attribute is split into multiple attribute extents).
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/inode.c')
-rw-r--r-- | fs/ntfs/inode.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index a1682342baa6..b24f4c4b2c5c 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -2845,8 +2845,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
2845 | 2845 | ||
2846 | err = inode_change_ok(vi, attr); | 2846 | err = inode_change_ok(vi, attr); |
2847 | if (err) | 2847 | if (err) |
2848 | return err; | 2848 | goto out; |
2849 | |||
2850 | /* We do not support NTFS ACLs yet. */ | 2849 | /* We do not support NTFS ACLs yet. */ |
2851 | if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) { | 2850 | if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) { |
2852 | ntfs_warning(vi->i_sb, "Changes in user/group/mode are not " | 2851 | ntfs_warning(vi->i_sb, "Changes in user/group/mode are not " |
@@ -2854,14 +2853,22 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
2854 | err = -EOPNOTSUPP; | 2853 | err = -EOPNOTSUPP; |
2855 | goto out; | 2854 | goto out; |
2856 | } | 2855 | } |
2857 | |||
2858 | if (ia_valid & ATTR_SIZE) { | 2856 | if (ia_valid & ATTR_SIZE) { |
2859 | if (attr->ia_size != i_size_read(vi)) { | 2857 | if (attr->ia_size != i_size_read(vi)) { |
2860 | ntfs_warning(vi->i_sb, "Changes in inode size are not " | 2858 | ntfs_inode *ni = NTFS_I(vi); |
2861 | "supported yet, ignoring."); | 2859 | /* |
2862 | err = -EOPNOTSUPP; | 2860 | * FIXME: For now we do not support resizing of |
2863 | // TODO: Implement... | 2861 | * compressed or encrypted files yet. |
2864 | // err = vmtruncate(vi, attr->ia_size); | 2862 | */ |
2863 | if (NInoCompressed(ni) || NInoEncrypted(ni)) { | ||
2864 | ntfs_warning(vi->i_sb, "Changes in inode size " | ||
2865 | "are not supported yet for " | ||
2866 | "%s files, ignoring.", | ||
2867 | NInoCompressed(ni) ? | ||
2868 | "compressed" : "encrypted"); | ||
2869 | err = -EOPNOTSUPP; | ||
2870 | } else | ||
2871 | err = vmtruncate(vi, attr->ia_size); | ||
2865 | if (err || ia_valid == ATTR_SIZE) | 2872 | if (err || ia_valid == ATTR_SIZE) |
2866 | goto out; | 2873 | goto out; |
2867 | } else { | 2874 | } else { |