[rtems commit] IMFS: Fix truncate according to POSIX

Sebastian Huber sebh at rtems.org
Fri Sep 13 14:42:41 UTC 2013


Module:    rtems
Branch:    master
Commit:    c5b2d7944c63695d4be21f4f904d74a945270763
Changeset: http://git.rtems.org/rtems/commit/?id=c5b2d7944c63695d4be21f4f904d74a945270763

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 13 15:17:57 2013 +0200

IMFS: Fix truncate according to POSIX

ftruncate() and open() with O_TRUNC shall upon successful completion
mark for update the st_ctime and st_mtime fields of the file.

truncate() shall upon successful completion, if the file size is
changed, mark for update the st_ctime and st_mtime fields of the file.

The POSIX standard "The Open Group Base Specifications Issue 7", IEEE
Std 1003.1, 2013 Edition says nothing about the behaviour of truncate()
if the file size remains unchanged.

Future directions of the standard may mandate the behaviour specified in
ftruncate():

http://austingroupbugs.net/view.php?id=489

---

 cpukit/libfs/src/imfs/memfile.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c
index b467ae9..2b398f5 100644
--- a/cpukit/libfs/src/imfs/memfile.c
+++ b/cpukit/libfs/src/imfs/memfile.c
@@ -174,7 +174,7 @@ int memfile_ftruncate(
    */
   the_jnode->info.file.size = length;
 
-  IMFS_update_atime( the_jnode );
+  IMFS_mtime_ctime_update(the_jnode);
 
   return 0;
 }
@@ -248,8 +248,7 @@ MEMFILE_STATIC int IMFS_memfile_extend(
    */
   the_jnode->info.file.size = new_length;
 
-  IMFS_update_ctime(the_jnode);
-  IMFS_update_mtime(the_jnode);
+  IMFS_mtime_ctime_update(the_jnode);
   return 0;
 }
 




More information about the vc mailing list