tfstools是一个交互式/脚本化操作的,核心库完全由C语言写成,易于移植的GPT分区与文件系统工具。
最初是作为Taurix操作系统内核的最基本的文件系统的实现,由于核心的库的高度可移植性(核心库完全使用C语言及其标准库,整个工具只使用C/C++语言及其标准库),现将tfstools单独发布。
| 自识别 | 创建 | 读取 | 写入 | |
|---|---|---|---|---|
| GPT分区 | √ | √ | √ | √ |
| FAT32 | 待完善 | √ | √ | √ |
git clone git@github.com:sxysxy/tfstools
cd tfstools
#构建核心库:
./makelib.sh
#构建工具
./maketool.sh
#安装到/usr/bin下
sudo ./install.sh
下载源代码,将所有源代码一起使用g++或cl.exe编译即可生成工具
除去tfstools.cpp,可以使用gcc或cl.exe编译成静态库或动态链接库
见tfstools.h,以及工具前端tfstools.cpp的用例
| 命令 | 参数 | 说明 |
|---|---|---|
| new | [filename, size_in_mb] | Create a new GPT disk image file (1mb=1024kb,1kb=1024b), No spaces in filename, pleaase |
| open | [filename] | Set disk image file |
| open_ro | [filename] | Set disk image file, readonly |
| close | Finish your operations and close disk image file | |
| exit | [code(optional)] | Exit with code(default to 0) |
| help | [command(optional)] | Show help message about the command |
| [text] | Just print the text |
| 命令 | 参数 | 说明 |
|---|---|---|
| list_parts | List exist part in the image file | |
| new_part_start | Start creating new partition | |
| attribute | [attr] | Set the attribute
1 :System partition
2 :EFI hidden partition
4 :Normal
1152921504606846976 :Readonly
4611686018427387904 :Hidden
9223372036854775808 :No auto mount
|
| type_guid | [guid] | Set the type guid of new partition, for example:
C12A7328-F81F-11D2-BA4B-00A0C93EC93B : EFI System
EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 : Data
0657FD6D-A4AB-43C4-84E5-0933C84B4F4F : Linux Swapfile
DE94BBA4-06D1-4D40-A16A-BFD50179D6AC : Windows Recovery Environment
48465300-0000-11AA-AA11-00306543ECAC : Apple HFS/HFS+
55465300-0000-11AA-AA11-00306543ECAC : Apple UFS
|
| guid | [guid/"random"] | Set the guid of new partition, or use random |
| start_lba | [lba] | Set start lba |
| end_lba | [lba] | Set end lba |
| label | [label] | Set the label |
| new_part_end | End creating new parition | |
| select | [guid/index] | To specified the current partition(find the partition by guid or index) |
| rmpart | Delete current partition. After done the current partition will come unexisting | |
| enter_part | [filesystem(optional)] | Enter into the filesystem in current partition(requires fore select_part, detect filesystem automatically if no argument) |
| sync | Synchronize partition table to disk image file(Think before you do) |
| 命令(简写) | 参数 | 说明 |
|---|---|---|
| makefs | [filesystem] | Format this partition with specified filesystem
Available filesystem:
FAT32
|
| chdir(cd) | [dir] | Change current directory to dir |
| chpdir(cdp) | Change current directory to parent directory | |
| mkdir | [dir] | Create directory(depth = 1) |
| ls | [dir(optional)] | List files in current directory |
| poll | [src, dest] | Poll src(in image file) to dest(in real filesystem on your computer) |
| push | [src, dest] | Send src(in real filesystem on you computer) to dest(in current directory in the image file) |
| rm | [filename] | Remove a file or directory |
用例见demo.tfs