diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2015-12-14 15:55:53 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2015-12-14 16:17:37 +0900 |
commit | a8d964ee3ae1acc7d0a9ed43e5f1e363d26da090 (patch) | |
tree | e25c4e9b888d173b3109ffed48153499ee00c531 /src/system.c | |
parent | 02e836feb7a708522369a8fb46a3ade8688db655 (diff) | |
download | tar-tizen_3.0_base.tar.gz tar-tizen_3.0_base.tar.bz2 tar-tizen_3.0_base.zip |
Bump to 1.17tizen_4.0.m1_releasesubmit/tizen_common/20160104.112601submit/tizen_base/20151228.234606submit/tizen_4.0_base/20170828.000001submit/tizen_4.0_base/20170828.000000submit/tizen_4.0_base/20170811.071500submit/tizen_3.0_base/20161028.062326submit/tizen_3.0.m2_base/20170104.073748submit/tizen/20151228.102125submit/tizen/20151223.034856accepted/tizen/common/20160107.114051accepted/tizen/base/20151229.114054accepted/tizen/4.0/base/20170828.221403accepted/tizen/4.0/base/20170811.093101accepted/tizen/3.0/base/20161028.103431accepted/tizen/3.0.m2/base/20170104.082123tizen_3.0_basetizen_3.0.m2_basetizen_3.0tizenaccepted/tizen_commonaccepted/tizen_3.0_baseaccepted/tizen_3.0.m2_base
sync with tizen 2.4
run unit test
Change-Id: Iae1c58a660ee7dad0694163929e5b9940a0ec9c8
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'src/system.c')
-rw-r--r-- | src/system.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/system.c b/src/system.c index e2d0431..70b746b 100644 --- a/src/system.c +++ b/src/system.c @@ -250,8 +250,25 @@ sys_compare_links (struct stat *link_data, struct stat *stat_data) int sys_truncate (int fd) { + struct stat st; off_t pos = lseek (fd, (off_t) 0, SEEK_CUR); - return pos < 0 ? -1 : ftruncate (fd, pos); + + if ( pos < 0) + return -1; + + if ( ftruncate(fd, pos) && errno == EPERM ) { + /* wrapper around ftruncate: + * ftruncate may fail to grow the size of a file with some OS and filesystem + * combinations. Linux and vfat/fat is one example. If this is the case do + * a write to grow the file to the desired length. + */ + if( (fstat( fd, &st ) == -1) || + (st.st_size >= pos) || + (lseek( fd, pos - 1, SEEK_SET) == (off_t)-1) || + (write( fd, "\0", 1) == -1) ) + return -1; + } + return 0; } /* Return nonzero if NAME is the name of a regular file, or if the file |