Skip to contentSkip to conversation

procfs: drop vmtruncate

PATCH In review Marco Stornelli 2 participants 3 messages Oct 20, 2012 – Oct 24, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 4/21 procfs: drop vmtruncate

Removed vmtruncate

---
 fs/proc/base.c        |    3 ++-
 fs/proc/generic.c     |    3 ++-
 fs/proc/proc_sysctl.c |    3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
fs/proc/base.c +2 -1
index 144a967..f976f31 100644
@@ -544,9 +544,10 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
 
 	if ((attr->ia_valid & ATTR_SIZE) &&
 	    attr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, attr->ia_size);
+		error = inode_newsize_ok(inode, attr->ia_size);
 		if (error)
 			return error;
+		truncate_setsize(inode, attr->ia_size);
 	}
 
 	setattr_copy(inode, attr);
fs/proc/generic.c +2 -1
index 0d80cef..6e7a8a7 100644
@@ -263,9 +263,10 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
 
 	if ((iattr->ia_valid & ATTR_SIZE) &&
 	    iattr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, iattr->ia_size);
+		error = inode_newsize_ok(inode, iattr->ia_size);
 		if (error)
 			return error;
+		truncate_setsize(inode, iattr->ia_size);
 	}
 
 	setattr_copy(inode, iattr);
fs/proc/proc_sysctl.c +2 -1
index a781bdf..f8d7989 100644
@@ -737,9 +737,10 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
 
 	if ((attr->ia_valid & ATTR_SIZE) &&
 	    attr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, attr->ia_size);
+		error = inode_newsize_ok(inode, attr->ia_size);
 		if (error)
 			return error;
+		truncate_setsize(inode, attr->ia_size);
 	}
 
 	setattr_copy(inode, attr);
Signature · 1 line
1.7.3.4
#2 lore raw

Il 24/10/2012 17:12, Christoph Hellwig ha scritto:

Quoted 9 lines · Marco Stornelli
Quoted 3 lines

Removed vmtruncate

As Al pointed out we probably shouldn't even allow truncate on procfs. Can look into refusing it instead, please?

Mmmm...for example the command "truncate --size=100 config.gz" is a nop, so it seems to me it makes no sense to support the size change, but I don't know if there are other use cases. However, should we return EPERM in case of size change checking it before inode_change_ok()?

Marco