Fix time modification on truncate()
POSIX truncate specification says "Upon successful completion, if the *file size is changed*, this function shall mark for update the st_ctime and st_mtime fields of the file." This patch prevents changing of the date fields when the size stays the same.
This commit is contained in:
committed by
Thomas Veerman
parent
902e0e27e0
commit
255ae85b1e
@@ -563,6 +563,8 @@ off_t newsize; /* inode must become this size */
|
||||
return(EINVAL);
|
||||
if (newsize > rip->i_sp->s_max_size) /* don't let inode grow too big */
|
||||
return(EFBIG);
|
||||
if (rip->i_size == newsize)
|
||||
return(OK);
|
||||
|
||||
/* Free the actual space if truncating. */
|
||||
if (newsize < rip->i_size) {
|
||||
|
||||
+5
-3
@@ -525,17 +525,19 @@ off_t newsize; /* inode must become this size */
|
||||
file_type = rip->i_mode & I_TYPE; /* check to see if file is special */
|
||||
if (file_type == I_CHAR_SPECIAL || file_type == I_BLOCK_SPECIAL)
|
||||
return(EINVAL);
|
||||
if(newsize > rip->i_sp->s_max_size) /* don't let inode grow too big */
|
||||
if (rip->i_size == newsize)
|
||||
return(OK);
|
||||
if (newsize > rip->i_sp->s_max_size) /* don't let inode grow too big */
|
||||
return(EFBIG);
|
||||
|
||||
/* Free the actual space if truncating. */
|
||||
if(newsize < rip->i_size) {
|
||||
if (newsize < rip->i_size) {
|
||||
if ((r = freesp_inode(rip, newsize, rip->i_size)) != OK)
|
||||
return(r);
|
||||
}
|
||||
|
||||
/* Clear the rest of the last zone if expanding. */
|
||||
if(newsize > rip->i_size) clear_zone(rip, rip->i_size, 0);
|
||||
if (newsize > rip->i_size) clear_zone(rip, rip->i_size, 0);
|
||||
|
||||
/* Next correct the inode size. */
|
||||
rip->i_size = newsize;
|
||||
|
||||
Reference in New Issue
Block a user