xdvdfs
是用來與 XDVDFS/XISO 映像互動的工具集合。
xdvdfs-cli
是一個用於與 xiso 檔案互動的命令列工具。
如果貨物在路徑中設定正確,則可以使用以下命令安裝:
$ cargo install xdvdfs-cli
否則,它可以作為預設項目從工作空間根運行。
github 版本中也提供了 xdvdfs-cli 的二進位發行版。
運行不帶參數的xdvdfs
將彈出幫助螢幕,顯示支援的子命令:
Usage: xdvdfs [COMMAND]
Commands:
ls List files in an image
tree List all files in an image, recursively
md5 Show MD5 checksums for files in an image
checksum Compute deterministic checksum of image contents
info Print information about image metadata
copy-out Copy a file or directory out of the provided image file
unpack Unpack an entire image to a directory
pack Pack an image from a given directory or source ISO image
build-image Pack an image from a given specification
image-spec Manage image spec `xdvdfs.toml` files
compress Pack and compress an image from a given directory or source ISO image
help Print this message or the help of the given subcommand(s)
使用-h
標誌運行子命令將顯示該特定子命令的幫助資訊。
若要從目錄打包映像,請執行:
$ xdvdfs pack < directory > [optional output path]
這將建立一個與輸入目錄一對一相符的 iso。
可從現有 ISO 映像重新打包映像:
$ xdvdfs pack < input-image > [optional output path]
這將創建一個與輸入圖像一對一匹配的 iso。
可以使用xdvdfs build-image
指令在底層映像中重寫到不同目標的主機路徑時打包映像。
如果不需要路徑重新映射功能(即您只需要/**:/{1}
規則),那麼您應該更喜歡xdvdfs pack
。
實現此目的的主要方法是使用xdvdfs.toml
檔案:
[ metadata ]
# Relative path to output iso, if not specified in command [optional]
output = " dist/image.xiso.iso "
# List of host-to-image path mapping rules. At least one rule is required.
# All paths are relative to the provided source path, the `xdvdfs.toml` file,
# or the working directory, in that priority order
# Host paths are matched by glob pattern
# Image paths have fields given by `{x}` substituted, where `x` is the index
# of the glob match, starting at 1. `{0}` matches the entire host path.
# Globs are evaluated in the provided order
[ map_rules ]
# Map contents of the "bin" directory to the image root
bin = " / "
# Map anything in the assets directory to `/assets/`
# Equivalent to `assets = "/assets"`
"assets/**" = " /assets/{1} "
# Map any file in the `sound` subdirectory with name `priority`
# and any extension to the same path in the image
# Note that `{0}` matches the entire relative host path
# Also note that due to the linear ordering of glob matches,
# this takes precedence over the below rule
"sound/priority.*" = " /{0} "
# Map any file in the `sound` subdirectory with extension `a`, `b`, or `c`,
# to `/a/filename`, "/b/filename" or `/c/filename`, based on its filename
# and extension.
"sound/*.{a,b,c}" = " /{2}/{1} "
# but, exclude any files in the `sound` subdirectory with filename `excluded`
# The image path is a don't-care value, and has no effect
"!sound/excluded.*" = " "
# Since globs are evaluated in order, this includes any otherwise excluded
# files in the `sound` subdirectory with name `excluded` and extension `c`
"sound/excluded.c" = " /c/excluded "
假設xdvdfs.toml
和所有上述路徑都相對於當前目錄,則可以使用以下內容打包映像:
# Produces `dist/image.xiso.iso` with the above configuration
$ xdvdfs build-image
還有其他方法可以從其他目錄打包圖像:
# Produces `/dist/image.xiso.iso`
$ xdvdfs build-image < path-to-source-dir >
# Also produces `/dist/image.xiso.iso`
$ xdvdfs build-image < path-to-source-dir > /xdvdfs.toml
# Produces `./dist/output.xiso.iso` in the current directory
$ xdvdfs build-image < path-to-source-dir > dist/output.xiso.iso
# Produces `/dist/image.xiso.iso`, with `xdvdfs.toml` not
# necessarily being in `. Here it is in the current directory
$ xdvdfs build-image -f xdvdfs.toml < path-to-source-dir >
要查看xdvdfs.toml
給出的真實映射而不實際打包映像,請使用-D
或--dry-run
標誌。
也可以直接在命令列中提供xdvdfs.toml
檔案的所有配置以build-image
。
-O
提供output
字段-m :
提供映射規則。這可以重複,並按照給定的順序進行匹配。這些也可以與--dry-run
結合使用來測試不同的映射。
若要將build-image
一組命令列選項轉換為xdvdfs.toml
文件,請使用具有相同參數的xdvdfs image-spec from
命令。
# Outputs equivalent `xdvdfs.toml` to stdout
$ xdvdfs image-spec from -O dist/image.iso -m " bin:/ " -m " assets:/{0} "
# Outputs equivalent `xdvdfs.toml` to a file
$ xdvdfs image-spec from -O dist/image.iso -m " bin:/ " -m " assets:/{0} " xdvdfs.toml
產生的規範文件可以與build-image
一起使用。
若要解壓縮影像,請運行:
$ xdvdfs unpack < path to image > [optional output path]
xdvdfs-cli
支援用於映像的其他實用工具。
命令 | 行動 |
---|---|
xdvsfs ls | 列出指定目錄中的文件,預設為 root |
xdvdfs tree | 列印圖像中每個文件的列表 |
xdvdfs md5 | 列印影像中指定檔案或每個檔案的 md5 和 |
xdvdfs checksum [path to img1]... | 計算所有影像內容的校驗和,以檢查其他影像的完整性 |
xdvdfs info | 列印指定目錄條目或根卷的元資料資訊 |
xdvdfs copy-out | 從提供的圖像複製單一檔案或目錄 |
xdvdfs-core
是一個用於處理 XDVDFS 元資料的函式庫。
從給定路徑讀取檔案的一個簡單範例是:
async fn read_from_path ( xiso : & Path , file_path : & str ) -> Box < [ u8 ] > {
let mut xiso = std :: fs :: File :: open ( xiso ) . unwrap ( ) ;
let volume = xdvdfs :: read :: read_volume ( & mut xiso ) . await . unwrap ( ) ;
let file_dirent = volume . root_table . walk_path ( & mut xiso , file_path ) . await . unwrap ( ) ;
let data = file_dirent . node . dirent . read_data_all ( & mut xiso ) . await . unwrap ( ) ;
data
}
該程式庫支援 no_std。可以透過實作xdvdfs::blockdev
中的特徵來定義自訂區塊裝置。
如果沒有alloc
功能,則僅支援基本元資料功能。 alloc
功能啟用了多個需要指派的實用函數(例如上面的read_data_all
。
xdvdfs-cli 的源代碼提供瞭如何在帶有 std 的環境中使用 xdvdfs-core 的更詳細範例。
請注意,xdvdfs 目前 API 不穩定,並且在主要版本 0 的 semver 之後,每個次要版本的提升可能會或可能不會包含重大變更。