mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-01 08:04:22 +08:00
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>
This commit is contained in:
parent
dd072330d1
commit
e9438250b6
@ -50,6 +50,13 @@ ToDo/Notes:
|
|||||||
but not the initialized size can be extended, too.
|
but not the initialized size can be extended, too.
|
||||||
- Implement fs/ntfs/inode.[hc]::ntfs_truncate(). It only supports
|
- Implement fs/ntfs/inode.[hc]::ntfs_truncate(). It only supports
|
||||||
uncompressed and unencrypted files.
|
uncompressed and unencrypted files.
|
||||||
|
- 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).
|
||||||
|
|
||||||
2.1.24 - Lots of bug fixes and support more clean journal states.
|
2.1.24 - Lots of bug fixes and support more clean journal states.
|
||||||
|
|
||||||
|
@ -2845,8 +2845,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
|
|||||||
|
|
||||||
err = inode_change_ok(vi, attr);
|
err = inode_change_ok(vi, attr);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto out;
|
||||||
|
|
||||||
/* We do not support NTFS ACLs yet. */
|
/* We do not support NTFS ACLs yet. */
|
||||||
if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) {
|
if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) {
|
||||||
ntfs_warning(vi->i_sb, "Changes in user/group/mode are not "
|
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)
|
|||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ia_valid & ATTR_SIZE) {
|
if (ia_valid & ATTR_SIZE) {
|
||||||
if (attr->ia_size != i_size_read(vi)) {
|
if (attr->ia_size != i_size_read(vi)) {
|
||||||
ntfs_warning(vi->i_sb, "Changes in inode size are not "
|
ntfs_inode *ni = NTFS_I(vi);
|
||||||
"supported yet, ignoring.");
|
/*
|
||||||
err = -EOPNOTSUPP;
|
* FIXME: For now we do not support resizing of
|
||||||
// TODO: Implement...
|
* compressed or encrypted files yet.
|
||||||
// err = vmtruncate(vi, attr->ia_size);
|
*/
|
||||||
|
if (NInoCompressed(ni) || NInoEncrypted(ni)) {
|
||||||
|
ntfs_warning(vi->i_sb, "Changes in inode size "
|
||||||
|
"are not supported yet for "
|
||||||
|
"%s files, ignoring.",
|
||||||
|
NInoCompressed(ni) ?
|
||||||
|
"compressed" : "encrypted");
|
||||||
|
err = -EOPNOTSUPP;
|
||||||
|
} else
|
||||||
|
err = vmtruncate(vi, attr->ia_size);
|
||||||
if (err || ia_valid == ATTR_SIZE)
|
if (err || ia_valid == ATTR_SIZE)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user