1 Star 0 Fork 15

src-oepkgs-oE-rv/tar

forked from src-openEuler/tar 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tar-1.28-vfatTruncate.patch 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:18 . Package init
From 90f446f9b04ab820a99b9408e68c01dc6b57056c Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 28 Jul 2014 08:10:10 +0200
Subject: [PATCH 2/9] vfat-like FS & sparse (still downstream)
Fix extracting sparse files to a file system like vfat, when
ftruncate may fail to grow the size of a file. Still downstram,
(do we need this now? ftruncate & vfat works is now OK).
Resolves: #179507
Upstream bugreport:
http://lists.gnu.org/archive/html/bug-tar/2006-02/msg00000.html
---
src/system.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/system.c b/src/system.c
index 9414233..37e9a3e 100644
--- a/src/system.c
+++ b/src/system.c
@@ -243,8 +243,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
--
1.9.3
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs-oe-rv/tar.git
git@gitee.com:src-oepkgs-oe-rv/tar.git
src-oepkgs-oe-rv
tar
tar
master

搜索帮助