forked from nickelpro/cNBT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmount.nbt.8
222 lines (204 loc) · 10.7 KB
/
mount.nbt.8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
.TH MOUNT.NBT 8 2025 nbtfsutils
.SH NAME
mount.nbt - Mount a Named Binary Tag File System
.SH SYNOPSIS
.nf
mount.nbt [-o \fI<fs-option>\fR[,\fI...\fR]] [-fnrvwh] \fI<nbt-file>\fR \fI<mount-point>\fR
.fi
.SH DESCRIPTION
This tool is a FUSE-based file system implementation for accessing NBT formatted data, which is used by Minecraft to store various data about the game. Running this tool mounts a file system from the file specified by \fI<nbt-file>\fR; both standalone NBT file (usually have suffix \fI.dat\fR) and Minecraft Region file (usually have suffix \fI.mcr\fR or \fI.mca\fR) are supported.
.SH OPTIONS
.sp
.B
.IP -f
Operate in foreground. Useful for debugging.
.B
.IP "-h\p --help"
Print a brief usage message.
.B
.IP -n
Ignored.
.B
.IP "-o \fI<fs-option>\fR[,\fI...\fR]"
Pass gereric mount options, FUSE-specific options, and/or NBT-specific options, in a comma-separated list. See \fBmount(8)\fR and \fBfuse(8)\fR for generic mount options and FUSE-specific options.
.sp
NBT-specific options are:
.RS
.TP
.B ro
Mount the file system read-only, useful to mount from a file that can't be written to, or to prevent accidentally changing it; but see \fBwritefile\fR option below.
.TP
.B rw
Revert any \fBro\fR option that may be specified early.
.TP
.B region
Specify the \fI<nbt-file>\fR is a Minecraft Region file instead of a standalone NBT file.
.TP
.B typeprefix
Use node type prefix for node names when listing compound nodes as a directory. This option affects directory listing only, existing nodes where their name contains no colon can always be accessed either with or without the type prefix.
.TP
.B umask=\fI<mask>\fR
Set file mode mask using an octal number for NBT nodes, default 0.
.TP
.B writefile=\fI<path>\fR
Set an alternative path for writing NBT data; the original \fI<nbt-file>\fR won't be written to if this is specified. Will have no effect when file system is mounted read-only.
.TP
.B compression={gzip|zlib}
Set compression format for writing NBT data; default \fBgzip\fR for standalone NBT file, \fBzlib\fR for Minecraft Region file. Will have no effect when file system is mounted read-only.
.TP
.B chunksymlink={hidden|visible}
Set whether the symbolic links in form of \fI<x>\fR,\fI<z>\fR for chunks, be visible in the region root directory; default \fBhidden\fR. This option is meaningful only when mounting a Minecraft Region file.
.TP
.B arraybyteorder={host|big|little}
Set integer byte order for presenting data of \fBint32array\fR and \fBint64array\fR nodes; default \fBhost\fR. This option is meaningful only when direct \fBread(2)\fRing of directories is supported by the operating system and the FUSE implementation.
.RE
.B
.IP -r
Mount the file system read-only. Same as specifying \fB-o ro\fR.
.B
.IP "-v\p --verbose"
Be Verbose during mounting.
.B
.IP "-V\p --version"
Display version, copyright and licensing information of this tool. The program will exit afterward.
.B
.IP -w
Mount the file system read-write. Same as specifying \fB-o rw\fR.
.SH NODE TYPES
.PP
NBT specification defined several types for a tag, they are mapped into file types as followings:
.TS
box;
l l l.
NBT Tag Type File Type Type Prefix Name
TAG_Byte Regular int8, byte
TAG_Short Regular int16
TAG_Int Regular int32
TAG_Long Regular int64
TAG_Float Regular float32, float, single
TAG_Double Regular float64, double
TAG_Byte_Array Regular int8array, bytearray
TAG_String Regular string
TAG_List Directory list
TAG_Compound Directory compound
TAG_Int_Array Directory int32array
TAG_Long_Array Directory int64array
.TE
.SH ACCESSING NODES
.SS Referencing Nodes Under Compound
For nodes directly under a \fBcompound\fR, they can be accessed using their name; a \fBtype prefix\fR can also be prepended to an name to reference a node, as \fItypeprefix\fR:\fIname\fR.
For example an \fBint64\fR node named \fBRandomSeed\fR under a \fBcompound\fR named \fBData\fR, the following 2 paths would referencing the exactly same node:
.RS
Data/int64:RandomSeed
.br
compound:Data/RandomSeed
.RE
Turning on mount option \fBtypeprefix\fR will having this \fBtype prefix\fR be automatically prepended to node names, when listing a \fBcompound\fR using \fBreaddir(3)\fR; this could be useful to preserve the type information when copying a \fBcompound\fR node recursively (such as using \fBtar(1)\fR), so it is possible for the copied nodes be restored into another NBT later.
.PP
To avoid ambiguity, nodes can be listed and accessed only with the corresponding type prefix when their name containing the colon.
.SS Referencing Nodes Under List
Nodes under a \fBlist\fR are accessed using index numbers starting with 0. They will also have same type; a pseudo file \fB.type\fR is available under any \fBlist\fR to indicate node type the list contains.
.SS Accessing Individual Node
Any node which the file type is regular file can be read and written directly using \fBread(2)\fR and \fBwrite(2)\fR; they can also be \fBtruncate(2)\fRd to empty, but number typed (
.B int8
,
.B int16
,
.B int32
,
.B int64
,
.B float32
and
.B float64
) nodes will turn its value into 0 after that.
Nodes with type \fBint8array\fR or \fBstring\fR support \fBlseek(2)\fR and unlimited \fBtruncate(2)\fR operations.
Reading from a \fBstring\fR node will have an additional line feed character (\\n) appended to the end automatically; similarly, writing to a \fBstring\fR node will have the ending line feed character stripped if exist.
.PP
\fBlist\fR and \fBcompound\fR nodes can contain other nodes, they can be accessed according to above rules.
.PP
\fBint32array\fR and \fBint64array\fR nodes are represented as directories, the array elements are accessed using an index number starting with 0, as regular files under the directory.
Creating a new regular file with appreciate index number under the directory extends the array, and any element between the old tail index and new index will appear automatically as well; automatically added elements are initialized to 0.
An array can also be shrunk by removing (\fBunlink(2)\fR) the tail element, one element at a time; as a design limitation, only the tail element can be removed.
On supported platforms, the array nodes may also be read directly (using \fBread(2)\fR); in this case seeking is supported only when aligned to element size, which is 4 or 8 for \fBint32array\fR or \fBint64array\fR respectively. The data stream read directly from an array will be the binary representation of the array elements in a byte order specified by the mount option \fBarraybyteorder\fR, which is \fBhost byte order\fR by default.
.SH ADDING AND REMOVING NODES
.SS Under Compound
Nodes under a \fBcompound\fR can be removed by using \fBunlink(2)\fR or \fBrmdir(2)\fR, according to their represented file type; usual file system restrictions on directory apply, meaning nodes that being represented as directories can not be removed unless empty.
.PP
New node may be created under a \fBcompound\fR by using either \fBopen(2)\fR or \fBmkdir(2)\fR. Unlike referencing an existing node, creating a new node requires the use of a type-prefixed name.
.SS Under List
Like \fBcompound\fR, nodes under a \fBlist\fR may be removed by using either \fBunlink(2)\fR or \fBrmdir(2)\fR; if a non-tail node was removed, the index number of later nodes will be shifted backward by 1, which could be surprising when trying to remove multiple nodes.
.PP
New node may be added only to the tail of a \fBlist\fR; there is currently not possible to insert a node in middle of a list. Newly created node will have the type specified by the list type, indicated by the \fB.type\fR pseudo file.
.PP
The list type may also be changed by writing a \fBtype prefix name\fR into \fB.type\fR, but only when the list is empty.
.SS Special Requirement For Creating List Node
A \fBlist\fR node may be created under either \fBcompound\fR or \fBlist\fR using \fBmkdir(2)\fR according to rules above, but please note newly created list will have an invalid list type; no node can be created under such list, and if a file system is unmounted with it, writing NBT data will fail, causing all modifications to be lost!
Any newly created list must be initialized with a supported list type, by writing the type prefix name to its \fB.type\fR pseudo file.
.SH MOVING (RENAMING) NODES
Any node can be moved from a \fBcompound\fR or \fBlist\fR, to same or another \fBcompound\fR or \fBlist\fR, by using \fBrename(2)\fR.
.SS Moving into Compound
If the new name is specified with a \fBtype prefix\fR, the specified type prefix name must match the type of the node being moved.
.PP
If another node in target \fBcompound\fR with the new name already exists, it will be overwritten if:
.RS
both node is considered as a regular file by the file system, or
.sp
both node is considered as a directory by the file system, and the node being overwritten is an empty \fBcompound\fR or \fBlist\fR, or an \fBint32array\fR or \fBint64array\fR.
.RE
.SS Moving into List
The node being moved must have a type that fit the list type.
.PP
The new name must be an index number. The index number must be point to either the tail of the \fBlist\fR, or an existing node in the \fBlist\fR; if it is pointing to an existing node and the node isn't a non-empty \fBcompound\fR or \fBlist\fR, the node will be overwritten.
.SH CAVEATS
.PP
Data is committed to underlying \fI<nbt-file>\fR only upon unmounting; if anything went wrong during this process, the error message will be sent to \fBsyslog(3)\fR, and the file system will be unmounted without saving some or all data.
.PP
When modifying a Minecraft Region file, it is currently not possible to extend a modified chunk beyond the space available for the chunk in that Region file; although this rarely happen unless a considerable amount of additional data was copied into a chunk. If this happens, such chunk will not be saved.
.SH EXAMPLES
.PP
The following examples took place in an Unix shell (\fBsh(1)\fR).
.LP
Mount a standalone NBT file \fI/tmp/level.dat\fR at \fI/mnt/nbt\fR, prepare to write a new NBT file at \fI/tmp/new-level.dat\fR:
.sp
.in +2
.nf
mount.nbt -o writefile=/tmp/new-level.dat /tmp/level.dat /mnt/nbt
.fi
.in -2
.sp
.LP
Mount a Minecraft Region file \fI/tmp/r.0.-1.mcr\fR at \fI/mnt/region\fR, with \fBtype prefix\fR turned on for node name listing:
.sp
.in +2
.nf
mount.nbt -o region,typeprefix /tmp/r.0.-1.mcr /mnt/region
.fi
.in -2
.sp
.LP
Working in a \fBcompound\fR, create and write a new \fBstring\fR node named \fIid\fR:
.sp
.in +2
.nf
echo Villager > string:id
.fi
.in -2
.LP
Working in a \fBcompound\fR, create a new \fBlist\fR node \fIPos\fR with list type set to \fBfloat64\fR, then create and write first node in the list:
.sp
.in +2
.nf
mkdir list:Pos
echo float64 > Pos/.type
echo 31.5 > Pos/0
.fi
.in -2
.sp
.SH AUTHOR
.SH SEE ALSO
.PP
fusefs(5), fuse(8), fusermount(8), mount(8), mkfs.nbt(8)
.PP
Named Binary Tag specification by Mojang