<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cgo on IHEXON BLOG</title><link>https://ihexon.github.io/tags/cgo/</link><description>Recent content in Cgo on IHEXON BLOG</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>zzheasy@gmail.com (IHEXON)</managingEditor><webMaster>zzheasy@gmail.com (IHEXON)</webMaster><copyright>Copy, _right?_ :thinking_face:</copyright><lastBuildDate>Sat, 23 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://ihexon.github.io/tags/cgo/index.xml" rel="self" type="application/rss+xml"/><item><title>在 Go 里用 libarchive 写一个接近 bsdtar 的归档器</title><link>https://ihexon.github.io/posts/go-libarchive-bsdtar-rootfs-export/</link><pubDate>Sat, 23 May 2026 00:00:00 +0000</pubDate><author>zzheasy@gmail.com (IHEXON)</author><guid>https://ihexon.github.io/posts/go-libarchive-bsdtar-rootfs-export/</guid><description>&lt;p&gt;这篇只是记一下最近用 Go 包 libarchive 的思路。&lt;/p&gt;
&lt;p&gt;目标很普通：把一个目录打成 &lt;code&gt;tar.zst&lt;/code&gt;，解包时也尽量保留原来的文件系统语义。真正费时间的地方不在遍历目录，而是各种边角：非 ASCII 文件名、软链接、硬链接、稀疏文件、设备节点、权限、owner、xattr，还有一些错误只会在 close 阶段冒出来。&lt;/p&gt;
&lt;p&gt;如果只用 Go 标准库 &lt;code&gt;archive/tar&lt;/code&gt; 手写，普通文件当然很快能跑通，但后面大概率会变成不断补特例。所以我最后还是把 libarchive 当成底层实现，行为尽量贴近 bsdtar。&lt;/p&gt;</description></item></channel></rss>