1 | /* $Id: isomakercmd.cpp 68872 2017-09-26 10:50:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - ISO Image Maker Command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #define LOG_GROUP RTLOGGROUP_FS
|
---|
32 | #include "internal/iprt.h"
|
---|
33 | #include <iprt/fsisomaker.h>
|
---|
34 |
|
---|
35 | #include <iprt/asm.h>
|
---|
36 | #include <iprt/assert.h>
|
---|
37 | #include <iprt/buildconfig.h>
|
---|
38 | #include <iprt/ctype.h>
|
---|
39 | #include <iprt/file.h>
|
---|
40 | #include <iprt/fsvfs.h>
|
---|
41 | #include <iprt/err.h>
|
---|
42 | #include <iprt/getopt.h>
|
---|
43 | #include <iprt/log.h>
|
---|
44 | #include <iprt/mem.h>
|
---|
45 | #include <iprt/message.h>
|
---|
46 | #include <iprt/path.h>
|
---|
47 | #include <iprt/rand.h>
|
---|
48 | #include <iprt/stream.h>
|
---|
49 | #include <iprt/string.h>
|
---|
50 | #include <iprt/vfs.h>
|
---|
51 | #include <iprt/formats/iso9660.h>
|
---|
52 |
|
---|
53 |
|
---|
54 | /*********************************************************************************************************************************
|
---|
55 | * Defined Constants And Macros *
|
---|
56 | *********************************************************************************************************************************/
|
---|
57 | /** Maximum number of name specifiers we allow. */
|
---|
58 | #define RTFSISOMAKERCMD_MAX_NAMES 8
|
---|
59 |
|
---|
60 | /** Maximum directory recursions when adding a directory tree. */
|
---|
61 | #define RTFSISOMAKERCMD_MAX_DIR_RECURSIONS 32
|
---|
62 |
|
---|
63 | /** @name Name specifiers
|
---|
64 | * @{ */
|
---|
65 | #define RTFSISOMAKERCMDNAME_PRIMARY_ISO RTFSISOMAKER_NAMESPACE_ISO_9660
|
---|
66 | #define RTFSISOMAKERCMDNAME_JOLIET RTFSISOMAKER_NAMESPACE_JOLIET
|
---|
67 | #define RTFSISOMAKERCMDNAME_UDF RTFSISOMAKER_NAMESPACE_UDF
|
---|
68 | #define RTFSISOMAKERCMDNAME_HFS RTFSISOMAKER_NAMESPACE_HFS
|
---|
69 |
|
---|
70 | #define RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE RT_BIT_32(16)
|
---|
71 | #define RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE RT_BIT_32(17)
|
---|
72 |
|
---|
73 | #define RTFSISOMAKERCMDNAME_JOLIET_TRANS_TBL RT_BIT_32(20)
|
---|
74 | #define RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL RT_BIT_32(21)
|
---|
75 | #define RTFSISOMAKERCMDNAME_UDF_TRANS_TBL RT_BIT_32(22)
|
---|
76 | #define RTFSISOMAKERCMDNAME_HFS_TRANS_TBL RT_BIT_32(23)
|
---|
77 |
|
---|
78 | #define RTFSISOMAKERCMDNAME_MAJOR_MASK \
|
---|
79 | (RTFSISOMAKERCMDNAME_PRIMARY_ISO | RTFSISOMAKERCMDNAME_JOLIET | RTFSISOMAKERCMDNAME_UDF | RTFSISOMAKERCMDNAME_HFS)
|
---|
80 |
|
---|
81 | #define RTFSISOMAKERCMDNAME_MINOR_MASK \
|
---|
82 | ( RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE | RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL \
|
---|
83 | | RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE | RTFSISOMAKERCMDNAME_JOLIET_TRANS_TBL \
|
---|
84 | | RTFSISOMAKERCMDNAME_UDF_TRANS_TBL \
|
---|
85 | | RTFSISOMAKERCMDNAME_HFS_TRANS_TBL)
|
---|
86 | AssertCompile((RTFSISOMAKERCMDNAME_MAJOR_MASK & RTFSISOMAKERCMDNAME_MINOR_MASK) == 0);
|
---|
87 | /** @} */
|
---|
88 |
|
---|
89 |
|
---|
90 | /*********************************************************************************************************************************
|
---|
91 | * Structures and Typedefs *
|
---|
92 | *********************************************************************************************************************************/
|
---|
93 | typedef enum RTFSISOMAKERCMDOPT
|
---|
94 | {
|
---|
95 | RTFSISOMAKERCMD_OPT_FIRST = 1000,
|
---|
96 |
|
---|
97 | RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER,
|
---|
98 | RTFSISOMAKERCMD_OPT_OUTPUT_BUFFER_SIZE,
|
---|
99 | RTFSISOMAKERCMD_OPT_RANDOM_OUTPUT_BUFFER_SIZE,
|
---|
100 | RTFSISOMAKERCMD_OPT_RANDOM_ORDER_VERIFICATION,
|
---|
101 | RTFSISOMAKERCMD_OPT_NAME_SETUP,
|
---|
102 |
|
---|
103 | RTFSISOMAKERCMD_OPT_ROCK_RIDGE,
|
---|
104 | RTFSISOMAKERCMD_OPT_LIMITED_ROCK_RIDGE,
|
---|
105 | RTFSISOMAKERCMD_OPT_NO_ROCK_RIDGE,
|
---|
106 | RTFSISOMAKERCMD_OPT_NO_JOLIET,
|
---|
107 |
|
---|
108 | RTFSISOMAKERCMD_OPT_IMPORT_ISO,
|
---|
109 | RTFSISOMAKERCMD_OPT_PUSH_ISO,
|
---|
110 | RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_JOLIET,
|
---|
111 | RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK,
|
---|
112 | RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK_NO_JOLIET,
|
---|
113 | RTFSISOMAKERCMD_OPT_POP,
|
---|
114 |
|
---|
115 | RTFSISOMAKERCMD_OPT_ELTORITO_NEW_ENTRY,
|
---|
116 | RTFSISOMAKERCMD_OPT_ELTORITO_ADD_IMAGE,
|
---|
117 | RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_12,
|
---|
118 | RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_144,
|
---|
119 | RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_288,
|
---|
120 |
|
---|
121 | RTFSISOMAKERCMD_OPT_RATIONAL_ATTRIBS,
|
---|
122 | RTFSISOMAKERCMD_OPT_STRICT_ATTRIBS,
|
---|
123 | RTFSISOMAKERCMD_OPT_NO_FILE_MODE,
|
---|
124 | RTFSISOMAKERCMD_OPT_NO_DIR_MODE,
|
---|
125 | RTFSISOMAKERCMD_OPT_CHMOD,
|
---|
126 | RTFSISOMAKERCMD_OPT_CHOWN,
|
---|
127 | RTFSISOMAKERCMD_OPT_CHGRP,
|
---|
128 |
|
---|
129 | /*
|
---|
130 | * Compatibility options:
|
---|
131 | */
|
---|
132 | RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID,
|
---|
133 | RTFSISOMAKERCMD_OPT_ALLOW_LEADING_DOTS,
|
---|
134 | RTFSISOMAKERCMD_OPT_ALLOW_LIMITED_SIZE,
|
---|
135 | RTFSISOMAKERCMD_OPT_ALLOW_LOWERCASE,
|
---|
136 | RTFSISOMAKERCMD_OPT_ALLOW_MULTI_DOT,
|
---|
137 | RTFSISOMAKERCMD_OPT_ALPHA_BOOT,
|
---|
138 | RTFSISOMAKERCMD_OPT_APPLE,
|
---|
139 | RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID,
|
---|
140 | RTFSISOMAKERCMD_OPT_CHECK_OLD_NAMES,
|
---|
141 | RTFSISOMAKERCMD_OPT_CHECK_SESSION,
|
---|
142 | RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID,
|
---|
143 | RTFSISOMAKERCMD_OPT_DETECT_HARDLINKS,
|
---|
144 | RTFSISOMAKERCMD_OPT_DIR_MODE,
|
---|
145 | RTFSISOMAKERCMD_OPT_DVD_VIDEO,
|
---|
146 | RTFSISOMAKERCMD_OPT_ELTORITO_PLATFORM_ID,
|
---|
147 | RTFSISOMAKERCMD_OPT_ELTORITO_HARD_DISK_BOOT,
|
---|
148 | RTFSISOMAKERCMD_OPT_ELTORITO_INFO_TABLE,
|
---|
149 | RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SEG,
|
---|
150 | RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SIZE,
|
---|
151 | RTFSISOMAKERCMD_OPT_ELTORITO_NO_BOOT,
|
---|
152 | RTFSISOMAKERCMD_OPT_ELTORITO_NO_EMULATION_BOOT,
|
---|
153 | RTFSISOMAKERCMD_OPT_EXCLUDE_LIST,
|
---|
154 | RTFSISOMAKERCMD_OPT_FILE_MODE,
|
---|
155 | RTFSISOMAKERCMD_OPT_FORCE_RR,
|
---|
156 | RTFSISOMAKERCMD_OPT_GID,
|
---|
157 | RTFSISOMAKERCMD_OPT_GRAFT_POINTS,
|
---|
158 | RTFSISOMAKERCMD_OPT_GUI,
|
---|
159 | RTFSISOMAKERCMD_OPT_HFS_AUTO,
|
---|
160 | RTFSISOMAKERCMD_OPT_HFS_BLESS,
|
---|
161 | RTFSISOMAKERCMD_OPT_HFS_BOOT_FILE,
|
---|
162 | RTFSISOMAKERCMD_OPT_HFS_CAP,
|
---|
163 | RTFSISOMAKERCMD_OPT_HFS_CHRP_BOOT,
|
---|
164 | RTFSISOMAKERCMD_OPT_HFS_CLUSTER_SIZE,
|
---|
165 | RTFSISOMAKERCMD_OPT_HFS_CREATOR,
|
---|
166 | RTFSISOMAKERCMD_OPT_HFS_DAVE,
|
---|
167 | RTFSISOMAKERCMD_OPT_HFS_DOUBLE,
|
---|
168 | RTFSISOMAKERCMD_OPT_HFS_ENABLE,
|
---|
169 | RTFSISOMAKERCMD_OPT_HFS_ETHERSHARE,
|
---|
170 | RTFSISOMAKERCMD_OPT_HFS_EXCHANGE,
|
---|
171 | RTFSISOMAKERCMD_OPT_HFS_HIDE,
|
---|
172 | RTFSISOMAKERCMD_OPT_HFS_HIDE_LIST,
|
---|
173 | RTFSISOMAKERCMD_OPT_HFS_ICON_POSITION,
|
---|
174 | RTFSISOMAKERCMD_OPT_HFS_INPUT_CHARSET,
|
---|
175 | RTFSISOMAKERCMD_OPT_HFS_MAC_NAME,
|
---|
176 | RTFSISOMAKERCMD_OPT_HFS_MACBIN,
|
---|
177 | RTFSISOMAKERCMD_OPT_HFS_MAGIC,
|
---|
178 | RTFSISOMAKERCMD_OPT_HFS_MAP,
|
---|
179 | RTFSISOMAKERCMD_OPT_HFS_NETATALK,
|
---|
180 | RTFSISOMAKERCMD_OPT_HFS_NO_DESKTOP,
|
---|
181 | RTFSISOMAKERCMD_OPT_HFS_OSX_DOUBLE,
|
---|
182 | RTFSISOMAKERCMD_OPT_HFS_OSX_HFS,
|
---|
183 | RTFSISOMAKERCMD_OPT_HFS_OUTPUT_CHARSET,
|
---|
184 | RTFSISOMAKERCMD_OPT_HFS_PARMS,
|
---|
185 | RTFSISOMAKERCMD_OPT_HFS_PART,
|
---|
186 | RTFSISOMAKERCMD_OPT_HFS_PREP_BOOT,
|
---|
187 | RTFSISOMAKERCMD_OPT_HFS_PROBE,
|
---|
188 | RTFSISOMAKERCMD_OPT_HFS_ROOT_INFO,
|
---|
189 | RTFSISOMAKERCMD_OPT_HFS_SFM,
|
---|
190 | RTFSISOMAKERCMD_OPT_HFS_SGI,
|
---|
191 | RTFSISOMAKERCMD_OPT_HFS_SINGLE,
|
---|
192 | RTFSISOMAKERCMD_OPT_HFS_TYPE,
|
---|
193 | RTFSISOMAKERCMD_OPT_HFS_UNLOCK,
|
---|
194 | RTFSISOMAKERCMD_OPT_HFS_USHARE,
|
---|
195 | RTFSISOMAKERCMD_OPT_HFS_VOL_ID,
|
---|
196 | RTFSISOMAKERCMD_OPT_HFS_XINET,
|
---|
197 | RTFSISOMAKERCMD_OPT_HIDDEN,
|
---|
198 | RTFSISOMAKERCMD_OPT_HIDDEN_LIST,
|
---|
199 | RTFSISOMAKERCMD_OPT_HIDE,
|
---|
200 | RTFSISOMAKERCMD_OPT_HIDE_JOLIET,
|
---|
201 | RTFSISOMAKERCMD_OPT_HIDE_JOLIET_LIST,
|
---|
202 | RTFSISOMAKERCMD_OPT_HIDE_JOLIET_TRANS_TBL,
|
---|
203 | RTFSISOMAKERCMD_OPT_HIDE_LIST,
|
---|
204 | RTFSISOMAKERCMD_OPT_HIDE_RR_MOVED,
|
---|
205 | RTFSISOMAKERCMD_OPT_HPPA_BOOTLOADER,
|
---|
206 | RTFSISOMAKERCMD_OPT_HPPA_CMDLINE,
|
---|
207 | RTFSISOMAKERCMD_OPT_HPPA_KERNEL_32,
|
---|
208 | RTFSISOMAKERCMD_OPT_HPPA_KERNEL_64,
|
---|
209 | RTFSISOMAKERCMD_OPT_HPPA_RAMDISK,
|
---|
210 | RTFSISOMAKERCMD_OPT_INPUT_CHARSET,
|
---|
211 | RTFSISOMAKERCMD_OPT_ISO_LEVEL,
|
---|
212 | RTFSISOMAKERCMD_OPT_JIGDO_COMPRESS,
|
---|
213 | RTFSISOMAKERCMD_OPT_JIGDO_EXCLUDE,
|
---|
214 | RTFSISOMAKERCMD_OPT_JIGDO_FORCE_MD5,
|
---|
215 | RTFSISOMAKERCMD_OPT_JIGDO_JIGDO,
|
---|
216 | RTFSISOMAKERCMD_OPT_JIGDO_MAP,
|
---|
217 | RTFSISOMAKERCMD_OPT_JIGDO_MD5_LIST,
|
---|
218 | RTFSISOMAKERCMD_OPT_JIGDO_MIN_FILE_SIZE,
|
---|
219 | RTFSISOMAKERCMD_OPT_JIGDO_TEMPLATE,
|
---|
220 | RTFSISOMAKERCMD_OPT_JOLIET_CHARSET,
|
---|
221 | RTFSISOMAKERCMD_OPT_JOLIET_LEVEL,
|
---|
222 | RTFSISOMAKERCMD_OPT_JOLIET_LONG,
|
---|
223 | RTFSISOMAKERCMD_OPT_LOG_FILE,
|
---|
224 | RTFSISOMAKERCMD_OPT_MAX_ISO9660_FILENAMES,
|
---|
225 | RTFSISOMAKERCMD_OPT_MIPS_BOOT,
|
---|
226 | RTFSISOMAKERCMD_OPT_MIPSEL_BOOT,
|
---|
227 | RTFSISOMAKERCMD_OPT_NEW_DIR_MODE,
|
---|
228 | RTFSISOMAKERCMD_OPT_NO_BACKUP_FILES,
|
---|
229 | RTFSISOMAKERCMD_OPT_NO_DETECT_HARDLINKS,
|
---|
230 | RTFSISOMAKERCMD_OPT_NO_ISO_TRANSLATE,
|
---|
231 | RTFSISOMAKERCMD_OPT_NO_PAD,
|
---|
232 | RTFSISOMAKERCMD_OPT_NO_RR,
|
---|
233 | RTFSISOMAKERCMD_OPT_NO_SPLIT_SYMLINK_COMPONENTS,
|
---|
234 | RTFSISOMAKERCMD_OPT_NO_SPLIT_SYMLINK_FIELDS,
|
---|
235 | RTFSISOMAKERCMD_OPT_OLD_ROOT,
|
---|
236 | RTFSISOMAKERCMD_OPT_OUTPUT_CHARSET,
|
---|
237 | RTFSISOMAKERCMD_OPT_PAD,
|
---|
238 | RTFSISOMAKERCMD_OPT_PATH_LIST,
|
---|
239 | RTFSISOMAKERCMD_OPT_PRINT_SIZE,
|
---|
240 | RTFSISOMAKERCMD_OPT_QUIET,
|
---|
241 | RTFSISOMAKERCMD_OPT_RELAXED_FILENAMES,
|
---|
242 | RTFSISOMAKERCMD_OPT_ROOT,
|
---|
243 | RTFSISOMAKERCMD_OPT_SORT,
|
---|
244 | RTFSISOMAKERCMD_OPT_SPARC_BOOT,
|
---|
245 | RTFSISOMAKERCMD_OPT_SPARC_LABEL,
|
---|
246 | RTFSISOMAKERCMD_OPT_SPLIT_OUTPUT,
|
---|
247 | RTFSISOMAKERCMD_OPT_STREAM_FILE_NAME,
|
---|
248 | RTFSISOMAKERCMD_OPT_STREAM_MEDIA_SIZE,
|
---|
249 | RTFSISOMAKERCMD_OPT_SUNX86_BOOT,
|
---|
250 | RTFSISOMAKERCMD_OPT_SUNX86_LABEL,
|
---|
251 | RTFSISOMAKERCMD_OPT_SYSTEM_ID,
|
---|
252 | RTFSISOMAKERCMD_OPT_TRANS_TBL_NAME,
|
---|
253 | RTFSISOMAKERCMD_OPT_UDF,
|
---|
254 | RTFSISOMAKERCMD_OPT_UID,
|
---|
255 | RTFSISOMAKERCMD_OPT_USE_FILE_VERSION,
|
---|
256 | RTFSISOMAKERCMD_OPT_VOLUME_ID,
|
---|
257 | RTFSISOMAKERCMD_OPT_VOLUME_SET_ID,
|
---|
258 | RTFSISOMAKERCMD_OPT_VOLUME_SET_SEQ_NO,
|
---|
259 | RTFSISOMAKERCMD_OPT_VOLUME_SET_SIZE,
|
---|
260 | RTFSISOMAKERCMD_OPT_END
|
---|
261 | } RTFSISOMAKERCMDOPT;
|
---|
262 |
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * El Torito boot entry.
|
---|
266 | */
|
---|
267 | typedef struct RTFSISOMKCMDELTORITOENTRY
|
---|
268 | {
|
---|
269 | /** The type of this entry. */
|
---|
270 | enum
|
---|
271 | {
|
---|
272 | kEntryType_Invalid = 0,
|
---|
273 | kEntryType_Validation, /**< Same as kEntryType_SectionHeader, just hardcoded #0. */
|
---|
274 | kEntryType_SectionHeader,
|
---|
275 | kEntryType_Default, /**< Same as kEntryType_Section, just hardcoded #1. */
|
---|
276 | kEntryType_Section
|
---|
277 | } enmType;
|
---|
278 | /** Type specific data. */
|
---|
279 | union
|
---|
280 | {
|
---|
281 | struct
|
---|
282 | {
|
---|
283 | /** The platform ID (ISO9660_ELTORITO_PLATFORM_ID_XXX). */
|
---|
284 | uint8_t idPlatform;
|
---|
285 | /** Some string for the header. */
|
---|
286 | const char *pszString;
|
---|
287 | } Validation,
|
---|
288 | SectionHeader;
|
---|
289 | struct
|
---|
290 | {
|
---|
291 | /** The name of the boot image wihtin the ISO (-b option). */
|
---|
292 | const char *pszImageNameInIso;
|
---|
293 | /** The object ID of the image in the ISO. This is set to UINT32_MAX when
|
---|
294 | * pszImageNameInIso is used (i.e. -b option) and we've delayed everything
|
---|
295 | * boot related till after all files have been added to the image. */
|
---|
296 | uint32_t idxImageObj;
|
---|
297 | /** Whether to insert boot info table into the image. */
|
---|
298 | bool fInsertBootInfoTable;
|
---|
299 | /** Bootble or not. Possible to make BIOS set up emulation w/o booting it. */
|
---|
300 | bool fBootable;
|
---|
301 | /** The media type (ISO9660_ELTORITO_BOOT_MEDIA_TYPE_XXX). */
|
---|
302 | uint8_t bBootMediaType;
|
---|
303 | /** File system / partition type. */
|
---|
304 | uint8_t bSystemType;
|
---|
305 | /** Load address divided by 0x10. */
|
---|
306 | uint16_t uLoadSeg;
|
---|
307 | /** Number of sectors (512) to load. */
|
---|
308 | uint16_t cSectorsToLoad;
|
---|
309 | } Section,
|
---|
310 | Default;
|
---|
311 | } u;
|
---|
312 | } RTFSISOMKCMDELTORITOENTRY;
|
---|
313 | /** Pointer to an el torito boot entry. */
|
---|
314 | typedef RTFSISOMKCMDELTORITOENTRY *PRTFSISOMKCMDELTORITOENTRY;
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * ISO maker command options & state.
|
---|
318 | */
|
---|
319 | typedef struct RTFSISOMAKERCMDOPTS
|
---|
320 | {
|
---|
321 | /** The handle to the ISO maker. */
|
---|
322 | RTFSISOMAKER hIsoMaker;
|
---|
323 | /** Set if we're creating a virtual image maker, i.e. producing something
|
---|
324 | * that is going to be read from only and not written to disk. */
|
---|
325 | bool fVirtualImageMaker;
|
---|
326 | /** Extended error info. This is a stderr alternative for the
|
---|
327 | * fVirtualImageMaker case (stdout goes to LogRel). */
|
---|
328 | PRTERRINFO pErrInfo;
|
---|
329 |
|
---|
330 | /** The output file.
|
---|
331 | * This is NULL when fVirtualImageMaker is set. */
|
---|
332 | const char *pszOutFile;
|
---|
333 | /** Special buffer size to use for testing the ISO maker code reading. */
|
---|
334 | uint32_t cbOutputReadBuffer;
|
---|
335 | /** Use random output read buffer size. cbOutputReadBuffer works as maximum
|
---|
336 | * when this is enabled. */
|
---|
337 | bool fRandomOutputReadBufferSize;
|
---|
338 | /** Do output verification, but do it in random order if non-zero. The
|
---|
339 | * values gives the block size to use. */
|
---|
340 | uint32_t cbRandomOrderVerifciationBlock;
|
---|
341 |
|
---|
342 | /** The current source VFS, NIL_RTVFS if regular file system is used. */
|
---|
343 | RTVFS hSrcVfs;
|
---|
344 | /** The specifier for hSrcVfs (error messages). */
|
---|
345 | const char *pszSrcVfs;
|
---|
346 | /** The option for hSrcVfs. */
|
---|
347 | const char *pszSrcVfsOption;
|
---|
348 |
|
---|
349 | /** @name Processing of inputs
|
---|
350 | * @{ */
|
---|
351 | /** The namespaces (RTFSISOMAKER_NAMESPACE_XXX) we're currently adding
|
---|
352 | * input to. */
|
---|
353 | uint32_t fDstNamespaces;
|
---|
354 | /** The number of name specifiers we're currently operating with. */
|
---|
355 | uint32_t cNameSpecifiers;
|
---|
356 | /** Name specifier configurations.
|
---|
357 | * For instance given "name0=name1=name2=name3=source-file" we will add
|
---|
358 | * source-file to the image with name0 as the name in the namespace and
|
---|
359 | * sub-name specified by aNameSpecifiers[0], name1 in aNameSpecifiers[1],
|
---|
360 | * and so on. This allows exact control over which names a file will
|
---|
361 | * have in each namespace (primary-iso, joliet, udf, hfs) and sub-namespace
|
---|
362 | * (rock-ridge, trans.tbl).
|
---|
363 | */
|
---|
364 | uint32_t afNameSpecifiers[RTFSISOMAKERCMD_MAX_NAMES];
|
---|
365 | /** The forced directory mode. */
|
---|
366 | RTFMODE fDirMode;
|
---|
367 | /** Set if fDirMode should be applied. */
|
---|
368 | bool fDirModeActive;
|
---|
369 | /** Set if fFileMode should be applied. */
|
---|
370 | bool fFileModeActive;
|
---|
371 | /** The force file mode. */
|
---|
372 | RTFMODE fFileMode;
|
---|
373 | /** @} */
|
---|
374 |
|
---|
375 | /** @name Booting related options and state.
|
---|
376 | * @{ */
|
---|
377 | /** Number of boot catalog entries (aBootCatEntries). */
|
---|
378 | uint32_t cBootCatEntries;
|
---|
379 | /** Boot catalog entries. */
|
---|
380 | RTFSISOMKCMDELTORITOENTRY aBootCatEntries[64];
|
---|
381 | /** @} */
|
---|
382 |
|
---|
383 | /** @name Filteringer
|
---|
384 | * @{ */
|
---|
385 | /** The trans.tbl filename when enabled. We must not import these files. */
|
---|
386 | const char *pszTransTbl;
|
---|
387 | /** @} */
|
---|
388 |
|
---|
389 | /** Number of items (files, directories, images, whatever) we've added. */
|
---|
390 | uint32_t cItemsAdded;
|
---|
391 | } RTFSISOMAKERCMDOPTS;
|
---|
392 | typedef RTFSISOMAKERCMDOPTS *PRTFSISOMAKERCMDOPTS;
|
---|
393 | typedef RTFSISOMAKERCMDOPTS const *PCRTFSISOMAKERCMDOPTS;
|
---|
394 |
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * One parsed name.
|
---|
398 | */
|
---|
399 | typedef struct RTFSISOMKCMDPARSEDNAME
|
---|
400 | {
|
---|
401 | /** Copy of the corresponding RTFSISOMAKERCMDOPTS::afNameSpecifiers
|
---|
402 | * value. */
|
---|
403 | uint32_t fNameSpecifiers;
|
---|
404 | /** The length of the specified path. */
|
---|
405 | uint32_t cchPath;
|
---|
406 | /** Specified path. */
|
---|
407 | char szPath[RTPATH_MAX];
|
---|
408 | } RTFSISOMKCMDPARSEDNAME;
|
---|
409 | /** Pointer to a parsed name. */
|
---|
410 | typedef RTFSISOMKCMDPARSEDNAME *PRTFSISOMKCMDPARSEDNAME;
|
---|
411 | /** Pointer to a const parsed name. */
|
---|
412 | typedef RTFSISOMKCMDPARSEDNAME const *PCRTFSISOMKCMDPARSEDNAME;
|
---|
413 |
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Parsed names.
|
---|
417 | */
|
---|
418 | typedef struct RTFSISOMKCMDPARSEDNAMES
|
---|
419 | {
|
---|
420 | /** Number of names. */
|
---|
421 | uint32_t cNames;
|
---|
422 | /** Number of names with the source. */
|
---|
423 | uint32_t cNamesWithSrc;
|
---|
424 | /** Special source types.
|
---|
425 | * Used for conveying commands to do on names intead of adding a source.
|
---|
426 | * Only used when adding generic stuff w/o any options involved. */
|
---|
427 | enum
|
---|
428 | {
|
---|
429 | kSrcType_None,
|
---|
430 | kSrcType_Normal,
|
---|
431 | kSrcType_Remove,
|
---|
432 | kSrcType_MustRemove
|
---|
433 | } enmSrcType;
|
---|
434 | /** The parsed names. */
|
---|
435 | RTFSISOMKCMDPARSEDNAME aNames[RTFSISOMAKERCMD_MAX_NAMES + 1];
|
---|
436 | } RTFSISOMKCMDPARSEDNAMES;
|
---|
437 | /** Pointer to parsed names. */
|
---|
438 | typedef RTFSISOMKCMDPARSEDNAMES *PRTFSISOMKCMDPARSEDNAMES;
|
---|
439 | /** Pointer to const parsed names. */
|
---|
440 | typedef RTFSISOMKCMDPARSEDNAMES *PCRTFSISOMKCMDPARSEDNAMES;
|
---|
441 |
|
---|
442 |
|
---|
443 | /*********************************************************************************************************************************
|
---|
444 | * Global Variables *
|
---|
445 | *********************************************************************************************************************************/
|
---|
446 | /*
|
---|
447 | * Parse the command line. This is similar to genisoimage and mkisofs,
|
---|
448 | * thus the single dash long name aliases.
|
---|
449 | */
|
---|
450 | static const RTGETOPTDEF g_aRtFsIsoMakerOptions[] =
|
---|
451 | {
|
---|
452 | /*
|
---|
453 | * Unique IPRT ISO maker options.
|
---|
454 | */
|
---|
455 | { "--name-setup", RTFSISOMAKERCMD_OPT_NAME_SETUP, RTGETOPT_REQ_STRING },
|
---|
456 | { "--import-iso", RTFSISOMAKERCMD_OPT_IMPORT_ISO, RTGETOPT_REQ_STRING },
|
---|
457 | { "--push-iso", RTFSISOMAKERCMD_OPT_PUSH_ISO, RTGETOPT_REQ_STRING },
|
---|
458 | { "--push-iso-no-joliet", RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_JOLIET, RTGETOPT_REQ_STRING },
|
---|
459 | { "--push-iso-no-rock", RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK, RTGETOPT_REQ_STRING },
|
---|
460 | { "--push-iso-no-rock-no-joliet", RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK_NO_JOLIET, RTGETOPT_REQ_STRING },
|
---|
461 | { "--pop", RTFSISOMAKERCMD_OPT_POP, RTGETOPT_REQ_NOTHING },
|
---|
462 |
|
---|
463 | { "--rock-ridge", RTFSISOMAKERCMD_OPT_ROCK_RIDGE, RTGETOPT_REQ_NOTHING },
|
---|
464 | { "--limited-rock-ridge", RTFSISOMAKERCMD_OPT_LIMITED_ROCK_RIDGE, RTGETOPT_REQ_NOTHING },
|
---|
465 | { "--no-rock-ridge", RTFSISOMAKERCMD_OPT_NO_ROCK_RIDGE, RTGETOPT_REQ_NOTHING },
|
---|
466 | { "--no-joliet", RTFSISOMAKERCMD_OPT_NO_JOLIET, RTGETOPT_REQ_NOTHING },
|
---|
467 | { "--joliet-ucs-level", RTFSISOMAKERCMD_OPT_JOLIET_LEVEL, RTGETOPT_REQ_UINT8 },
|
---|
468 |
|
---|
469 | { "--rational-attribs", RTFSISOMAKERCMD_OPT_RATIONAL_ATTRIBS, RTGETOPT_REQ_NOTHING },
|
---|
470 | { "--strict-attribs", RTFSISOMAKERCMD_OPT_STRICT_ATTRIBS, RTGETOPT_REQ_NOTHING },
|
---|
471 | { "--no-file-mode", RTFSISOMAKERCMD_OPT_NO_FILE_MODE, RTGETOPT_REQ_NOTHING },
|
---|
472 | { "--no-dir-mode", RTFSISOMAKERCMD_OPT_NO_DIR_MODE, RTGETOPT_REQ_NOTHING },
|
---|
473 | { "--chmod", RTFSISOMAKERCMD_OPT_CHMOD, RTGETOPT_REQ_STRING },
|
---|
474 | { "--chown", RTFSISOMAKERCMD_OPT_CHOWN, RTGETOPT_REQ_STRING },
|
---|
475 | { "--chgrp", RTFSISOMAKERCMD_OPT_CHGRP, RTGETOPT_REQ_STRING },
|
---|
476 |
|
---|
477 | { "--eltorito-new-entry", RTFSISOMAKERCMD_OPT_ELTORITO_NEW_ENTRY, RTGETOPT_REQ_NOTHING },
|
---|
478 | { "--eltorito-add-image", RTFSISOMAKERCMD_OPT_ELTORITO_ADD_IMAGE, RTGETOPT_REQ_STRING },
|
---|
479 | { "--eltorito-floppy-12", RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_12, RTGETOPT_REQ_NOTHING },
|
---|
480 | { "--eltorito-floppy-144", RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_144, RTGETOPT_REQ_NOTHING },
|
---|
481 | { "--eltorito-floppy-288", RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_288, RTGETOPT_REQ_NOTHING },
|
---|
482 |
|
---|
483 | { "--iprt-iso-maker-file-marker", RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER, RTGETOPT_REQ_STRING },
|
---|
484 | { "--iprt-iso-maker-file-marker-ms", RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER, RTGETOPT_REQ_STRING },
|
---|
485 | { "--iprt-iso-maker-file-marker-ms-crt", RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER, RTGETOPT_REQ_STRING },
|
---|
486 | { "--iprt-iso-maker-file-marker-bourne", RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER, RTGETOPT_REQ_STRING },
|
---|
487 | { "--iprt-iso-maker-file-marker-bourne-sh", RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER, RTGETOPT_REQ_STRING },
|
---|
488 |
|
---|
489 | { "--output-buffer-size", RTFSISOMAKERCMD_OPT_OUTPUT_BUFFER_SIZE, RTGETOPT_REQ_UINT32 },
|
---|
490 | { "--random-output-buffer-size", RTFSISOMAKERCMD_OPT_RANDOM_OUTPUT_BUFFER_SIZE, RTGETOPT_REQ_NOTHING },
|
---|
491 | { "--random-order-verification", RTFSISOMAKERCMD_OPT_RANDOM_ORDER_VERIFICATION, RTGETOPT_REQ_UINT32 },
|
---|
492 |
|
---|
493 | #define DD(a_szLong, a_chShort, a_fFlags) { a_szLong, a_chShort, a_fFlags }, { "-" a_szLong, a_chShort, a_fFlags }
|
---|
494 |
|
---|
495 | /*
|
---|
496 | * genisoimage/mkisofs compatibility options we've implemented:
|
---|
497 | */
|
---|
498 | /* booting: */
|
---|
499 | { "--generic-boot", 'G', RTGETOPT_REQ_STRING },
|
---|
500 | DD("-eltorito-boot", 'b', RTGETOPT_REQ_STRING ),
|
---|
501 | DD("-eltorito-alt-boot", RTFSISOMAKERCMD_OPT_ELTORITO_NEW_ENTRY, RTGETOPT_REQ_NOTHING ),
|
---|
502 | DD("-eltorito-platform-id", RTFSISOMAKERCMD_OPT_ELTORITO_PLATFORM_ID, RTGETOPT_REQ_STRING ),
|
---|
503 | DD("-hard-disk-boot", RTFSISOMAKERCMD_OPT_ELTORITO_HARD_DISK_BOOT, RTGETOPT_REQ_NOTHING ),
|
---|
504 | DD("-no-emulation-boot", RTFSISOMAKERCMD_OPT_ELTORITO_NO_EMULATION_BOOT, RTGETOPT_REQ_NOTHING ),
|
---|
505 | DD("-no-boot", RTFSISOMAKERCMD_OPT_ELTORITO_NO_BOOT, RTGETOPT_REQ_NOTHING ),
|
---|
506 | DD("-boot-load-seg", RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SEG, RTGETOPT_REQ_UINT16 ),
|
---|
507 | DD("-boot-load-size", RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SIZE, RTGETOPT_REQ_UINT16 ),
|
---|
508 | DD("-boot-info-table", RTFSISOMAKERCMD_OPT_ELTORITO_INFO_TABLE, RTGETOPT_REQ_NOTHING ),
|
---|
509 | { "--boot-catalog", 'c', RTGETOPT_REQ_STRING },
|
---|
510 |
|
---|
511 | /* String props: */
|
---|
512 | DD("-abstract", RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID, RTGETOPT_REQ_STRING ),
|
---|
513 | { "--application-id", 'A', RTGETOPT_REQ_STRING },
|
---|
514 | DD("-biblio", RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID, RTGETOPT_REQ_STRING ),
|
---|
515 | DD("-copyright", RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID, RTGETOPT_REQ_STRING ),
|
---|
516 | DD("-publisher", 'P', RTGETOPT_REQ_STRING ),
|
---|
517 | { "--preparer", 'p', RTGETOPT_REQ_STRING },
|
---|
518 | DD("-sysid", RTFSISOMAKERCMD_OPT_SYSTEM_ID, RTGETOPT_REQ_STRING ),
|
---|
519 | { "--volume-id", RTFSISOMAKERCMD_OPT_VOLUME_ID, RTGETOPT_REQ_STRING }, /* should've been '-V' */
|
---|
520 | DD("-volid", RTFSISOMAKERCMD_OPT_VOLUME_ID, RTGETOPT_REQ_STRING ),
|
---|
521 | DD("-volset", RTFSISOMAKERCMD_OPT_VOLUME_SET_ID, RTGETOPT_REQ_STRING ),
|
---|
522 |
|
---|
523 | /* Other: */
|
---|
524 | DD("-file-mode", RTFSISOMAKERCMD_OPT_FILE_MODE, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
|
---|
525 | DD("-dir-mode", RTFSISOMAKERCMD_OPT_DIR_MODE, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
|
---|
526 | DD("-new-dir-mode", RTFSISOMAKERCMD_OPT_NEW_DIR_MODE, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
|
---|
527 | DD("-graft-points", RTFSISOMAKERCMD_OPT_GRAFT_POINTS, RTGETOPT_REQ_NOTHING ),
|
---|
528 | DD("--iso-level", RTFSISOMAKERCMD_OPT_ISO_LEVEL, RTGETOPT_REQ_UINT8 ),
|
---|
529 | { "--long-names", 'l', RTGETOPT_REQ_NOTHING },
|
---|
530 | { "--output", 'o', RTGETOPT_REQ_STRING },
|
---|
531 | { "--joliet", 'J', RTGETOPT_REQ_NOTHING },
|
---|
532 | DD("-ucs-level", RTFSISOMAKERCMD_OPT_JOLIET_LEVEL, RTGETOPT_REQ_UINT8 ),
|
---|
533 | DD("-rock", 'R', RTGETOPT_REQ_NOTHING ),
|
---|
534 | DD("-rational-rock", 'r', RTGETOPT_REQ_NOTHING ),
|
---|
535 | DD("-pad", RTFSISOMAKERCMD_OPT_PAD, RTGETOPT_REQ_NOTHING ),
|
---|
536 | DD("-no-pad", RTFSISOMAKERCMD_OPT_NO_PAD, RTGETOPT_REQ_NOTHING ),
|
---|
537 |
|
---|
538 | /*
|
---|
539 | * genisoimage/mkisofs compatibility:
|
---|
540 | */
|
---|
541 | DD("-allow-limited-size", RTFSISOMAKERCMD_OPT_ALLOW_LIMITED_SIZE, RTGETOPT_REQ_NOTHING ),
|
---|
542 | DD("-allow-leading-dots", RTFSISOMAKERCMD_OPT_ALLOW_LEADING_DOTS, RTGETOPT_REQ_NOTHING ),
|
---|
543 | DD("-ldots", RTFSISOMAKERCMD_OPT_ALLOW_LEADING_DOTS, RTGETOPT_REQ_NOTHING ),
|
---|
544 | DD("-allow-lowercase", RTFSISOMAKERCMD_OPT_ALLOW_LOWERCASE, RTGETOPT_REQ_NOTHING ),
|
---|
545 | DD("-allow-multidot", RTFSISOMAKERCMD_OPT_ALLOW_MULTI_DOT, RTGETOPT_REQ_NOTHING ),
|
---|
546 | DD("-cache-inodes", RTFSISOMAKERCMD_OPT_DETECT_HARDLINKS, RTGETOPT_REQ_NOTHING ),
|
---|
547 | DD("-no-cache-inodes", RTFSISOMAKERCMD_OPT_NO_DETECT_HARDLINKS, RTGETOPT_REQ_NOTHING ),
|
---|
548 | DD("-alpha-boot", RTFSISOMAKERCMD_OPT_ALPHA_BOOT, RTGETOPT_REQ_STRING ),
|
---|
549 | DD("-hppa-bootloader", RTFSISOMAKERCMD_OPT_HPPA_BOOTLOADER, RTGETOPT_REQ_STRING ),
|
---|
550 | DD("-hppa-cmdline", RTFSISOMAKERCMD_OPT_HPPA_CMDLINE, RTGETOPT_REQ_STRING ),
|
---|
551 | DD("-hppa-kernel-32", RTFSISOMAKERCMD_OPT_HPPA_KERNEL_32, RTGETOPT_REQ_STRING ),
|
---|
552 | DD("-hppa-kernel-64", RTFSISOMAKERCMD_OPT_HPPA_KERNEL_64, RTGETOPT_REQ_STRING ),
|
---|
553 | DD("-hppa-ramdisk", RTFSISOMAKERCMD_OPT_HPPA_RAMDISK, RTGETOPT_REQ_STRING ),
|
---|
554 | DD("-mips-boot", RTFSISOMAKERCMD_OPT_MIPS_BOOT, RTGETOPT_REQ_STRING ),
|
---|
555 | DD("-mipsel-boot", RTFSISOMAKERCMD_OPT_MIPSEL_BOOT, RTGETOPT_REQ_STRING ),
|
---|
556 | DD("-sparc-boot", 'B', RTGETOPT_REQ_STRING ),
|
---|
557 | { "--cd-extra", 'C', RTGETOPT_REQ_STRING },
|
---|
558 | DD("-check-oldnames", RTFSISOMAKERCMD_OPT_CHECK_OLD_NAMES, RTGETOPT_REQ_NOTHING ),
|
---|
559 | DD("-check-session", RTFSISOMAKERCMD_OPT_CHECK_SESSION, RTGETOPT_REQ_STRING ),
|
---|
560 | { "--dont-append-dot", 'd', RTGETOPT_REQ_NOTHING },
|
---|
561 | { "--deep-directories", 'D', RTGETOPT_REQ_NOTHING },
|
---|
562 | DD("-dvd-video", RTFSISOMAKERCMD_OPT_DVD_VIDEO, RTGETOPT_REQ_NOTHING ),
|
---|
563 | DD("-follow-symlinks", 'f', RTGETOPT_REQ_NOTHING ),
|
---|
564 | DD("-gid", RTFSISOMAKERCMD_OPT_GID, RTGETOPT_REQ_UINT32 ),
|
---|
565 | DD("-gui", RTFSISOMAKERCMD_OPT_GUI, RTGETOPT_REQ_NOTHING ),
|
---|
566 | DD("-hide", RTFSISOMAKERCMD_OPT_HIDE, RTGETOPT_REQ_STRING ),
|
---|
567 | DD("-hide-list", RTFSISOMAKERCMD_OPT_HIDE_LIST, RTGETOPT_REQ_STRING ),
|
---|
568 | DD("-hidden", RTFSISOMAKERCMD_OPT_HIDDEN, RTGETOPT_REQ_STRING ),
|
---|
569 | DD("-hidden-list", RTFSISOMAKERCMD_OPT_HIDDEN_LIST, RTGETOPT_REQ_STRING ),
|
---|
570 | DD("-hide-joliet", RTFSISOMAKERCMD_OPT_HIDE_JOLIET, RTGETOPT_REQ_STRING ),
|
---|
571 | DD("-hide-joliet-list", RTFSISOMAKERCMD_OPT_HIDE_JOLIET_LIST, RTGETOPT_REQ_STRING ),
|
---|
572 | DD("-hide-joliet-trans-tbl", RTFSISOMAKERCMD_OPT_HIDE_JOLIET_TRANS_TBL, RTGETOPT_REQ_NOTHING ),
|
---|
573 | DD("-hide-rr-moved", RTFSISOMAKERCMD_OPT_HIDE_RR_MOVED, RTGETOPT_REQ_NOTHING ),
|
---|
574 | DD("-input-charset", RTFSISOMAKERCMD_OPT_INPUT_CHARSET, RTGETOPT_REQ_STRING ),
|
---|
575 | DD("-output-charset", RTFSISOMAKERCMD_OPT_OUTPUT_CHARSET, RTGETOPT_REQ_STRING ),
|
---|
576 | DD("-joliet-long", RTFSISOMAKERCMD_OPT_JOLIET_LONG, RTGETOPT_REQ_NOTHING ),
|
---|
577 | DD("-jcharset", RTFSISOMAKERCMD_OPT_JOLIET_CHARSET, RTGETOPT_REQ_STRING ),
|
---|
578 | { "--leading-dot", 'L', RTGETOPT_REQ_NOTHING },
|
---|
579 | DD("-jigdo-jigdo", RTFSISOMAKERCMD_OPT_JIGDO_JIGDO, RTGETOPT_REQ_STRING ),
|
---|
580 | DD("-jigdo-template", RTFSISOMAKERCMD_OPT_JIGDO_TEMPLATE, RTGETOPT_REQ_STRING ),
|
---|
581 | DD("-jigdo-min-file-size", RTFSISOMAKERCMD_OPT_JIGDO_MIN_FILE_SIZE, RTGETOPT_REQ_UINT64 ),
|
---|
582 | DD("-jigdo-force-md5", RTFSISOMAKERCMD_OPT_JIGDO_FORCE_MD5, RTGETOPT_REQ_STRING ),
|
---|
583 | DD("-jigdo-exclude", RTFSISOMAKERCMD_OPT_JIGDO_EXCLUDE, RTGETOPT_REQ_STRING ),
|
---|
584 | DD("-jigdo-map", RTFSISOMAKERCMD_OPT_JIGDO_MAP, RTGETOPT_REQ_STRING ),
|
---|
585 | DD("-md5-list", RTFSISOMAKERCMD_OPT_JIGDO_MD5_LIST, RTGETOPT_REQ_STRING ),
|
---|
586 | DD("-jigdo-template-compress", RTFSISOMAKERCMD_OPT_JIGDO_COMPRESS, RTGETOPT_REQ_STRING ),
|
---|
587 | DD("-log-file", RTFSISOMAKERCMD_OPT_LOG_FILE, RTGETOPT_REQ_STRING ),
|
---|
588 | { "--exclude", 'm', RTGETOPT_REQ_STRING },
|
---|
589 | { "--exclude", 'x', RTGETOPT_REQ_STRING },
|
---|
590 | DD("-exclude-list", RTFSISOMAKERCMD_OPT_EXCLUDE_LIST, RTGETOPT_REQ_STRING ),
|
---|
591 | DD("-max-iso9660-filenames", RTFSISOMAKERCMD_OPT_MAX_ISO9660_FILENAMES, RTGETOPT_REQ_NOTHING ),
|
---|
592 | { "--merge", 'M', RTGETOPT_REQ_STRING },
|
---|
593 | DD("-dev", 'M', RTGETOPT_REQ_STRING ),
|
---|
594 | { "--omit-version-numbers", 'N', RTGETOPT_REQ_NOTHING },
|
---|
595 | DD("-nobak", RTFSISOMAKERCMD_OPT_NO_BACKUP_FILES, RTGETOPT_REQ_NOTHING ),
|
---|
596 | DD("-no-bak", RTFSISOMAKERCMD_OPT_NO_BACKUP_FILES, RTGETOPT_REQ_NOTHING ),
|
---|
597 | DD("-force-rr", RTFSISOMAKERCMD_OPT_FORCE_RR, RTGETOPT_REQ_NOTHING ),
|
---|
598 | DD("-no-rr", RTFSISOMAKERCMD_OPT_NO_RR, RTGETOPT_REQ_NOTHING ),
|
---|
599 | DD("-no-split-symlink-components", RTFSISOMAKERCMD_OPT_NO_SPLIT_SYMLINK_COMPONENTS, RTGETOPT_REQ_NOTHING ),
|
---|
600 | DD("-no-split-symlink-fields", RTFSISOMAKERCMD_OPT_NO_SPLIT_SYMLINK_FIELDS, RTGETOPT_REQ_NOTHING ),
|
---|
601 | DD("-path-list", RTFSISOMAKERCMD_OPT_PATH_LIST, RTGETOPT_REQ_STRING ),
|
---|
602 | DD("-print-size", RTFSISOMAKERCMD_OPT_PRINT_SIZE, RTGETOPT_REQ_NOTHING ),
|
---|
603 | DD("-quiet", RTFSISOMAKERCMD_OPT_QUIET, RTGETOPT_REQ_NOTHING ),
|
---|
604 | DD("-relaxed-filenames", RTFSISOMAKERCMD_OPT_RELAXED_FILENAMES, RTGETOPT_REQ_NOTHING ),
|
---|
605 | DD("-root", RTFSISOMAKERCMD_OPT_ROOT, RTGETOPT_REQ_STRING ),
|
---|
606 | DD("-old-root", RTFSISOMAKERCMD_OPT_OLD_ROOT, RTGETOPT_REQ_STRING ),
|
---|
607 | DD("-sort", RTFSISOMAKERCMD_OPT_SORT, RTGETOPT_REQ_STRING ),
|
---|
608 | DD("-sparc-boot", RTFSISOMAKERCMD_OPT_SPARC_BOOT, RTGETOPT_REQ_STRING ),
|
---|
609 | DD("-sparc-label", RTFSISOMAKERCMD_OPT_SPARC_LABEL, RTGETOPT_REQ_STRING ),
|
---|
610 | DD("-split-output", RTFSISOMAKERCMD_OPT_SPLIT_OUTPUT, RTGETOPT_REQ_NOTHING ),
|
---|
611 | DD("-stream-media-size", RTFSISOMAKERCMD_OPT_STREAM_MEDIA_SIZE, RTGETOPT_REQ_UINT64 ),
|
---|
612 | DD("-stream-file-name", RTFSISOMAKERCMD_OPT_STREAM_FILE_NAME, RTGETOPT_REQ_STRING ),
|
---|
613 | DD("-sunx86-boot", RTFSISOMAKERCMD_OPT_SUNX86_BOOT, RTGETOPT_REQ_STRING ),
|
---|
614 | DD("-sunx86-label", RTFSISOMAKERCMD_OPT_SUNX86_LABEL, RTGETOPT_REQ_STRING ),
|
---|
615 | { "--trans-tbl", 'T', RTGETOPT_REQ_NOTHING },
|
---|
616 | DD("-table-name", RTFSISOMAKERCMD_OPT_TRANS_TBL_NAME, RTGETOPT_REQ_STRING ),
|
---|
617 | DD("-udf", RTFSISOMAKERCMD_OPT_UDF, RTGETOPT_REQ_NOTHING ),
|
---|
618 | DD("-uid", RTFSISOMAKERCMD_OPT_UID, RTGETOPT_REQ_UINT32 ),
|
---|
619 | DD("-use-fileversion", RTFSISOMAKERCMD_OPT_USE_FILE_VERSION, RTGETOPT_REQ_NOTHING ),
|
---|
620 | { "--untranslated-filenames", 'U', RTGETOPT_REQ_NOTHING },
|
---|
621 | DD("-no-iso-translate", RTFSISOMAKERCMD_OPT_NO_ISO_TRANSLATE, RTGETOPT_REQ_NOTHING ),
|
---|
622 | DD("-volset-size", RTFSISOMAKERCMD_OPT_VOLUME_SET_SIZE, RTGETOPT_REQ_UINT32 ),
|
---|
623 | DD("-volset-seqno", RTFSISOMAKERCMD_OPT_VOLUME_SET_SEQ_NO, RTGETOPT_REQ_UINT32 ),
|
---|
624 | { "--transpared-compression", 'z', RTGETOPT_REQ_NOTHING },
|
---|
625 |
|
---|
626 | /* HFS and ISO-9660 apple extensions. */
|
---|
627 | DD("-hfs", RTFSISOMAKERCMD_OPT_HFS_ENABLE, RTGETOPT_REQ_NOTHING ),
|
---|
628 | DD("-apple", RTFSISOMAKERCMD_OPT_APPLE, RTGETOPT_REQ_NOTHING ),
|
---|
629 | DD("-map", RTFSISOMAKERCMD_OPT_HFS_MAP, RTGETOPT_REQ_STRING ),
|
---|
630 | DD("-magic", RTFSISOMAKERCMD_OPT_HFS_MAGIC, RTGETOPT_REQ_STRING ),
|
---|
631 | DD("-hfs-creator", RTFSISOMAKERCMD_OPT_HFS_CREATOR, RTGETOPT_REQ_STRING ),
|
---|
632 | DD("-hfs-type", RTFSISOMAKERCMD_OPT_HFS_TYPE, RTGETOPT_REQ_STRING ),
|
---|
633 | DD("-probe", RTFSISOMAKERCMD_OPT_HFS_PROBE, RTGETOPT_REQ_NOTHING ),
|
---|
634 | DD("-no-desktop", RTFSISOMAKERCMD_OPT_HFS_NO_DESKTOP, RTGETOPT_REQ_NOTHING ),
|
---|
635 | DD("-mac-name", RTFSISOMAKERCMD_OPT_HFS_MAC_NAME, RTGETOPT_REQ_NOTHING ),
|
---|
636 | DD("-boot-hfs-file", RTFSISOMAKERCMD_OPT_HFS_BOOT_FILE, RTGETOPT_REQ_STRING ),
|
---|
637 | DD("-part", RTFSISOMAKERCMD_OPT_HFS_PART, RTGETOPT_REQ_NOTHING ),
|
---|
638 | DD("-auto", RTFSISOMAKERCMD_OPT_HFS_AUTO, RTGETOPT_REQ_STRING ),
|
---|
639 | DD("-cluster-size", RTFSISOMAKERCMD_OPT_HFS_CLUSTER_SIZE, RTGETOPT_REQ_UINT32 ),
|
---|
640 | DD("-hide-hfs", RTFSISOMAKERCMD_OPT_HFS_HIDE, RTGETOPT_REQ_STRING ),
|
---|
641 | DD("-hide-hfs-list", RTFSISOMAKERCMD_OPT_HFS_HIDE_LIST, RTGETOPT_REQ_STRING ),
|
---|
642 | DD("-hfs-volid", RTFSISOMAKERCMD_OPT_HFS_VOL_ID, RTGETOPT_REQ_STRING ),
|
---|
643 | DD("-icon-position", RTFSISOMAKERCMD_OPT_HFS_ICON_POSITION, RTGETOPT_REQ_NOTHING ),
|
---|
644 | DD("-root-info", RTFSISOMAKERCMD_OPT_HFS_ROOT_INFO, RTGETOPT_REQ_STRING ),
|
---|
645 | DD("-prep-boot", RTFSISOMAKERCMD_OPT_HFS_PREP_BOOT, RTGETOPT_REQ_STRING ),
|
---|
646 | DD("-chrp-boot", RTFSISOMAKERCMD_OPT_HFS_CHRP_BOOT, RTGETOPT_REQ_NOTHING ),
|
---|
647 | DD("-input-hfs-charset", RTFSISOMAKERCMD_OPT_HFS_INPUT_CHARSET, RTGETOPT_REQ_STRING ),
|
---|
648 | DD("-output-hfs-charset", RTFSISOMAKERCMD_OPT_HFS_OUTPUT_CHARSET, RTGETOPT_REQ_STRING ),
|
---|
649 | DD("-hfs-unlock", RTFSISOMAKERCMD_OPT_HFS_UNLOCK, RTGETOPT_REQ_NOTHING ),
|
---|
650 | DD("-hfs-bless", RTFSISOMAKERCMD_OPT_HFS_BLESS, RTGETOPT_REQ_STRING ),
|
---|
651 | DD("-hfs-parms", RTFSISOMAKERCMD_OPT_HFS_PARMS, RTGETOPT_REQ_STRING ),
|
---|
652 | { "--cap", RTFSISOMAKERCMD_OPT_HFS_CAP, RTGETOPT_REQ_NOTHING },
|
---|
653 | { "--netatalk", RTFSISOMAKERCMD_OPT_HFS_NETATALK, RTGETOPT_REQ_NOTHING },
|
---|
654 | { "--double", RTFSISOMAKERCMD_OPT_HFS_DOUBLE, RTGETOPT_REQ_NOTHING },
|
---|
655 | { "--ethershare", RTFSISOMAKERCMD_OPT_HFS_ETHERSHARE, RTGETOPT_REQ_NOTHING },
|
---|
656 | { "--ushare", RTFSISOMAKERCMD_OPT_HFS_USHARE, RTGETOPT_REQ_NOTHING },
|
---|
657 | { "--exchange", RTFSISOMAKERCMD_OPT_HFS_EXCHANGE, RTGETOPT_REQ_NOTHING },
|
---|
658 | { "--sgi", RTFSISOMAKERCMD_OPT_HFS_SGI, RTGETOPT_REQ_NOTHING },
|
---|
659 | { "--xinet", RTFSISOMAKERCMD_OPT_HFS_XINET, RTGETOPT_REQ_NOTHING },
|
---|
660 | { "--macbin", RTFSISOMAKERCMD_OPT_HFS_MACBIN, RTGETOPT_REQ_NOTHING },
|
---|
661 | { "--single", RTFSISOMAKERCMD_OPT_HFS_SINGLE, RTGETOPT_REQ_NOTHING },
|
---|
662 | { "--dave", RTFSISOMAKERCMD_OPT_HFS_DAVE, RTGETOPT_REQ_NOTHING },
|
---|
663 | { "--sfm", RTFSISOMAKERCMD_OPT_HFS_SFM, RTGETOPT_REQ_NOTHING },
|
---|
664 | { "--osx-double", RTFSISOMAKERCMD_OPT_HFS_OSX_DOUBLE, RTGETOPT_REQ_NOTHING },
|
---|
665 | { "--osx-hfs", RTFSISOMAKERCMD_OPT_HFS_OSX_HFS, RTGETOPT_REQ_NOTHING },
|
---|
666 | #undef DD
|
---|
667 | };
|
---|
668 |
|
---|
669 | #ifndef RT_OS_OS2 /* fixme */
|
---|
670 | # include "isomakercmd-man.h"
|
---|
671 | #endif
|
---|
672 |
|
---|
673 |
|
---|
674 | /*********************************************************************************************************************************
|
---|
675 | * Internal Functions *
|
---|
676 | *********************************************************************************************************************************/
|
---|
677 | static int rtFsIsoMakerCmdParse(PRTFSISOMAKERCMDOPTS pOpts, unsigned cArgs, char **papszArgs, unsigned cDepth);
|
---|
678 |
|
---|
679 |
|
---|
680 | /**
|
---|
681 | * Wrapper around RTErrInfoSetV / RTMsgErrorV.
|
---|
682 | *
|
---|
683 | * @returns @a rc
|
---|
684 | * @param pOpts The ISO maker command instance.
|
---|
685 | * @param rc The return code.
|
---|
686 | * @param pszFormat The message format.
|
---|
687 | * @param ... The message format arguments.
|
---|
688 | */
|
---|
689 | static int rtFsIsoMakerCmdErrorRc(PRTFSISOMAKERCMDOPTS pOpts, int rc, const char *pszFormat, ...)
|
---|
690 | {
|
---|
691 | va_list va;
|
---|
692 | va_start(va, pszFormat);
|
---|
693 | if (pOpts->pErrInfo)
|
---|
694 | RTErrInfoSetV(pOpts->pErrInfo, rc, pszFormat, va);
|
---|
695 | else
|
---|
696 | RTMsgErrorV(pszFormat, va);
|
---|
697 | va_end(va);
|
---|
698 | return rc;
|
---|
699 | }
|
---|
700 |
|
---|
701 |
|
---|
702 | /**
|
---|
703 | * Wrapper around RTErrInfoSetV / RTMsgErrorV for doing the job of
|
---|
704 | * RTVfsChainMsgError.
|
---|
705 | *
|
---|
706 | * @returns @a rc
|
---|
707 | * @param pOpts The ISO maker command instance.
|
---|
708 | * @param pszFunction The API called.
|
---|
709 | * @param pszSpec The VFS chain specification or file path passed to the.
|
---|
710 | * @param rc The return code.
|
---|
711 | * @param offError The error offset value returned (0 if not captured).
|
---|
712 | * @param pErrInfo Additional error information. Optional.
|
---|
713 | */
|
---|
714 | static int rtFsIsoMakerCmdChainError(PRTFSISOMAKERCMDOPTS pOpts, const char *pszFunction, const char *pszSpec, int rc,
|
---|
715 | uint32_t offError, PRTERRINFO pErrInfo)
|
---|
716 | {
|
---|
717 | if (RTErrInfoIsSet(pErrInfo))
|
---|
718 | {
|
---|
719 | if (offError > 0)
|
---|
720 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
721 | "%s failed with rc=%Rrc: %s\n"
|
---|
722 | " '%s'\n"
|
---|
723 | " %*s^",
|
---|
724 | pszFunction, rc, pErrInfo->pszMsg, pszSpec, offError, "");
|
---|
725 | else
|
---|
726 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc: %s",
|
---|
727 | pszFunction, pszSpec, rc, pErrInfo->pszMsg);
|
---|
728 | }
|
---|
729 | else
|
---|
730 | {
|
---|
731 | if (offError > 0)
|
---|
732 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
733 | "%s failed with rc=%Rrc:\n"
|
---|
734 | " '%s'\n"
|
---|
735 | " %*s^",
|
---|
736 | pszFunction, rc, pszSpec, offError, "");
|
---|
737 | else
|
---|
738 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc", pszFunction, pszSpec, rc);
|
---|
739 | }
|
---|
740 | return rc;
|
---|
741 | }
|
---|
742 |
|
---|
743 |
|
---|
744 | /**
|
---|
745 | * Wrapper around RTErrInfoSetV / RTMsgErrorV for displaying syntax errors.
|
---|
746 | *
|
---|
747 | * @returns VERR_INVALID_PARAMETER
|
---|
748 | * @param pOpts The ISO maker command instance.
|
---|
749 | * @param pszFormat The message format.
|
---|
750 | * @param ... The message format arguments.
|
---|
751 | */
|
---|
752 | static int rtFsIsoMakerCmdSyntaxError(PRTFSISOMAKERCMDOPTS pOpts, const char *pszFormat, ...)
|
---|
753 | {
|
---|
754 | va_list va;
|
---|
755 | va_start(va, pszFormat);
|
---|
756 | if (pOpts->pErrInfo)
|
---|
757 | RTErrInfoSetV(pOpts->pErrInfo, VERR_INVALID_PARAMETER, pszFormat, va);
|
---|
758 | else
|
---|
759 | RTMsgErrorV(pszFormat, va);
|
---|
760 | va_end(va);
|
---|
761 | return VERR_INVALID_PARAMETER;
|
---|
762 | }
|
---|
763 |
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Wrapper around RTPrintfV / RTLogRelPrintfV.
|
---|
767 | *
|
---|
768 | * @param pOpts The ISO maker command instance.
|
---|
769 | * @param pszFormat The message format.
|
---|
770 | * @param ... The message format arguments.
|
---|
771 | */
|
---|
772 | static void rtFsIsoMakerPrintf(PRTFSISOMAKERCMDOPTS pOpts, const char *pszFormat, ...)
|
---|
773 | {
|
---|
774 | va_list va;
|
---|
775 | va_start(va, pszFormat);
|
---|
776 | if (pOpts->pErrInfo)
|
---|
777 | RTLogRelPrintfV(pszFormat, va);
|
---|
778 | else
|
---|
779 | RTPrintfV(pszFormat, va);
|
---|
780 | va_end(va);
|
---|
781 | }
|
---|
782 |
|
---|
783 | /**
|
---|
784 | * Deletes the state and returns @a rc.
|
---|
785 | *
|
---|
786 | * @returns @a rc.
|
---|
787 | * @param pOpts The ISO maker command instance to delete.
|
---|
788 | * @param rc The status code to return.
|
---|
789 | */
|
---|
790 | static int rtFsIsoMakerCmdDeleteState(PRTFSISOMAKERCMDOPTS pOpts, int rc)
|
---|
791 | {
|
---|
792 | if (pOpts->hIsoMaker != NIL_RTFSISOMAKER)
|
---|
793 | {
|
---|
794 | RTFsIsoMakerRelease(pOpts->hIsoMaker);
|
---|
795 | pOpts->hIsoMaker = NIL_RTFSISOMAKER;
|
---|
796 | }
|
---|
797 |
|
---|
798 | if (pOpts->hSrcVfs != NIL_RTVFS)
|
---|
799 | {
|
---|
800 | RTVfsRelease(pOpts->hSrcVfs);
|
---|
801 | pOpts->hSrcVfs = NIL_RTVFS;
|
---|
802 | }
|
---|
803 |
|
---|
804 | return rc;
|
---|
805 | }
|
---|
806 |
|
---|
807 |
|
---|
808 | /**
|
---|
809 | * Print the usage.
|
---|
810 | *
|
---|
811 | * @param pOpts Options for print metho.
|
---|
812 | * @param pszProgName The program name.
|
---|
813 | */
|
---|
814 | static void rtFsIsoMakerCmdUsage(PRTFSISOMAKERCMDOPTS pOpts, const char *pszProgName)
|
---|
815 | {
|
---|
816 | #ifndef RT_OS_OS2 /* fixme */
|
---|
817 | if (!pOpts->pErrInfo)
|
---|
818 | RTMsgRefEntryHelp(g_pStdOut, &g_viso);
|
---|
819 | else
|
---|
820 | #endif
|
---|
821 | rtFsIsoMakerPrintf(pOpts, "Usage: %s [options] [@commands.rsp] <filespec...>\n",
|
---|
822 | RTPathFilename(pszProgName));
|
---|
823 | }
|
---|
824 |
|
---|
825 |
|
---|
826 | /**
|
---|
827 | * Verifies the image content by reading blocks in random order.
|
---|
828 | *
|
---|
829 | * This is for exercise the virtual ISO code better and test that we get the
|
---|
830 | * same data when reading something twice.
|
---|
831 | *
|
---|
832 | * @returns IPRT status code.
|
---|
833 | * @param pOpts The ISO maker command instance.
|
---|
834 | * @param hVfsSrcFile The source file (virtual ISO).
|
---|
835 | * @param hVfsDstFile The destination file (image file on disk).
|
---|
836 | * @param cbImage The size of the ISO.
|
---|
837 | */
|
---|
838 | static int rtFsIsoMakerCmdVerifyImageInRandomOrder(PRTFSISOMAKERCMDOPTS pOpts, RTVFSFILE hVfsSrcFile,
|
---|
839 | RTVFSFILE hVfsDstFile, uint64_t cbImage)
|
---|
840 | {
|
---|
841 | /*
|
---|
842 | * Figure the buffer (block) size and allocate a bitmap for noting down blocks we've covered.
|
---|
843 | */
|
---|
844 | int rc;
|
---|
845 | size_t cbBuf = RT_MAX(pOpts->cbRandomOrderVerifciationBlock, 1);
|
---|
846 | uint64_t cBlocks64 = (cbImage + cbBuf - 1) / cbBuf;
|
---|
847 | if (cBlocks64 > _512M)
|
---|
848 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_OUT_OF_RANGE,
|
---|
849 | "verification block count too high: cBlocks=%#RX64 (cbBuf=%#zx), max 512M", cBlocks64, cbBuf);
|
---|
850 | uint32_t cBlocks = (uint32_t)cBlocks64;
|
---|
851 | uint32_t cbBitmap = (cBlocks + 63) / 8;
|
---|
852 | if (cbBitmap > _64M)
|
---|
853 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_OUT_OF_RANGE,
|
---|
854 | "verification bitmap too big: cbBitmap=%#RX32 (cbBuf=%#zx), max 64MB", cbBitmap, cbBuf);
|
---|
855 | void *pvSrcBuf = RTMemTmpAlloc(cbBuf);
|
---|
856 | void *pvDstBuf = RTMemTmpAlloc(cbBuf);
|
---|
857 | void *pvBitmap = RTMemTmpAllocZ(cbBitmap);
|
---|
858 | if (pvSrcBuf && pvDstBuf && pvBitmap)
|
---|
859 | {
|
---|
860 | /* Must set the unused bits in the top qword. */
|
---|
861 | for (uint32_t i = RT_ALIGN_32(cBlocks, 64) - 1; i >= cBlocks; i--)
|
---|
862 | ASMBitSet(pvBitmap, i);
|
---|
863 |
|
---|
864 | /*
|
---|
865 | * Do the verification.
|
---|
866 | */
|
---|
867 | rtFsIsoMakerPrintf(pOpts, "Verifying image in random order using %zu (%#zx) byte blocks: %#RX32 in blocks\n",
|
---|
868 | cbBuf, cbBuf, cBlocks);
|
---|
869 |
|
---|
870 | rc = VINF_SUCCESS;
|
---|
871 | uint64_t cLeft = cBlocks;
|
---|
872 | while (cLeft-- > 0)
|
---|
873 | {
|
---|
874 | /*
|
---|
875 | * Figure out which block to check next.
|
---|
876 | */
|
---|
877 | uint32_t iBlock = RTRandU32Ex(0, cBlocks - 1);
|
---|
878 | if (!ASMBitTestAndSet(pvBitmap, iBlock))
|
---|
879 | Assert(iBlock < cBlocks);
|
---|
880 | else
|
---|
881 | {
|
---|
882 | /* try 32 other random numbers. */
|
---|
883 | bool fBitSet;
|
---|
884 | unsigned cTries = 0;
|
---|
885 | do
|
---|
886 | {
|
---|
887 | iBlock = RTRandU32Ex(0, cBlocks - 1);
|
---|
888 | fBitSet = ASMBitTestAndSet(pvBitmap, iBlock);
|
---|
889 | } while (fBitSet && ++cTries < 32);
|
---|
890 | if (fBitSet)
|
---|
891 | {
|
---|
892 | /* Look for the next clear bit after it (with wrap around). */
|
---|
893 | int iHit = ASMBitNextClear(pvBitmap, cBlocks, iBlock);
|
---|
894 | Assert(iHit < (int32_t)cBlocks);
|
---|
895 | if (iHit < 0)
|
---|
896 | {
|
---|
897 | iHit = ASMBitFirstClear(pvBitmap, iBlock);
|
---|
898 | Assert(iHit < (int32_t)cBlocks);
|
---|
899 | }
|
---|
900 | if (iHit >= 0)
|
---|
901 | {
|
---|
902 | fBitSet = ASMBitTestAndSet(pvBitmap, iHit);
|
---|
903 | if (!fBitSet)
|
---|
904 | iBlock = iHit;
|
---|
905 | else
|
---|
906 | {
|
---|
907 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_INTERNAL_ERROR_3,
|
---|
908 | "Bitmap weirdness: iHit=%#x iBlock=%#x cLeft=%#x cBlocks=%#x",
|
---|
909 | iHit, iBlock, cLeft, cBlocks);
|
---|
910 | if (!pOpts->pErrInfo)
|
---|
911 | RTMsgInfo("Bitmap: %#RX32 bytes\n%.*Rhxd", cbBitmap, cbBitmap, pvBitmap);
|
---|
912 | break;
|
---|
913 | }
|
---|
914 | }
|
---|
915 | else
|
---|
916 | {
|
---|
917 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_INTERNAL_ERROR_2,
|
---|
918 | "Bitmap weirdness: iBlock=%#x cLeft=%#x cBlocks=%#x",
|
---|
919 | iBlock, cLeft, cBlocks);
|
---|
920 | if (!pOpts->pErrInfo)
|
---|
921 | RTMsgInfo("Bitmap: %#RX32 bytes\n%.*Rhxd", cbBitmap, cbBitmap, pvBitmap);
|
---|
922 | break;
|
---|
923 | }
|
---|
924 | }
|
---|
925 | }
|
---|
926 | Assert(ASMBitTest(pvBitmap, iBlock));
|
---|
927 |
|
---|
928 | /*
|
---|
929 | * Figure out how much and where to read (last block fun).
|
---|
930 | */
|
---|
931 | uint64_t offBlock = iBlock * (uint64_t)cbBuf;
|
---|
932 | size_t cbToRead = cbBuf;
|
---|
933 | if (iBlock + 1 < cBlocks)
|
---|
934 | { /* likely */ }
|
---|
935 | else if (cbToRead > cbImage - offBlock)
|
---|
936 | cbToRead = (size_t)(cbImage - offBlock);
|
---|
937 | Assert(offBlock + cbToRead <= cbImage);
|
---|
938 |
|
---|
939 | /*
|
---|
940 | * Read the blocks.
|
---|
941 | */
|
---|
942 | //RTPrintf("Reading block #%#x at %#RX64\n", iBlock, offBlock);
|
---|
943 | rc = RTVfsFileReadAt(hVfsDstFile, offBlock, pvDstBuf, cbToRead, NULL);
|
---|
944 | if (RT_SUCCESS(rc))
|
---|
945 | {
|
---|
946 | memset(pvSrcBuf, 0xdd, cbBuf);
|
---|
947 | rc = RTVfsFileReadAt(hVfsSrcFile, offBlock, pvSrcBuf, cbToRead, NULL);
|
---|
948 | if (RT_SUCCESS(rc))
|
---|
949 | {
|
---|
950 | if (memcmp(pvDstBuf, pvSrcBuf, cbToRead) == 0)
|
---|
951 | continue;
|
---|
952 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_MISMATCH,
|
---|
953 | "Block #%#x differs! offBlock=%#RX64 cbToRead=%#zu\n"
|
---|
954 | "Virtual ISO (source):\n%.*Rhxd\nWritten ISO (destination):\n%.*Rhxd",
|
---|
955 | iBlock, offBlock, cbToRead, cbToRead, pvSrcBuf, cbToRead, pvDstBuf);
|
---|
956 | }
|
---|
957 | else
|
---|
958 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
959 | "Error reading %#zx bytes source (virtual ISO) block #%#x at %#RX64: %Rrc",
|
---|
960 | cbToRead, iBlock, offBlock, rc);
|
---|
961 | }
|
---|
962 | else
|
---|
963 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
964 | "Error reading %#zx bytes destination (written ISO) block #%#x at %#RX64: %Rrc",
|
---|
965 | cbToRead, iBlock, offBlock, rc);
|
---|
966 | break;
|
---|
967 | }
|
---|
968 |
|
---|
969 | if (RT_SUCCESS(rc))
|
---|
970 | rtFsIsoMakerPrintf(pOpts, "Written image verified fine!\n");
|
---|
971 | }
|
---|
972 | else if (!pvSrcBuf || !pvDstBuf)
|
---|
973 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "RTMemTmpAlloc(%#zx) failed", cbBuf);
|
---|
974 | else
|
---|
975 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "RTMemTmpAlloc(%#zx) failed", cbBuf);
|
---|
976 | RTMemTmpFree(pvBitmap);
|
---|
977 | RTMemTmpFree(pvDstBuf);
|
---|
978 | RTMemTmpFree(pvSrcBuf);
|
---|
979 | return rc;
|
---|
980 | }
|
---|
981 |
|
---|
982 |
|
---|
983 | /**
|
---|
984 | * Writes the image to file, no checking, no special buffering.
|
---|
985 | *
|
---|
986 | * @returns IPRT status code.
|
---|
987 | * @param pOpts The ISO maker command instance.
|
---|
988 | * @param hVfsSrcFile The source file from the ISO maker.
|
---|
989 | * @param hVfsDstFile The destination file (image file on disk).
|
---|
990 | * @param cbImage The size of the ISO.
|
---|
991 | * @param ppvBuf Pointer to the buffer pointer. The buffer will
|
---|
992 | * be reallocated, but we want the luxary of the
|
---|
993 | * caller freeing it.
|
---|
994 | */
|
---|
995 | static int rtFsIsoMakerCmdWriteImageRandomBufferSize(PRTFSISOMAKERCMDOPTS pOpts, RTVFSFILE hVfsSrcFile, RTVFSFILE hVfsDstFile,
|
---|
996 | uint64_t cbImage, void **ppvBuf)
|
---|
997 | {
|
---|
998 | /*
|
---|
999 | * Copy the virtual image bits to the destination file.
|
---|
1000 | */
|
---|
1001 | void *pvBuf = *ppvBuf;
|
---|
1002 | uint32_t cbMaxBuf = pOpts->cbOutputReadBuffer > 0 ? pOpts->cbOutputReadBuffer : _64K;
|
---|
1003 | uint64_t offImage = 0;
|
---|
1004 | while (offImage < cbImage)
|
---|
1005 | {
|
---|
1006 | /* Figure out how much to copy this time. */
|
---|
1007 | size_t cbToCopy = RTRandU32Ex(1, cbMaxBuf - 1);
|
---|
1008 | if (offImage + cbToCopy < cbImage)
|
---|
1009 | { /* likely */ }
|
---|
1010 | else
|
---|
1011 | cbToCopy = (size_t)(cbImage - offImage);
|
---|
1012 | RTMemFree(pvBuf);
|
---|
1013 | *ppvBuf = pvBuf = RTMemTmpAlloc(cbToCopy);
|
---|
1014 | if (pvBuf)
|
---|
1015 | {
|
---|
1016 | /* Do the copying. */
|
---|
1017 | int rc = RTVfsFileReadAt(hVfsSrcFile, offImage, pvBuf, cbToCopy, NULL);
|
---|
1018 | if (RT_SUCCESS(rc))
|
---|
1019 | {
|
---|
1020 | rc = RTVfsFileWriteAt(hVfsDstFile, offImage, pvBuf, cbToCopy, NULL);
|
---|
1021 | if (RT_SUCCESS(rc))
|
---|
1022 | offImage += cbToCopy;
|
---|
1023 | else
|
---|
1024 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error %Rrc writing %#zx bytes at offset %#RX64 to '%s'",
|
---|
1025 | rc, cbToCopy, offImage, pOpts->pszOutFile);
|
---|
1026 | }
|
---|
1027 | else
|
---|
1028 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error %Rrc read %#zx bytes at offset %#RX64", rc, cbToCopy, offImage);
|
---|
1029 | }
|
---|
1030 | else
|
---|
1031 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "RTMemTmpAlloc(%#zx) failed", cbToCopy);
|
---|
1032 | }
|
---|
1033 | return VINF_SUCCESS;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | /**
|
---|
1038 | * Writes the image to file, no checking, no special buffering.
|
---|
1039 | *
|
---|
1040 | * @returns IPRT status code.
|
---|
1041 | * @param pOpts The ISO maker command instance.
|
---|
1042 | * @param hVfsSrcFile The source file from the ISO maker.
|
---|
1043 | * @param hVfsDstFile The destination file (image file on disk).
|
---|
1044 | * @param cbImage The size of the ISO.
|
---|
1045 | * @param pvBuf Pointer to read buffer.
|
---|
1046 | * @param cbBuf The buffer size.
|
---|
1047 | */
|
---|
1048 | static int rtFsIsoMakerCmdWriteImageSimple(PRTFSISOMAKERCMDOPTS pOpts, RTVFSFILE hVfsSrcFile, RTVFSFILE hVfsDstFile,
|
---|
1049 | uint64_t cbImage, void *pvBuf, size_t cbBuf)
|
---|
1050 | {
|
---|
1051 | /*
|
---|
1052 | * Copy the virtual image bits to the destination file.
|
---|
1053 | */
|
---|
1054 | uint64_t offImage = 0;
|
---|
1055 | while (offImage < cbImage)
|
---|
1056 | {
|
---|
1057 | /* Figure out how much to copy this time. */
|
---|
1058 | size_t cbToCopy = cbBuf;
|
---|
1059 | if (offImage + cbToCopy < cbImage)
|
---|
1060 | { /* likely */ }
|
---|
1061 | else
|
---|
1062 | cbToCopy = (size_t)(cbImage - offImage);
|
---|
1063 |
|
---|
1064 | /* Do the copying. */
|
---|
1065 | int rc = RTVfsFileReadAt(hVfsSrcFile, offImage, pvBuf, cbToCopy, NULL);
|
---|
1066 | if (RT_SUCCESS(rc))
|
---|
1067 | {
|
---|
1068 | rc = RTVfsFileWriteAt(hVfsDstFile, offImage, pvBuf, cbToCopy, NULL);
|
---|
1069 | if (RT_SUCCESS(rc))
|
---|
1070 | offImage += cbToCopy;
|
---|
1071 | else
|
---|
1072 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error %Rrc writing %#zx bytes at offset %#RX64 to '%s'",
|
---|
1073 | rc, cbToCopy, offImage, pOpts->pszOutFile);
|
---|
1074 | }
|
---|
1075 | else
|
---|
1076 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error %Rrc read %#zx bytes at offset %#RX64", rc, cbToCopy, offImage);
|
---|
1077 | }
|
---|
1078 | return VINF_SUCCESS;
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 |
|
---|
1082 | /**
|
---|
1083 | * Writes the image to file.
|
---|
1084 | *
|
---|
1085 | * @returns IPRT status code.
|
---|
1086 | * @param pOpts The ISO maker command instance.
|
---|
1087 | * @param hVfsSrcFile The source file from the ISO maker.
|
---|
1088 | */
|
---|
1089 | static int rtFsIsoMakerCmdWriteImage(PRTFSISOMAKERCMDOPTS pOpts, RTVFSFILE hVfsSrcFile)
|
---|
1090 | {
|
---|
1091 | /*
|
---|
1092 | * Get the image size and setup the copy buffer.
|
---|
1093 | */
|
---|
1094 | uint64_t cbImage;
|
---|
1095 | int rc = RTVfsFileGetSize(hVfsSrcFile, &cbImage);
|
---|
1096 | if (RT_SUCCESS(rc))
|
---|
1097 | {
|
---|
1098 | rtFsIsoMakerPrintf(pOpts, "Image size: %'RU64 (%#RX64) bytes\n", cbImage, cbImage);
|
---|
1099 |
|
---|
1100 | uint32_t cbBuf = pOpts->cbOutputReadBuffer == 0 ? _1M : pOpts->cbOutputReadBuffer;
|
---|
1101 | void *pvBuf = RTMemTmpAlloc(cbBuf);
|
---|
1102 | if (pvBuf)
|
---|
1103 | {
|
---|
1104 | /*
|
---|
1105 | * Open the output file.
|
---|
1106 | */
|
---|
1107 | RTVFSFILE hVfsDstFile;
|
---|
1108 | uint32_t offError;
|
---|
1109 | RTERRINFOSTATIC ErrInfo;
|
---|
1110 | rc = RTVfsChainOpenFile(pOpts->pszOutFile, RTFILE_O_READWRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE,
|
---|
1111 | &hVfsDstFile, &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
1112 | if (RT_SUCCESS(rc))
|
---|
1113 | {
|
---|
1114 | /*
|
---|
1115 | * Apply the desired writing method.
|
---|
1116 | */
|
---|
1117 | if (!pOpts->fRandomOutputReadBufferSize)
|
---|
1118 | rc = rtFsIsoMakerCmdWriteImageRandomBufferSize(pOpts, hVfsSrcFile, hVfsDstFile, cbImage, &pvBuf);
|
---|
1119 | else
|
---|
1120 | rc = rtFsIsoMakerCmdWriteImageSimple(pOpts, hVfsSrcFile, hVfsDstFile, cbImage, pvBuf, cbBuf);
|
---|
1121 | RTMemTmpFree(pvBuf);
|
---|
1122 |
|
---|
1123 | if (RT_SUCCESS(rc) && pOpts->cbRandomOrderVerifciationBlock > 0)
|
---|
1124 | rc = rtFsIsoMakerCmdVerifyImageInRandomOrder(pOpts, hVfsSrcFile, hVfsDstFile, cbImage);
|
---|
1125 |
|
---|
1126 | /*
|
---|
1127 | * Flush the output file before releasing it.
|
---|
1128 | */
|
---|
1129 | if (RT_SUCCESS(rc))
|
---|
1130 | {
|
---|
1131 | rc = RTVfsFileFlush(hVfsDstFile);
|
---|
1132 | if (RT_FAILURE(rc))
|
---|
1133 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTVfsFileFlush failed on '%s': %Rrc", pOpts->pszOutFile, rc);
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | RTVfsFileRelease(hVfsDstFile);
|
---|
1137 | }
|
---|
1138 | else
|
---|
1139 | {
|
---|
1140 | RTMemTmpFree(pvBuf);
|
---|
1141 | rc = rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainOpenFile", pOpts->pszOutFile, rc, offError, &ErrInfo.Core);
|
---|
1142 | }
|
---|
1143 | }
|
---|
1144 | else
|
---|
1145 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "RTMemTmpAlloc(%zu) failed", cbBuf);
|
---|
1146 | }
|
---|
1147 | else
|
---|
1148 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTVfsFileGetSize failed: %Rrc", rc);
|
---|
1149 | return rc;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 |
|
---|
1153 | /**
|
---|
1154 | * Formats @a fNameSpecifiers into a '+' separated list of names.
|
---|
1155 | *
|
---|
1156 | * @returns pszDst
|
---|
1157 | * @param fNameSpecifiers The name specifiers.
|
---|
1158 | * @param pszDst The destination bufer.
|
---|
1159 | * @param cbDst The size of the destination buffer.
|
---|
1160 | */
|
---|
1161 | static char *rtFsIsoMakerCmdNameSpecifiersToString(uint32_t fNameSpecifiers, char *pszDst, size_t cbDst)
|
---|
1162 | {
|
---|
1163 | static struct { const char *pszName; uint32_t cchName; uint32_t fSpec; } const s_aSpecs[] =
|
---|
1164 | {
|
---|
1165 | { RT_STR_TUPLE("primary"), RTFSISOMAKERCMDNAME_PRIMARY_ISO },
|
---|
1166 | { RT_STR_TUPLE("primary-rock"), RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE },
|
---|
1167 | { RT_STR_TUPLE("primary-trans-tbl"), RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL },
|
---|
1168 | { RT_STR_TUPLE("joliet"), RTFSISOMAKERCMDNAME_JOLIET },
|
---|
1169 | { RT_STR_TUPLE("joliet-rock"), RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE },
|
---|
1170 | { RT_STR_TUPLE("joliet-trans-tbl"), RTFSISOMAKERCMDNAME_JOLIET_TRANS_TBL },
|
---|
1171 | { RT_STR_TUPLE("udf"), RTFSISOMAKERCMDNAME_UDF },
|
---|
1172 | { RT_STR_TUPLE("udf-trans-tbl"), RTFSISOMAKERCMDNAME_UDF_TRANS_TBL },
|
---|
1173 | { RT_STR_TUPLE("hfs"), RTFSISOMAKERCMDNAME_HFS },
|
---|
1174 | { RT_STR_TUPLE("hfs-trans-tbl"), RTFSISOMAKERCMDNAME_HFS_TRANS_TBL },
|
---|
1175 | };
|
---|
1176 |
|
---|
1177 | Assert(cbDst > 0);
|
---|
1178 | char *pszRet = pszDst;
|
---|
1179 | for (uint32_t i = 0; i < RT_ELEMENTS(s_aSpecs); i++)
|
---|
1180 | if (s_aSpecs[i].fSpec & fNameSpecifiers)
|
---|
1181 | {
|
---|
1182 | if (pszDst != pszRet && cbDst > 1)
|
---|
1183 | {
|
---|
1184 | *pszDst++ = '+';
|
---|
1185 | cbDst--;
|
---|
1186 | }
|
---|
1187 | if (cbDst > s_aSpecs[i].cchName)
|
---|
1188 | {
|
---|
1189 | memcpy(pszDst, s_aSpecs[i].pszName, s_aSpecs[i].cchName);
|
---|
1190 | cbDst -= s_aSpecs[i].cchName;
|
---|
1191 | pszDst += s_aSpecs[i].cchName;
|
---|
1192 | }
|
---|
1193 | else if (cbDst > 1)
|
---|
1194 | {
|
---|
1195 | memcpy(pszDst, s_aSpecs[i].pszName, cbDst - 1);
|
---|
1196 | pszDst += cbDst - 1;
|
---|
1197 | cbDst = 1;
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | fNameSpecifiers &= ~s_aSpecs[i].fSpec;
|
---|
1201 | if (!fNameSpecifiers)
|
---|
1202 | break;
|
---|
1203 | }
|
---|
1204 | *pszDst = '\0';
|
---|
1205 | return pszRet;
|
---|
1206 | }
|
---|
1207 |
|
---|
1208 |
|
---|
1209 | /**
|
---|
1210 | * Parses the --name-setup option.
|
---|
1211 | *
|
---|
1212 | * @returns IPRT status code.
|
---|
1213 | * @param pOpts The ISO maker command instance.
|
---|
1214 | * @param pszSpec The name setup specification.
|
---|
1215 | */
|
---|
1216 | static int rtFsIsoMakerCmdOptNameSetup(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSpec)
|
---|
1217 | {
|
---|
1218 | /*
|
---|
1219 | * Comma separated list of one or more specifiers.
|
---|
1220 | */
|
---|
1221 | uint32_t fNamespaces = 0;
|
---|
1222 | uint32_t fPrevMajor = 0;
|
---|
1223 | uint32_t iNameSpecifier = 0;
|
---|
1224 | uint32_t offSpec = 0;
|
---|
1225 | do
|
---|
1226 | {
|
---|
1227 | /*
|
---|
1228 | * Parse up to the next colon or end of string.
|
---|
1229 | */
|
---|
1230 | uint32_t fNameSpecifier = 0;
|
---|
1231 | char ch;
|
---|
1232 | while ( (ch = pszSpec[offSpec]) != '\0'
|
---|
1233 | && ch != ',')
|
---|
1234 | {
|
---|
1235 | if (RT_C_IS_SPACE(ch) || ch == '+' || ch == '|') /* space, '+' and '|' are allowed as name separators. */
|
---|
1236 | offSpec++;
|
---|
1237 | else
|
---|
1238 | {
|
---|
1239 | /* Find the end of the name. */
|
---|
1240 | uint32_t offEndSpec = offSpec + 1;
|
---|
1241 | while ( (ch = pszSpec[offEndSpec]) != '\0'
|
---|
1242 | && ch != ','
|
---|
1243 | && ch != '+'
|
---|
1244 | && ch != '|'
|
---|
1245 | && !RT_C_IS_SPACE(ch))
|
---|
1246 | offEndSpec++;
|
---|
1247 |
|
---|
1248 | #define IS_EQUAL(a_sz) (cchName == sizeof(a_sz) - 1U && strncmp(pchName, a_sz, sizeof(a_sz) - 1U) == 0)
|
---|
1249 | const char * const pchName = &pszSpec[offSpec];
|
---|
1250 | uint32_t const cchName = offEndSpec - offSpec;
|
---|
1251 | /* major namespaces */
|
---|
1252 | if ( IS_EQUAL("iso")
|
---|
1253 | || IS_EQUAL("primary")
|
---|
1254 | || IS_EQUAL("iso9660")
|
---|
1255 | || IS_EQUAL("iso-9660")
|
---|
1256 | || IS_EQUAL("primary-iso")
|
---|
1257 | || IS_EQUAL("iso-primary") )
|
---|
1258 | {
|
---|
1259 | fNameSpecifier |= RTFSISOMAKERCMDNAME_PRIMARY_ISO;
|
---|
1260 | fNamespaces |= fPrevMajor = RTFSISOMAKER_NAMESPACE_ISO_9660;
|
---|
1261 | }
|
---|
1262 | else if (IS_EQUAL("joliet"))
|
---|
1263 | {
|
---|
1264 | fNameSpecifier |= RTFSISOMAKERCMDNAME_JOLIET;
|
---|
1265 | fNamespaces |= fPrevMajor = RTFSISOMAKER_NAMESPACE_JOLIET;
|
---|
1266 | }
|
---|
1267 | else if (IS_EQUAL("udf"))
|
---|
1268 | {
|
---|
1269 | #if 0
|
---|
1270 | fNameSpecifier |= RTFSISOMAKERCMDNAME_UDF;
|
---|
1271 | fNamespaces |= fPrevMajor = RTFSISOMAKER_NAMESPACE_UDF;
|
---|
1272 | #else
|
---|
1273 | return rtFsIsoMakerCmdSyntaxError(pOpts, "UDF support is currently not implemented");
|
---|
1274 | #endif
|
---|
1275 | }
|
---|
1276 | else if (IS_EQUAL("hfs") || IS_EQUAL("hfsplus"))
|
---|
1277 | {
|
---|
1278 | #if 0
|
---|
1279 | fNameSpecifier |= RTFSISOMAKERCMDNAME_HFS;
|
---|
1280 | fNamespaces |= fPrevMajor = RTFSISOMAKER_NAMESPACE_HFS;
|
---|
1281 | #else
|
---|
1282 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Hybrid HFS+ support is currently not implemented");
|
---|
1283 | #endif
|
---|
1284 | }
|
---|
1285 | /* rock ridge */
|
---|
1286 | else if ( IS_EQUAL("rr")
|
---|
1287 | || IS_EQUAL("rock")
|
---|
1288 | || IS_EQUAL("rock-ridge"))
|
---|
1289 | {
|
---|
1290 | if (fPrevMajor == RTFSISOMAKERCMDNAME_PRIMARY_ISO)
|
---|
1291 | fNameSpecifier |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE;
|
---|
1292 | else if (fPrevMajor == RTFSISOMAKERCMDNAME_JOLIET)
|
---|
1293 | fNameSpecifier |= RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE;
|
---|
1294 | else
|
---|
1295 | return rtFsIsoMakerCmdSyntaxError(pOpts, "unqualified rock-ridge name specifier");
|
---|
1296 | }
|
---|
1297 | else if ( IS_EQUAL("iso-rr") || IS_EQUAL("iso-rock") || IS_EQUAL("iso-rock-ridge")
|
---|
1298 | || IS_EQUAL("primary-rr") || IS_EQUAL("primary-rock") || IS_EQUAL("primary-rock-ridge")
|
---|
1299 | || IS_EQUAL("iso9660-rr") || IS_EQUAL("iso9660-rock") || IS_EQUAL("iso9660-rock-ridge")
|
---|
1300 | || IS_EQUAL("iso-9660-rr") || IS_EQUAL("iso-9660-rock") || IS_EQUAL("iso-9660-rock-ridge")
|
---|
1301 | || IS_EQUAL("primaryiso-rr") || IS_EQUAL("primaryiso-rock") || IS_EQUAL("primaryiso-rock-ridge")
|
---|
1302 | || IS_EQUAL("primary-iso-rr") || IS_EQUAL("primary-iso-rock") || IS_EQUAL("primary-iso-rock-ridge") )
|
---|
1303 | {
|
---|
1304 | fNameSpecifier |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE;
|
---|
1305 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_PRIMARY_ISO))
|
---|
1306 | return rtFsIsoMakerCmdSyntaxError(pOpts, "iso-9660-rock-ridge must come after the iso-9660 name specifier");
|
---|
1307 | }
|
---|
1308 | else if (IS_EQUAL("joliet-rr") || IS_EQUAL("joliet-rock") || IS_EQUAL("joliet-rock-ridge"))
|
---|
1309 | {
|
---|
1310 | fNameSpecifier |= RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE;
|
---|
1311 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_JOLIET))
|
---|
1312 | return rtFsIsoMakerCmdSyntaxError(pOpts, "joliet-rock-ridge must come after the joliet name specifier");
|
---|
1313 | }
|
---|
1314 | /* trans.tbl */
|
---|
1315 | else if (IS_EQUAL("trans") || IS_EQUAL("trans-tbl"))
|
---|
1316 | {
|
---|
1317 | if (fPrevMajor == RTFSISOMAKERCMDNAME_PRIMARY_ISO)
|
---|
1318 | fNameSpecifier |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
|
---|
1319 | else if (fPrevMajor == RTFSISOMAKERCMDNAME_JOLIET)
|
---|
1320 | fNameSpecifier |= RTFSISOMAKERCMDNAME_JOLIET_TRANS_TBL;
|
---|
1321 | else
|
---|
1322 | return rtFsIsoMakerCmdSyntaxError(pOpts, "unqualified trans-tbl name specifier");
|
---|
1323 | }
|
---|
1324 | else if ( IS_EQUAL("iso-trans") || IS_EQUAL("iso-trans-tbl")
|
---|
1325 | || IS_EQUAL("primary-trans") || IS_EQUAL("primary-trans-tbl")
|
---|
1326 | || IS_EQUAL("iso9660-trans") || IS_EQUAL("iso9660-trans-tbl")
|
---|
1327 | || IS_EQUAL("iso-9660-trans") || IS_EQUAL("iso-9660-trans-tbl")
|
---|
1328 | || IS_EQUAL("primaryiso-trans") || IS_EQUAL("primaryiso-trans-tbl")
|
---|
1329 | || IS_EQUAL("primary-iso-trans") || IS_EQUAL("primary-iso-trans-tbl") )
|
---|
1330 | {
|
---|
1331 | fNameSpecifier |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
|
---|
1332 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_PRIMARY_ISO))
|
---|
1333 | return rtFsIsoMakerCmdSyntaxError(pOpts, "iso-9660-trans-tbl must come after the iso-9660 name specifier");
|
---|
1334 | }
|
---|
1335 | else if (IS_EQUAL("joliet-trans") || IS_EQUAL("joliet-trans-tbl"))
|
---|
1336 | {
|
---|
1337 | fNameSpecifier |= RTFSISOMAKERCMDNAME_JOLIET_TRANS_TBL;
|
---|
1338 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_JOLIET))
|
---|
1339 | return rtFsIsoMakerCmdSyntaxError(pOpts, "joliet-trans-tbl must come after the joliet name specifier");
|
---|
1340 | }
|
---|
1341 | else if (IS_EQUAL("udf-trans") || IS_EQUAL("udf-trans-tbl"))
|
---|
1342 | {
|
---|
1343 | fNameSpecifier |= RTFSISOMAKERCMDNAME_UDF_TRANS_TBL;
|
---|
1344 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_UDF))
|
---|
1345 | return rtFsIsoMakerCmdSyntaxError(pOpts, "udf-trans-tbl must come after the udf name specifier");
|
---|
1346 | }
|
---|
1347 | else if (IS_EQUAL("hfs-trans") || IS_EQUAL("hfs-trans-tbl"))
|
---|
1348 | {
|
---|
1349 | fNameSpecifier |= RTFSISOMAKERCMDNAME_HFS_TRANS_TBL;
|
---|
1350 | if (!(fNamespaces & RTFSISOMAKERCMDNAME_HFS))
|
---|
1351 | return rtFsIsoMakerCmdSyntaxError(pOpts, "hfs-trans-tbl must come after the hfs name specifier");
|
---|
1352 | }
|
---|
1353 | else
|
---|
1354 | return rtFsIsoMakerCmdSyntaxError(pOpts, "unknown name specifier '%.*s'", cchName, pchName);
|
---|
1355 | #undef IS_EQUAL
|
---|
1356 | offSpec = offEndSpec;
|
---|
1357 | }
|
---|
1358 | } /* while same specifier */
|
---|
1359 |
|
---|
1360 | /*
|
---|
1361 | * Check that it wasn't empty.
|
---|
1362 | */
|
---|
1363 | if (fNameSpecifier == 0)
|
---|
1364 | return rtFsIsoMakerCmdSyntaxError(pOpts, "name specifier #%u (0-based) is empty ", iNameSpecifier);
|
---|
1365 |
|
---|
1366 | /*
|
---|
1367 | * Complain if a major namespace name is duplicated. The rock-ridge and
|
---|
1368 | * trans.tbl names are simple to replace, the others affect the two former
|
---|
1369 | * names and are therefore not allowed twice in the list.
|
---|
1370 | */
|
---|
1371 | uint32_t i = iNameSpecifier;
|
---|
1372 | while (i-- > 0)
|
---|
1373 | {
|
---|
1374 | uint32_t fRepeated = (fNameSpecifier & RTFSISOMAKERCMDNAME_MAJOR_MASK)
|
---|
1375 | & (pOpts->afNameSpecifiers[i] & RTFSISOMAKERCMDNAME_MAJOR_MASK);
|
---|
1376 | if (fRepeated)
|
---|
1377 | {
|
---|
1378 | char szTmp[128];
|
---|
1379 | return rtFsIsoMakerCmdSyntaxError(pOpts, "repeating name specifier%s: %s", RT_IS_POWER_OF_TWO(fRepeated) ? "" : "s",
|
---|
1380 | rtFsIsoMakerCmdNameSpecifiersToString(fRepeated, szTmp, sizeof(szTmp)));
|
---|
1381 | }
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | /*
|
---|
1385 | * Add it.
|
---|
1386 | */
|
---|
1387 | if (iNameSpecifier >= RT_ELEMENTS(pOpts->afNameSpecifiers))
|
---|
1388 | return rtFsIsoMakerCmdSyntaxError(pOpts, "too many name specifiers (max %d)", RT_ELEMENTS(pOpts->afNameSpecifiers));
|
---|
1389 | pOpts->afNameSpecifiers[iNameSpecifier] = fNameSpecifier;
|
---|
1390 | iNameSpecifier++;
|
---|
1391 |
|
---|
1392 | /*
|
---|
1393 | * Next, if any.
|
---|
1394 | */
|
---|
1395 | if (pszSpec[offSpec] == ',')
|
---|
1396 | offSpec++;
|
---|
1397 | } while (pszSpec[offSpec] != '\0');
|
---|
1398 |
|
---|
1399 | pOpts->cNameSpecifiers = iNameSpecifier;
|
---|
1400 | pOpts->fDstNamespaces = fNamespaces;
|
---|
1401 |
|
---|
1402 | return VINF_SUCCESS;
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 |
|
---|
1406 | /**
|
---|
1407 | * Processes a non-option argument.
|
---|
1408 | *
|
---|
1409 | * @returns IPRT status code.
|
---|
1410 | * @param pOpts The ISO maker command instance.
|
---|
1411 | * @param pszSpec The specification of what to add.
|
---|
1412 | * @param fWithSrc Whether the specification includes a source path
|
---|
1413 | * or not.
|
---|
1414 | * @param pParsed Where to return the parsed name specification.
|
---|
1415 | */
|
---|
1416 | static int rtFsIsoMakerCmdParseNameSpec(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSpec, bool fWithSrc,
|
---|
1417 | PRTFSISOMKCMDPARSEDNAMES pParsed)
|
---|
1418 | {
|
---|
1419 | const char * const pszSpecIn = pszSpec;
|
---|
1420 | uint32_t const cMaxNames = pOpts->cNameSpecifiers + fWithSrc;
|
---|
1421 |
|
---|
1422 | /*
|
---|
1423 | * Split it up by '='.
|
---|
1424 | */
|
---|
1425 | pParsed->cNames = 0;
|
---|
1426 | pParsed->cNamesWithSrc = 0;
|
---|
1427 | pParsed->enmSrcType = fWithSrc ? RTFSISOMKCMDPARSEDNAMES::kSrcType_Normal : RTFSISOMKCMDPARSEDNAMES::kSrcType_None;
|
---|
1428 | for (;;)
|
---|
1429 | {
|
---|
1430 | const char *pszEqual = strchr(pszSpec, '=');
|
---|
1431 | size_t cchName = pszEqual ? pszEqual - pszSpec : strlen(pszSpec);
|
---|
1432 | bool fNeedSlash = (pszEqual || !fWithSrc) && !RTPATH_IS_SLASH(*pszSpec) && cchName > 0;
|
---|
1433 | if (cchName + fNeedSlash >= sizeof(pParsed->aNames[pParsed->cNamesWithSrc].szPath))
|
---|
1434 | return rtFsIsoMakerCmdSyntaxError(pOpts, "name #%u (0-based) is too long: %s", pParsed->cNamesWithSrc, pszSpecIn);
|
---|
1435 | if (pParsed->cNamesWithSrc >= cMaxNames)
|
---|
1436 | return rtFsIsoMakerCmdSyntaxError(pOpts, "too many names specified (max %u%s): %s",
|
---|
1437 | pOpts->cNameSpecifiers, fWithSrc ? " + source" : "", pszSpecIn);
|
---|
1438 | if (!fNeedSlash)
|
---|
1439 | memcpy(pParsed->aNames[pParsed->cNamesWithSrc].szPath, pszSpec, cchName);
|
---|
1440 | else
|
---|
1441 | {
|
---|
1442 | memcpy(&pParsed->aNames[pParsed->cNamesWithSrc].szPath[1], pszSpec, cchName);
|
---|
1443 | pParsed->aNames[pParsed->cNamesWithSrc].szPath[0] = RTPATH_SLASH;
|
---|
1444 | cchName++;
|
---|
1445 | }
|
---|
1446 | pParsed->aNames[pParsed->cNamesWithSrc].szPath[cchName] = '\0';
|
---|
1447 | pParsed->aNames[pParsed->cNamesWithSrc].cchPath = (uint32_t)cchName;
|
---|
1448 | pParsed->cNamesWithSrc++;
|
---|
1449 |
|
---|
1450 | if (!pszEqual)
|
---|
1451 | {
|
---|
1452 | if (fWithSrc)
|
---|
1453 | {
|
---|
1454 | if (!cchName)
|
---|
1455 | return rtFsIsoMakerCmdSyntaxError(pOpts, "empty source file name: %s", pszSpecIn);
|
---|
1456 | if (cchName == 8 && strcmp(pszSpec, ":remove:") == 0)
|
---|
1457 | pParsed->enmSrcType = RTFSISOMKCMDPARSEDNAMES::kSrcType_Remove;
|
---|
1458 | else if (cchName == 13 && strcmp(pszSpec, ":must-remove:") == 0)
|
---|
1459 | pParsed->enmSrcType = RTFSISOMKCMDPARSEDNAMES::kSrcType_MustRemove;
|
---|
1460 | }
|
---|
1461 | break;
|
---|
1462 | }
|
---|
1463 | pszSpec = pszEqual + 1;
|
---|
1464 | }
|
---|
1465 |
|
---|
1466 | /*
|
---|
1467 | * If there are too few names specified, move the source and repeat the
|
---|
1468 | * last non-source name. If only source, convert source into a name spec.
|
---|
1469 | */
|
---|
1470 | if (pParsed->cNamesWithSrc < cMaxNames)
|
---|
1471 | {
|
---|
1472 | uint32_t iSrc;
|
---|
1473 | if (!fWithSrc)
|
---|
1474 | iSrc = pParsed->cNamesWithSrc - 1;
|
---|
1475 | else
|
---|
1476 | {
|
---|
1477 | pParsed->aNames[pOpts->cNameSpecifiers] = pParsed->aNames[pParsed->cNamesWithSrc - 1];
|
---|
1478 | iSrc = pParsed->cNamesWithSrc >= 2 ? pParsed->cNamesWithSrc - 2 : 0;
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | /* If the source is a input file name specifier, reduce it to something that starts with a slash. */
|
---|
1482 | if (pParsed->cNamesWithSrc == 1 && fWithSrc)
|
---|
1483 | {
|
---|
1484 | const char *pszSrc = pParsed->aNames[iSrc].szPath;
|
---|
1485 | char *pszFinalPath = NULL;
|
---|
1486 | if (RTVfsChainIsSpec(pParsed->aNames[iSrc].szPath))
|
---|
1487 | {
|
---|
1488 | uint32_t offError;
|
---|
1489 | int rc = RTVfsChainQueryFinalPath(pParsed->aNames[iSrc].szPath, &pszFinalPath, &offError);
|
---|
1490 | if (RT_FAILURE(rc))
|
---|
1491 | return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainQueryFinalPath",
|
---|
1492 | pParsed->aNames[iSrc].szPath, rc, offError, NULL);
|
---|
1493 | pszSrc = pszFinalPath;
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | /* Find the start of the last component, ignoring trailing slashes. */
|
---|
1497 | size_t cchSrc = strlen(pszSrc);
|
---|
1498 | size_t offLast = cchSrc;
|
---|
1499 | while (offLast > 0 && RTPATH_IS_SLASH(pszSrc[offLast - 1]))
|
---|
1500 | offLast--;
|
---|
1501 | while (offLast > 0 && !RTPATH_IS_SLASH(pszSrc[offLast - 1]))
|
---|
1502 | offLast--;
|
---|
1503 |
|
---|
1504 | /* Move it up front with a leading slash. */
|
---|
1505 | if (offLast > 0 || !RTPATH_IS_SLASH(*pszSrc))
|
---|
1506 | {
|
---|
1507 | pParsed->aNames[iSrc].cchPath = 1 + (uint32_t)(cchSrc - offLast);
|
---|
1508 | if (pParsed->aNames[iSrc].cchPath >= sizeof(pParsed->aNames[iSrc].szPath))
|
---|
1509 | return rtFsIsoMakerCmdSyntaxError(pOpts, "name too long: %s", pszSpecIn);
|
---|
1510 |
|
---|
1511 | memmove(&pParsed->aNames[iSrc].szPath[1], &pszSrc[offLast], pParsed->aNames[iSrc].cchPath);
|
---|
1512 | }
|
---|
1513 | else
|
---|
1514 | pParsed->aNames[iSrc].cchPath = 1;
|
---|
1515 | pParsed->aNames[iSrc].szPath[0] = RTPATH_SLASH;
|
---|
1516 |
|
---|
1517 | if (pszFinalPath)
|
---|
1518 | RTStrFree(pszFinalPath);
|
---|
1519 | }
|
---|
1520 |
|
---|
1521 | for (uint32_t iDst = iSrc + 1; iDst < pOpts->cNameSpecifiers; iDst++)
|
---|
1522 | pParsed->aNames[iDst] = pParsed->aNames[iSrc];
|
---|
1523 |
|
---|
1524 | pParsed->cNamesWithSrc = cMaxNames;
|
---|
1525 | }
|
---|
1526 | pParsed->cNames = pOpts->cNameSpecifiers;
|
---|
1527 |
|
---|
1528 | /*
|
---|
1529 | * Copy the specifier flags and check that the paths all starts with slashes.
|
---|
1530 | */
|
---|
1531 | for (uint32_t i = 0; i < pOpts->cNameSpecifiers; i++)
|
---|
1532 | {
|
---|
1533 | pParsed->aNames[i].fNameSpecifiers = pOpts->afNameSpecifiers[i];
|
---|
1534 | Assert( pParsed->aNames[i].cchPath == 0
|
---|
1535 | || RTPATH_IS_SLASH(pParsed->aNames[i].szPath[0]));
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | return VINF_SUCCESS;
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 |
|
---|
1542 | /**
|
---|
1543 | * Enteres an object into the namespace by full paths.
|
---|
1544 | *
|
---|
1545 | * This is used by rtFsIsoMakerCmdOptEltoritoSetBootCatalogPath and
|
---|
1546 | * rtFsIsoMakerCmdAddFile.
|
---|
1547 | *
|
---|
1548 | * @returns IPRT status code.
|
---|
1549 | * @param pOpts The ISO maker command instance.
|
---|
1550 | * @param idxObj The configuration index of the object to be named.
|
---|
1551 | * @param pParsed The parsed names.
|
---|
1552 | * @param pszSrcOrName Source file or name.
|
---|
1553 | */
|
---|
1554 | static int rtFsIsoMakerCmdSetObjPaths(PRTFSISOMAKERCMDOPTS pOpts, uint32_t idxObj, PCRTFSISOMKCMDPARSEDNAMES pParsed,
|
---|
1555 | const char *pszSrcOrName)
|
---|
1556 | {
|
---|
1557 | int rc = VINF_SUCCESS;
|
---|
1558 | for (uint32_t i = 0; i < pParsed->cNames; i++)
|
---|
1559 | if (pParsed->aNames[i].cchPath > 0)
|
---|
1560 | {
|
---|
1561 | if (pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK)
|
---|
1562 | {
|
---|
1563 | rc = RTFsIsoMakerObjSetPath(pOpts->hIsoMaker, idxObj,
|
---|
1564 | pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK,
|
---|
1565 | pParsed->aNames[i].szPath);
|
---|
1566 | if (RT_FAILURE(rc))
|
---|
1567 | {
|
---|
1568 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting name '%s' on '%s': %Rrc",
|
---|
1569 | pParsed->aNames[i].szPath, pszSrcOrName, rc);
|
---|
1570 | break;
|
---|
1571 | }
|
---|
1572 | }
|
---|
1573 | if (pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MINOR_MASK)
|
---|
1574 | {
|
---|
1575 | /** @todo add APIs for this. */
|
---|
1576 | }
|
---|
1577 | }
|
---|
1578 | return rc;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 |
|
---|
1582 | /**
|
---|
1583 | * Adds a file.
|
---|
1584 | *
|
---|
1585 | * @returns IPRT status code.
|
---|
1586 | * @param pOpts The ISO maker command instance.
|
---|
1587 | * @param pszSrc The path to the source file.
|
---|
1588 | * @param pParsed The parsed names.
|
---|
1589 | * @param pidxObj Where to return the configuration index for the
|
---|
1590 | * added file. Optional.
|
---|
1591 | */
|
---|
1592 | static int rtFsIsoMakerCmdAddFile(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSrc, PCRTFSISOMKCMDPARSEDNAMES pParsed,
|
---|
1593 | uint32_t *pidxObj)
|
---|
1594 | {
|
---|
1595 | int rc;
|
---|
1596 | uint32_t idxObj = UINT32_MAX;
|
---|
1597 | if ( pOpts->hSrcVfs == NIL_RTVFS
|
---|
1598 | || RTVfsChainIsSpec(pszSrc))
|
---|
1599 | {
|
---|
1600 | rc = RTFsIsoMakerAddUnnamedFileWithSrcPath(pOpts->hIsoMaker, pszSrc, &idxObj);
|
---|
1601 | if (RT_FAILURE(rc))
|
---|
1602 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding '%s': %Rrc", pszSrc, rc);
|
---|
1603 | }
|
---|
1604 | else
|
---|
1605 | {
|
---|
1606 | RTVFSFILE hVfsFileSrc;
|
---|
1607 | rc = RTVfsFileOpen(pOpts->hSrcVfs, pszSrc, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc);
|
---|
1608 | if (RT_FAILURE(rc))
|
---|
1609 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening '%s' (inside '%s'): %Rrc", pszSrc, pOpts->pszSrcVfs, rc);
|
---|
1610 |
|
---|
1611 | rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj);
|
---|
1612 | RTVfsFileRelease(hVfsFileSrc);
|
---|
1613 | if (RT_FAILURE(rc))
|
---|
1614 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding '%s' (VFS): %Rrc", pszSrc, rc);
|
---|
1615 | }
|
---|
1616 |
|
---|
1617 | pOpts->cItemsAdded++;
|
---|
1618 | if (pidxObj)
|
---|
1619 | *pidxObj = idxObj;
|
---|
1620 |
|
---|
1621 | return rtFsIsoMakerCmdSetObjPaths(pOpts, idxObj, pParsed, pszSrc);
|
---|
1622 | }
|
---|
1623 |
|
---|
1624 |
|
---|
1625 | /**
|
---|
1626 | * Applies filtering rules.
|
---|
1627 | *
|
---|
1628 | * @returns true if filtered out, false if included.
|
---|
1629 | * @param pOpts The ISO maker command instance.
|
---|
1630 | * @param pszSrc The source source.
|
---|
1631 | * @param pszName The name part (maybe different buffer from pszSrc).
|
---|
1632 | * @param fIsDir Set if directory, clear if not.
|
---|
1633 | */
|
---|
1634 | static bool rtFsIsoMakerCmdIsFilteredOut(PRTFSISOMAKERCMDOPTS pOpts, const char *pszDir, const char *pszName, bool fIsDir)
|
---|
1635 | {
|
---|
1636 | /* Ignore trans.tbl files. */
|
---|
1637 | if ( !fIsDir
|
---|
1638 | && RTStrICmp(pszName, pOpts->pszTransTbl) == 0)
|
---|
1639 | return true;
|
---|
1640 |
|
---|
1641 | RT_NOREF(pOpts, pszDir, pszName, fIsDir);
|
---|
1642 | return false;
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 |
|
---|
1646 | /**
|
---|
1647 | * Adds a directory, from a VFS chain or real file system.
|
---|
1648 | *
|
---|
1649 | * @returns IPRT status code.
|
---|
1650 | * @param pOpts The ISO maker command instance.
|
---|
1651 | * @param pszSrc The path to the source directory.
|
---|
1652 | * @param pParsed The parsed names.
|
---|
1653 | */
|
---|
1654 | static int rtFsIsoMakerCmdAddDir(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSrc, PCRTFSISOMKCMDPARSEDNAMES pParsed)
|
---|
1655 | {
|
---|
1656 | RT_NOREF(pParsed);
|
---|
1657 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED, "Adding directory '%s' failed: not implemented", pszSrc);
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 |
|
---|
1661 | /**
|
---|
1662 | * Worker for rtFsIsoMakerCmdAddVfsDir that does the recursion.
|
---|
1663 | *
|
---|
1664 | * @returns IPRT status code.
|
---|
1665 | * @param pOpts The ISO maker command instance.
|
---|
1666 | * @param hVfsDir The directory to process.
|
---|
1667 | * @param idxDirObj The configuration index of the directory.
|
---|
1668 | * @param pszSrc Pointer to the source path buffer. RTPATH_MAX
|
---|
1669 | * in size. Okay to modify beyond @a cchSrc.
|
---|
1670 | * @param cchSrc Length of the path corresponding to @a hVfsDir.
|
---|
1671 | * @param fNamespaces Which ISO maker namespaces to add the names to.
|
---|
1672 | * @param cDepth Number of recursions. Used to deal with loopy
|
---|
1673 | * directories.
|
---|
1674 | */
|
---|
1675 | static int rtFsIsoMakerCmdAddVfsDirRecursive(PRTFSISOMAKERCMDOPTS pOpts, RTVFSDIR hVfsDir, uint32_t idxDirObj,
|
---|
1676 | char *pszSrc, size_t cchSrc, uint32_t fNamespaces, uint8_t cDepth)
|
---|
1677 | {
|
---|
1678 | /*
|
---|
1679 | * Check that we're not in too deep.
|
---|
1680 | */
|
---|
1681 | if (cDepth >= RTFSISOMAKERCMD_MAX_DIR_RECURSIONS)
|
---|
1682 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_ISOMK_IMPORT_TOO_DEEP_DIR_TREE,
|
---|
1683 | "Recursive (VFS) dir add too deep (depth=%u): %.*s", cDepth, cchSrc, pszSrc);
|
---|
1684 | /*
|
---|
1685 | * Enumerate the directory.
|
---|
1686 | */
|
---|
1687 | int rc;
|
---|
1688 | size_t cbDirEntryAlloced = sizeof(RTDIRENTRYEX);
|
---|
1689 | PRTDIRENTRYEX pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntryAlloced);
|
---|
1690 | if (pDirEntry)
|
---|
1691 | {
|
---|
1692 | for (;;)
|
---|
1693 | {
|
---|
1694 | /*
|
---|
1695 | * Read the next entry.
|
---|
1696 | */
|
---|
1697 | size_t cbDirEntry = cbDirEntryAlloced;
|
---|
1698 | rc = RTVfsDirReadEx(hVfsDir, pDirEntry, &cbDirEntry, RTFSOBJATTRADD_UNIX);
|
---|
1699 | if (RT_FAILURE(rc))
|
---|
1700 | {
|
---|
1701 | if (rc == VERR_NO_MORE_FILES)
|
---|
1702 | rc = VINF_SUCCESS;
|
---|
1703 | else if (rc == VERR_BUFFER_OVERFLOW)
|
---|
1704 | {
|
---|
1705 | RTMemTmpFree(pDirEntry);
|
---|
1706 | cbDirEntryAlloced = RT_ALIGN_Z(RT_MIN(cbDirEntry, cbDirEntryAlloced) + 64, 64);
|
---|
1707 | pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntryAlloced);
|
---|
1708 | if (pDirEntry)
|
---|
1709 | continue;
|
---|
1710 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "Out of memory (direntry buffer)");
|
---|
1711 | }
|
---|
1712 | else
|
---|
1713 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTVfsDirReadEx failed on %.*s: %Rrc", cchSrc, pszSrc, rc);
|
---|
1714 | break;
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | /* Ignore '.' and '..' entries. */
|
---|
1718 | if (RTDirEntryExIsStdDotLink(pDirEntry))
|
---|
1719 | continue;
|
---|
1720 |
|
---|
1721 | /*
|
---|
1722 | * Process the entry.
|
---|
1723 | */
|
---|
1724 |
|
---|
1725 | /* Update the name. */
|
---|
1726 | if (cchSrc + 1 + pDirEntry->cbName < RTPATH_MAX)
|
---|
1727 | {
|
---|
1728 | pszSrc[cchSrc] = '/'; /* VFS only groks unix slashes */
|
---|
1729 | memcpy(&pszSrc[cchSrc + 1], pDirEntry->szName, pDirEntry->cbName);
|
---|
1730 | pszSrc[cchSrc + 1 + pDirEntry->cbName] = '\0';
|
---|
1731 | }
|
---|
1732 | else
|
---|
1733 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_FILENAME_TOO_LONG, "Filename is too long (depth %u): '%.*s/%s'",
|
---|
1734 | cDepth, cchSrc, pszSrc, pDirEntry->szName);
|
---|
1735 |
|
---|
1736 | /* Okay? Check name filtering. */
|
---|
1737 | if ( RT_SUCCESS(rc)
|
---|
1738 | && !rtFsIsoMakerCmdIsFilteredOut(pOpts, pszSrc, pDirEntry->szName, RTFS_IS_DIRECTORY(pDirEntry->Info.Attr.fMode)))
|
---|
1739 | {
|
---|
1740 | /* Do type specific adding. */
|
---|
1741 | uint32_t idxObj = UINT32_MAX;
|
---|
1742 | if (RTFS_IS_FILE(pDirEntry->Info.Attr.fMode))
|
---|
1743 | {
|
---|
1744 | /*
|
---|
1745 | * Files are added with VFS file sources.
|
---|
1746 | * The ASSUMPTION is that we're working with a virtual file system
|
---|
1747 | * here and won't be wasting native file descriptors.
|
---|
1748 | */
|
---|
1749 | RTVFSFILE hVfsFileSrc;
|
---|
1750 | rc = RTVfsDirOpenFile(hVfsDir, pDirEntry->szName,
|
---|
1751 | RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc);
|
---|
1752 | if (RT_SUCCESS(rc))
|
---|
1753 | {
|
---|
1754 | rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj);
|
---|
1755 | RTVfsFileRelease(hVfsFileSrc);
|
---|
1756 | if (RT_SUCCESS(rc))
|
---|
1757 | {
|
---|
1758 | pOpts->cItemsAdded++;
|
---|
1759 | rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces,
|
---|
1760 | pDirEntry->szName);
|
---|
1761 | if (RT_FAILURE(rc))
|
---|
1762 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting parent & name on file '%s' to '%s': %Rrc",
|
---|
1763 | pszSrc, pDirEntry->szName, rc);
|
---|
1764 | }
|
---|
1765 | else
|
---|
1766 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive): %Rrc", pszSrc, rc);
|
---|
1767 | }
|
---|
1768 | else
|
---|
1769 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening file '%s' (VFS recursive): %Rrc", pszSrc, rc);
|
---|
1770 | }
|
---|
1771 | else if (RTFS_IS_DIRECTORY(pDirEntry->Info.Attr.fMode))
|
---|
1772 | {
|
---|
1773 | /*
|
---|
1774 | * Open and add the sub-directory.
|
---|
1775 | */
|
---|
1776 | RTVFSDIR hVfsSubDirSrc;
|
---|
1777 | rc = RTVfsDirOpenDir(hVfsDir, pDirEntry->szName, 0 /*fFlags*/, &hVfsSubDirSrc);
|
---|
1778 | if (RT_SUCCESS(rc))
|
---|
1779 | {
|
---|
1780 | rc = RTFsIsoMakerAddUnnamedDir(pOpts->hIsoMaker, &pDirEntry->Info, &idxObj);
|
---|
1781 | if (RT_SUCCESS(rc))
|
---|
1782 | {
|
---|
1783 | pOpts->cItemsAdded++;
|
---|
1784 | rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces,
|
---|
1785 | pDirEntry->szName);
|
---|
1786 | if (RT_SUCCESS(rc))
|
---|
1787 | /* Recurse into the sub-directory. */
|
---|
1788 | rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsSubDirSrc, idxObj, pszSrc,
|
---|
1789 | cchSrc + 1 + pDirEntry->cbName, fNamespaces, cDepth + 1);
|
---|
1790 | else
|
---|
1791 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
1792 | "Error setting parent & name on directory '%s' to '%s': %Rrc",
|
---|
1793 | pszSrc, pDirEntry->szName, rc);
|
---|
1794 | }
|
---|
1795 | else
|
---|
1796 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding directory '%s' (VFS recursive): %Rrc", pszSrc, rc);
|
---|
1797 | RTVfsDirRelease(hVfsSubDirSrc);
|
---|
1798 | }
|
---|
1799 | else
|
---|
1800 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening directory '%s' (VFS recursive): %Rrc", pszSrc, rc);
|
---|
1801 | }
|
---|
1802 | else if (RTFS_IS_SYMLINK(pDirEntry->Info.Attr.fMode))
|
---|
1803 | {
|
---|
1804 | /*
|
---|
1805 | * TODO: ISO FS symlink support.
|
---|
1806 | */
|
---|
1807 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED,
|
---|
1808 | "Adding symlink '%s' failed: not yet implemented", pszSrc);
|
---|
1809 | }
|
---|
1810 | else
|
---|
1811 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED,
|
---|
1812 | "Adding special file '%s' failed: not implemented", pszSrc);
|
---|
1813 | }
|
---|
1814 | if (RT_FAILURE(rc))
|
---|
1815 | break;
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | RTMemTmpFree(pDirEntry);
|
---|
1819 | }
|
---|
1820 | else
|
---|
1821 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "Out of memory! (direntry buffer)");
|
---|
1822 | return rc;
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 |
|
---|
1826 | /**
|
---|
1827 | * Adds a directory, from the source VFS.
|
---|
1828 | *
|
---|
1829 | * @returns IPRT status code.
|
---|
1830 | * @param pOpts The ISO maker command instance.
|
---|
1831 | * @param pParsed The parsed names.
|
---|
1832 | * @param pidxObj Where to return the configuration index for the
|
---|
1833 | * added file. Optional.
|
---|
1834 | */
|
---|
1835 | static int rtFsIsoMakerCmdAddVfsDir(PRTFSISOMAKERCMDOPTS pOpts, PCRTFSISOMKCMDPARSEDNAMES pParsed, PCRTFSOBJINFO pObjInfo)
|
---|
1836 | {
|
---|
1837 | Assert(pParsed->cNames < pParsed->cNamesWithSrc);
|
---|
1838 |
|
---|
1839 | /*
|
---|
1840 | * Open the directory.
|
---|
1841 | */
|
---|
1842 | char *pszDir = pParsed->aNames[pParsed->cNamesWithSrc - 1].szPath;
|
---|
1843 | RTPathChangeToUnixSlashes(pszDir, true /*fForce*/); /* VFS currently only understand unix slashes. */
|
---|
1844 | RTVFSDIR hVfsDirSrc;
|
---|
1845 | int rc = RTVfsDirOpen(pOpts->hSrcVfs, pszDir, 0 /*fFlags*/, &hVfsDirSrc);
|
---|
1846 | if (RT_FAILURE(rc))
|
---|
1847 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening directory '%s' (inside '%s'): %Rrc",
|
---|
1848 | pszDir, pOpts->pszSrcVfs, rc);
|
---|
1849 |
|
---|
1850 | /*
|
---|
1851 | * Add the directory if it doesn't exist.
|
---|
1852 | */
|
---|
1853 | uint32_t idxObj = UINT32_MAX;
|
---|
1854 | for (uint32_t i = 0; i < pParsed->cNames; i++)
|
---|
1855 | if (pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK)
|
---|
1856 | {
|
---|
1857 | idxObj = RTFsIsoMakerGetObjIdxForPath(pOpts->hIsoMaker,
|
---|
1858 | pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK,
|
---|
1859 | pParsed->aNames[i].szPath);
|
---|
1860 | if (idxObj != UINT32_MAX)
|
---|
1861 | {
|
---|
1862 | /** @todo make sure the directory is present in the other namespace. */
|
---|
1863 | break;
|
---|
1864 | }
|
---|
1865 | }
|
---|
1866 | if (idxObj == UINT32_MAX)
|
---|
1867 | {
|
---|
1868 | rc = RTFsIsoMakerAddUnnamedDir(pOpts->hIsoMaker, pObjInfo, &idxObj);
|
---|
1869 | if (RT_SUCCESS(rc))
|
---|
1870 | rc = rtFsIsoMakerCmdSetObjPaths(pOpts, idxObj, pParsed, pParsed->aNames[pParsed->cNames - 1].szPath);
|
---|
1871 | else
|
---|
1872 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerAddUnnamedDir failed: %Rrc", rc);
|
---|
1873 | }
|
---|
1874 | if (RT_SUCCESS(rc))
|
---|
1875 | {
|
---|
1876 | /*
|
---|
1877 | * Add the directory content.
|
---|
1878 | */
|
---|
1879 | uint32_t fNamespaces = 0;
|
---|
1880 | for (uint32_t i = 0; i < pParsed->cNames; i++)
|
---|
1881 | fNamespaces |= pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK;
|
---|
1882 | rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsDirSrc, idxObj, pszDir,
|
---|
1883 | pParsed->aNames[pParsed->cNamesWithSrc - 1].cchPath, fNamespaces, 0 /*cDepth*/);
|
---|
1884 | }
|
---|
1885 | RTVfsDirRelease(hVfsDirSrc);
|
---|
1886 | return rc;
|
---|
1887 | }
|
---|
1888 |
|
---|
1889 |
|
---|
1890 |
|
---|
1891 |
|
---|
1892 | /**
|
---|
1893 | * Adds a file after first making sure it's a file.
|
---|
1894 | *
|
---|
1895 | * @returns IPRT status code
|
---|
1896 | * @param pOpts The ISO maker command instance.
|
---|
1897 | * @param pszSrc The path to the source file.
|
---|
1898 | * @param pParsed The parsed names.
|
---|
1899 | * @param pidxObj Where to return the configuration index for the
|
---|
1900 | * added file. Optional.
|
---|
1901 | */
|
---|
1902 | static int rtFsIsoMakerCmdStatAndAddFile(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSrc, PCRTFSISOMKCMDPARSEDNAMES pParsed,
|
---|
1903 | uint32_t *pidxObj)
|
---|
1904 | {
|
---|
1905 | int rc;
|
---|
1906 | RTFSOBJINFO ObjInfo;
|
---|
1907 | if ( pOpts->hSrcVfs == NIL_RTVFS
|
---|
1908 | || RTVfsChainIsSpec(pszSrc))
|
---|
1909 | {
|
---|
1910 | uint32_t offError;
|
---|
1911 | RTERRINFOSTATIC ErrInfo;
|
---|
1912 | rc = RTVfsChainQueryInfo(pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX,
|
---|
1913 | RTPATH_F_FOLLOW_LINK, &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
1914 | if (RT_FAILURE(rc))
|
---|
1915 | return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainQueryInfo", pszSrc, rc, offError, &ErrInfo.Core);
|
---|
1916 | }
|
---|
1917 | else
|
---|
1918 | {
|
---|
1919 | rc = RTVfsQueryPathInfo(pOpts->hSrcVfs, pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX, RTPATH_F_FOLLOW_LINK);
|
---|
1920 | if (RT_FAILURE(rc))
|
---|
1921 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTVfsQueryPathInfo failed on %s (inside %s): %Rrc",
|
---|
1922 | pszSrc, pOpts->pszSrcVfs, rc);
|
---|
1923 | }
|
---|
1924 |
|
---|
1925 | if (RTFS_IS_FILE(ObjInfo.Attr.fMode))
|
---|
1926 | return rtFsIsoMakerCmdAddFile(pOpts, pszSrc, pParsed, pidxObj);
|
---|
1927 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_A_FILE, "Not a file: %s", pszSrc);
|
---|
1928 | }
|
---|
1929 |
|
---|
1930 |
|
---|
1931 | /**
|
---|
1932 | * Processes a non-option argument.
|
---|
1933 | *
|
---|
1934 | * @returns IPRT status code.
|
---|
1935 | * @param pOpts The ISO maker command instance.
|
---|
1936 | * @param pszSpec The specification of what to add.
|
---|
1937 | */
|
---|
1938 | static int rtFsIsoMakerCmdAddSomething(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSpec)
|
---|
1939 | {
|
---|
1940 | /*
|
---|
1941 | * Parse the name spec.
|
---|
1942 | */
|
---|
1943 | RTFSISOMKCMDPARSEDNAMES Parsed;
|
---|
1944 | int rc = rtFsIsoMakerCmdParseNameSpec(pOpts, pszSpec, true /*fWithSrc*/, &Parsed);
|
---|
1945 | if (RT_FAILURE(rc))
|
---|
1946 | return rc;
|
---|
1947 |
|
---|
1948 | /*
|
---|
1949 | * Deal with special source filenames used to remove/change stuff.
|
---|
1950 | */
|
---|
1951 | if ( Parsed.enmSrcType == RTFSISOMKCMDPARSEDNAMES::kSrcType_Remove
|
---|
1952 | || Parsed.enmSrcType == RTFSISOMKCMDPARSEDNAMES::kSrcType_MustRemove)
|
---|
1953 | {
|
---|
1954 | const char *pszFirstNm = NULL;
|
---|
1955 | uint32_t cRemoved = 0;
|
---|
1956 | for (uint32_t i = 0; i < pOpts->cNameSpecifiers; i++)
|
---|
1957 | if ( Parsed.aNames[i].cchPath > 0
|
---|
1958 | && (Parsed.aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK))
|
---|
1959 | {
|
---|
1960 | pszFirstNm = Parsed.aNames[i].szPath;
|
---|
1961 | uint32_t idxObj = RTFsIsoMakerGetObjIdxForPath(pOpts->hIsoMaker,
|
---|
1962 | Parsed.aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK,
|
---|
1963 | Parsed.aNames[i].szPath);
|
---|
1964 | if (idxObj != UINT32_MAX)
|
---|
1965 | {
|
---|
1966 | rc = RTFsIsoMakerObjRemove(pOpts->hIsoMaker, idxObj);
|
---|
1967 | if (RT_FAILURE(rc))
|
---|
1968 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to remove '%s': %Rrc", pszSpec, rc);
|
---|
1969 | cRemoved++;
|
---|
1970 | }
|
---|
1971 | }
|
---|
1972 | if ( Parsed.enmSrcType == RTFSISOMKCMDPARSEDNAMES::kSrcType_MustRemove
|
---|
1973 | && cRemoved == 0)
|
---|
1974 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_FOUND, "Failed to locate '%s' for removal", pszSpec);
|
---|
1975 | }
|
---|
1976 | /*
|
---|
1977 | * Add regular source.
|
---|
1978 | */
|
---|
1979 | else
|
---|
1980 | {
|
---|
1981 | const char *pszSrc = Parsed.aNames[Parsed.cNamesWithSrc - 1].szPath;
|
---|
1982 | RTFSOBJINFO ObjInfo;
|
---|
1983 | if ( pOpts->hSrcVfs == NIL_RTVFS
|
---|
1984 | || RTVfsChainIsSpec(pszSrc))
|
---|
1985 | {
|
---|
1986 | uint32_t offError;
|
---|
1987 | RTERRINFOSTATIC ErrInfo;
|
---|
1988 | rc = RTVfsChainQueryInfo(pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX,
|
---|
1989 | RTPATH_F_FOLLOW_LINK, &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
1990 | if (RT_FAILURE(rc))
|
---|
1991 | return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainQueryInfo", pszSrc, rc, offError, &ErrInfo.Core);
|
---|
1992 | }
|
---|
1993 | else
|
---|
1994 | {
|
---|
1995 | rc = RTVfsQueryPathInfo(pOpts->hSrcVfs, pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX, RTPATH_F_FOLLOW_LINK);
|
---|
1996 | if (RT_FAILURE(rc))
|
---|
1997 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTVfsQueryPathInfo failed on %s (in %s): %Rrc",
|
---|
1998 | pszSrc, pOpts->pszSrcVfs, rc);
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 | if (RTFS_IS_FILE(ObjInfo.Attr.fMode))
|
---|
2002 | return rtFsIsoMakerCmdAddFile(pOpts, pszSrc, &Parsed, NULL /*pidxObj*/);
|
---|
2003 |
|
---|
2004 | if (RTFS_IS_DIRECTORY(ObjInfo.Attr.fMode))
|
---|
2005 | {
|
---|
2006 | if ( pOpts->hSrcVfs == NIL_RTVFS
|
---|
2007 | || RTVfsChainIsSpec(pszSrc))
|
---|
2008 | return rtFsIsoMakerCmdAddDir(pOpts, pszSrc, &Parsed);
|
---|
2009 | return rtFsIsoMakerCmdAddVfsDir(pOpts, &Parsed, &ObjInfo);
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | if (RTFS_IS_SYMLINK(ObjInfo.Attr.fMode))
|
---|
2013 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED, "Adding symlink '%s' failed: not yet implemented", pszSpec);
|
---|
2014 |
|
---|
2015 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED, "Adding special file '%s' failed: not implemented", pszSpec);
|
---|
2016 | }
|
---|
2017 |
|
---|
2018 | return VINF_SUCCESS;
|
---|
2019 | }
|
---|
2020 |
|
---|
2021 |
|
---|
2022 | /**
|
---|
2023 | * Opens an ISO and use it for subsequent file system accesses.
|
---|
2024 | *
|
---|
2025 | * This is handy for duplicating a part of an ISO in the new image.
|
---|
2026 | *
|
---|
2027 | * @returns IPRT status code.
|
---|
2028 | * @param pOpts The ISO maker command instance.
|
---|
2029 | * @param pszIsoSpec The ISO path specifier.
|
---|
2030 | * @param pszOption The option we're being called on.
|
---|
2031 | * @param fFlags RTFSISO9660_F_XXX
|
---|
2032 | */
|
---|
2033 | static int rtFsIsoMakerCmdOptPushIso(PRTFSISOMAKERCMDOPTS pOpts, const char *pszIsoSpec, const char *pszOption, uint32_t fFlags)
|
---|
2034 | {
|
---|
2035 | if (pOpts->hSrcVfs != NIL_RTVFS)
|
---|
2036 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_IMPLEMENTED,
|
---|
2037 | "Nested %s usage is not supported (previous: %s %s)",
|
---|
2038 | pszOption, pOpts->pszSrcVfsOption, pOpts->pszSrcVfs);
|
---|
2039 |
|
---|
2040 | /*
|
---|
2041 | * Try open the file.
|
---|
2042 | */
|
---|
2043 | RTVFSFILE hVfsFileIso;
|
---|
2044 | uint32_t offError;
|
---|
2045 | RTERRINFOSTATIC ErrInfo;
|
---|
2046 | int rc = RTVfsChainOpenFile(pszIsoSpec, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE,
|
---|
2047 | &hVfsFileIso, &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
2048 | if (RT_SUCCESS(rc))
|
---|
2049 | {
|
---|
2050 | RTVFS hSrcVfs;
|
---|
2051 | rc = RTFsIso9660VolOpen(hVfsFileIso, fFlags, &hSrcVfs, RTErrInfoInitStatic(&ErrInfo));
|
---|
2052 | RTVfsFileRelease(hVfsFileIso);
|
---|
2053 | if (RT_SUCCESS(rc))
|
---|
2054 | {
|
---|
2055 | pOpts->hSrcVfs = hSrcVfs;
|
---|
2056 | pOpts->pszSrcVfs = pszIsoSpec;
|
---|
2057 | pOpts->pszSrcVfsOption = pszOption;
|
---|
2058 | return VINF_SUCCESS;
|
---|
2059 | }
|
---|
2060 |
|
---|
2061 | if (RTErrInfoIsSet(&ErrInfo.Core))
|
---|
2062 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to open '%s' as ISO FS: %Rrc - %s",
|
---|
2063 | pszIsoSpec, rc, ErrInfo.Core.pszMsg);
|
---|
2064 | else
|
---|
2065 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to open '%s' as ISO FS: %Rrc", pszIsoSpec, rc);
|
---|
2066 | }
|
---|
2067 | else
|
---|
2068 | rc = rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainOpenFile", pszIsoSpec, rc, offError, &ErrInfo.Core);
|
---|
2069 | return rc;
|
---|
2070 | }
|
---|
2071 |
|
---|
2072 |
|
---|
2073 | /**
|
---|
2074 | * Counter part to --push-iso and friends.
|
---|
2075 | *
|
---|
2076 | * @returns IPRT status code.
|
---|
2077 | * @param pOpts The ISO maker command instance.
|
---|
2078 | */
|
---|
2079 | static int rtFsIsoMakerCmdOptPop(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2080 | {
|
---|
2081 | if (pOpts->hSrcVfs != NIL_RTVFS)
|
---|
2082 | {
|
---|
2083 | RTVfsRelease(pOpts->hSrcVfs);
|
---|
2084 | pOpts->hSrcVfs = NIL_RTVFS;
|
---|
2085 | pOpts->pszSrcVfs = NULL;
|
---|
2086 | pOpts->pszSrcVfsOption = NULL;
|
---|
2087 | return VINF_SUCCESS;
|
---|
2088 | }
|
---|
2089 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_NOT_FOUND, "--pop without --push-xxx");
|
---|
2090 | }
|
---|
2091 |
|
---|
2092 |
|
---|
2093 | /**
|
---|
2094 | * Deals with the --import-iso {iso-file-spec} options.
|
---|
2095 | *
|
---|
2096 | * @returns IPRT status code
|
---|
2097 | * @param pOpts The ISO maker command instance.
|
---|
2098 | * @param pszIsoSpec The ISO path specifier.
|
---|
2099 | */
|
---|
2100 | static int rtFsIsoMakerCmdOptImportIso(PRTFSISOMAKERCMDOPTS pOpts, const char *pszIsoSpec)
|
---|
2101 | {
|
---|
2102 | RTFSISOMAKERIMPORTRESULTS Results;
|
---|
2103 | RTERRINFOSTATIC ErrInfo;
|
---|
2104 | int rc = RTFsIsoMakerImport(pOpts->hIsoMaker, pszIsoSpec, 0 /*fFlags*/, &Results, RTErrInfoInitStatic(&ErrInfo));
|
---|
2105 |
|
---|
2106 | pOpts->cItemsAdded += Results.cAddedFiles;
|
---|
2107 | pOpts->cItemsAdded += Results.cAddedSymlinks;
|
---|
2108 | pOpts->cItemsAdded += Results.cAddedDirs;
|
---|
2109 | pOpts->cItemsAdded += Results.cBootCatEntries != UINT32_MAX ? Results.cBootCatEntries : 0;
|
---|
2110 | pOpts->cItemsAdded += Results.cbSysArea != 0 ? 1 : 0;
|
---|
2111 |
|
---|
2112 | rtFsIsoMakerPrintf(pOpts, "ISO imported statistics for '%s'\n", pszIsoSpec);
|
---|
2113 | rtFsIsoMakerPrintf(pOpts, " cAddedNames: %'14RU32\n", Results.cAddedNames);
|
---|
2114 | rtFsIsoMakerPrintf(pOpts, " cAddedDirs: %'14RU32\n", Results.cAddedDirs);
|
---|
2115 | rtFsIsoMakerPrintf(pOpts, " cbAddedDataBlocks: %'14RU64 bytes\n", Results.cbAddedDataBlocks);
|
---|
2116 | rtFsIsoMakerPrintf(pOpts, " cAddedFiles: %'14RU32\n", Results.cAddedFiles);
|
---|
2117 | rtFsIsoMakerPrintf(pOpts, " cAddedSymlinks: %'14RU32\n", Results.cAddedSymlinks);
|
---|
2118 | if (Results.cBootCatEntries == UINT32_MAX)
|
---|
2119 | rtFsIsoMakerPrintf(pOpts, " cBootCatEntries: none\n");
|
---|
2120 | else
|
---|
2121 | rtFsIsoMakerPrintf(pOpts, " cBootCatEntries: %'14RU32\n", Results.cBootCatEntries);
|
---|
2122 | rtFsIsoMakerPrintf(pOpts, " cbSysArea: %'14RU32\n", Results.cbSysArea);
|
---|
2123 | rtFsIsoMakerPrintf(pOpts, " cErrors: %'14RU32\n", Results.cErrors);
|
---|
2124 |
|
---|
2125 | if (RT_SUCCESS(rc))
|
---|
2126 | return rc;
|
---|
2127 | if (Results.offError != UINT32_MAX)
|
---|
2128 | return rtFsIsoMakerCmdChainError(pOpts, "RTFsIsoMakerImport", pszIsoSpec, rc, Results.offError, &ErrInfo.Core);
|
---|
2129 | if (RTErrInfoIsSet(&ErrInfo.Core))
|
---|
2130 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerImport failed: %Rrc - %s", rc, ErrInfo.Core.pszMsg);
|
---|
2131 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerImport failed: %Rrc", rc);
|
---|
2132 | }
|
---|
2133 |
|
---|
2134 |
|
---|
2135 | /**
|
---|
2136 | * Deals with: --iso-level, -l
|
---|
2137 | *
|
---|
2138 | * @returns IPRT status code
|
---|
2139 | * @param pOpts The ISO maker command instance.
|
---|
2140 | * @param uLevel The new ISO level.
|
---|
2141 | */
|
---|
2142 | static int rtFsIsoMakerCmdOptSetIsoLevel(PRTFSISOMAKERCMDOPTS pOpts, uint8_t uLevel)
|
---|
2143 | {
|
---|
2144 | int rc = RTFsIsoMakerSetIso9660Level(pOpts->hIsoMaker, uLevel);
|
---|
2145 | if (RT_SUCCESS(rc))
|
---|
2146 | return rc;
|
---|
2147 | if (rc == VERR_WRONG_ORDER)
|
---|
2148 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Cannot change ISO level to %d after having added files!", uLevel);
|
---|
2149 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set ISO level to %d: %Rrc", uLevel, rc);
|
---|
2150 | }
|
---|
2151 |
|
---|
2152 |
|
---|
2153 | /**
|
---|
2154 | * Deals with: --rock-ridge, --limited-rock-ridge, --no-rock-ridge
|
---|
2155 | *
|
---|
2156 | * @returns IPRT status code
|
---|
2157 | * @param pOpts The ISO maker command instance.
|
---|
2158 | * @param uLevel The new rock ridge level.
|
---|
2159 | */
|
---|
2160 | static int rtFsIsoMakerCmdOptSetPrimaryRockLevel(PRTFSISOMAKERCMDOPTS pOpts, uint8_t uLevel)
|
---|
2161 | {
|
---|
2162 | int rc = RTFsIsoMakerSetRockRidgeLevel(pOpts->hIsoMaker, uLevel);
|
---|
2163 | if (RT_SUCCESS(rc))
|
---|
2164 | return rc;
|
---|
2165 | if (rc == VERR_WRONG_ORDER)
|
---|
2166 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Cannot change rock ridge level to %d after having added files!", uLevel);
|
---|
2167 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set rock ridge level to %d: %Rrc", uLevel, rc);
|
---|
2168 | }
|
---|
2169 |
|
---|
2170 |
|
---|
2171 | /**
|
---|
2172 | * Deals with: --joliet, --no-joliet, --joliet-ucs-level, --ucs-level
|
---|
2173 | *
|
---|
2174 | * @returns IPRT status code
|
---|
2175 | * @param pOpts The ISO maker command instance.
|
---|
2176 | * @param uLevel The new rock ridge level.
|
---|
2177 | */
|
---|
2178 | static int rtFsIsoMakerCmdOptSetJolietUcs2Level(PRTFSISOMAKERCMDOPTS pOpts, uint8_t uLevel)
|
---|
2179 | {
|
---|
2180 | int rc = RTFsIsoMakerSetJolietUcs2Level(pOpts->hIsoMaker, uLevel);
|
---|
2181 | if (RT_SUCCESS(rc))
|
---|
2182 | return rc;
|
---|
2183 | if (rc == VERR_WRONG_ORDER)
|
---|
2184 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Cannot change joliet UCS level to %d after having added files!", uLevel);
|
---|
2185 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set joliet UCS level to %d: %Rrc", uLevel, rc);
|
---|
2186 | }
|
---|
2187 |
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * Deals with: --rational-attribs, --strict-attribs, -R, -r
|
---|
2191 | *
|
---|
2192 | * @returns IPRT status code
|
---|
2193 | * @param pOpts The ISO maker command instance.
|
---|
2194 | * @param uLevel The new rock ridge level.
|
---|
2195 | */
|
---|
2196 | static int rtFsIsoMakerCmdOptSetAttribInheritStyle(PRTFSISOMAKERCMDOPTS pOpts, bool fStrict)
|
---|
2197 | {
|
---|
2198 | int rc = RTFsIsoMakerSetAttribInheritStyle(pOpts->hIsoMaker, fStrict);
|
---|
2199 | if (RT_SUCCESS(rc))
|
---|
2200 | return rc;
|
---|
2201 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to change attributes handling style to %s: %Rrc",
|
---|
2202 | fStrict ? "strict" : "rational", rc);
|
---|
2203 | }
|
---|
2204 |
|
---|
2205 |
|
---|
2206 | /**
|
---|
2207 | * Deals with: -G|--generic-boot {file}
|
---|
2208 | *
|
---|
2209 | * This concers content the first 16 sectors of the image. We start loading the
|
---|
2210 | * file at byte 0 in the image and stops at 32KB.
|
---|
2211 | *
|
---|
2212 | * @returns IPRT status code
|
---|
2213 | * @param pOpts The ISO maker command instance.
|
---|
2214 | * @param pszGenericBootImage The generic boot image source.
|
---|
2215 | */
|
---|
2216 | static int rtFsIsoMakerCmdOptGenericBoot(PRTFSISOMAKERCMDOPTS pOpts, const char *pszGenericBootImage)
|
---|
2217 | {
|
---|
2218 | RTERRINFOSTATIC ErrInfo;
|
---|
2219 | uint32_t offError;
|
---|
2220 | RTVFSFILE hVfsFile;
|
---|
2221 | int rc = RTVfsChainOpenFile(pszGenericBootImage, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFile,
|
---|
2222 | &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
2223 | if (RT_FAILURE(rc))
|
---|
2224 | return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainOpenFile", pszGenericBootImage, rc, offError, &ErrInfo.Core);
|
---|
2225 |
|
---|
2226 | uint8_t abBuf[_32K];
|
---|
2227 | size_t cbRead;
|
---|
2228 | rc = RTVfsFileReadAt(hVfsFile, 0, abBuf, sizeof(abBuf), &cbRead);
|
---|
2229 | RTVfsFileRelease(hVfsFile);
|
---|
2230 | if (RT_FAILURE(rc))
|
---|
2231 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error reading 32KB from generic boot image '%s': %Rrc", pszGenericBootImage, rc);
|
---|
2232 |
|
---|
2233 | rc = RTFsIsoMakerSetSysAreaContent(pOpts->hIsoMaker, abBuf, cbRead, 0);
|
---|
2234 | if (RT_FAILURE(rc))
|
---|
2235 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerSetSysAreaContent failed with a %zu bytes input: %Rrc", cbRead, rc);
|
---|
2236 |
|
---|
2237 | return VINF_SUCCESS;
|
---|
2238 | }
|
---|
2239 |
|
---|
2240 |
|
---|
2241 | /**
|
---|
2242 | * Helper that makes sure we've got a validation boot entry.
|
---|
2243 | *
|
---|
2244 | * @returns IPRT status code
|
---|
2245 | * @param pOpts The ISO maker command instance.
|
---|
2246 | */
|
---|
2247 | static void rtFsIsoMakerCmdOptEltoritoEnsureValidationEntry(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2248 | {
|
---|
2249 | if (pOpts->cBootCatEntries == 0)
|
---|
2250 | {
|
---|
2251 | pOpts->aBootCatEntries[0].enmType = RTFSISOMKCMDELTORITOENTRY::kEntryType_Validation;
|
---|
2252 | pOpts->aBootCatEntries[0].u.Validation.idPlatform = ISO9660_ELTORITO_PLATFORM_ID_X86;
|
---|
2253 | pOpts->aBootCatEntries[0].u.Validation.pszString = NULL;
|
---|
2254 | pOpts->cBootCatEntries = 1;
|
---|
2255 | }
|
---|
2256 | }
|
---|
2257 |
|
---|
2258 |
|
---|
2259 | /**
|
---|
2260 | * Helper that makes sure we've got a current boot entry.
|
---|
2261 | *
|
---|
2262 | * @returns IPRT status code
|
---|
2263 | * @param pOpts The ISO maker command instance.
|
---|
2264 | * @param fForceNew Whether to force a new entry.
|
---|
2265 | * @param pidxBootCat Where to return the boot catalog index.
|
---|
2266 | */
|
---|
2267 | static int rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(PRTFSISOMAKERCMDOPTS pOpts, bool fForceNew, uint32_t *pidxBootCat)
|
---|
2268 | {
|
---|
2269 | rtFsIsoMakerCmdOptEltoritoEnsureValidationEntry(pOpts);
|
---|
2270 |
|
---|
2271 | uint32_t i = pOpts->cBootCatEntries;
|
---|
2272 | if (i == 2 && fForceNew)
|
---|
2273 | {
|
---|
2274 | pOpts->aBootCatEntries[i].enmType = RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader;
|
---|
2275 | pOpts->aBootCatEntries[i].u.SectionHeader.idPlatform = pOpts->aBootCatEntries[0].u.Validation.idPlatform;
|
---|
2276 | pOpts->aBootCatEntries[i].u.SectionHeader.pszString = NULL;
|
---|
2277 | pOpts->cBootCatEntries = ++i;
|
---|
2278 | }
|
---|
2279 |
|
---|
2280 | if ( i == 1
|
---|
2281 | || fForceNew
|
---|
2282 | || pOpts->aBootCatEntries[i - 1].enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader)
|
---|
2283 | {
|
---|
2284 | if (i >= RT_ELEMENTS(pOpts->aBootCatEntries))
|
---|
2285 | {
|
---|
2286 | *pidxBootCat = UINT32_MAX;
|
---|
2287 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_BUFFER_OVERFLOW, "Too many boot catalog entries");
|
---|
2288 | }
|
---|
2289 |
|
---|
2290 | pOpts->aBootCatEntries[i].enmType = i == 1 ? RTFSISOMKCMDELTORITOENTRY::kEntryType_Default
|
---|
2291 | : RTFSISOMKCMDELTORITOENTRY::kEntryType_Section;
|
---|
2292 | pOpts->aBootCatEntries[i].u.Section.pszImageNameInIso = NULL;
|
---|
2293 | pOpts->aBootCatEntries[i].u.Section.idxImageObj = UINT32_MAX;
|
---|
2294 | pOpts->aBootCatEntries[i].u.Section.fInsertBootInfoTable = false;
|
---|
2295 | pOpts->aBootCatEntries[i].u.Section.fBootable = true;
|
---|
2296 | pOpts->aBootCatEntries[i].u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_MASK;
|
---|
2297 | pOpts->aBootCatEntries[i].u.Section.bSystemType = 1 /*FAT12*/;
|
---|
2298 | pOpts->aBootCatEntries[i].u.Section.uLoadSeg = 0x7c0;
|
---|
2299 | pOpts->aBootCatEntries[i].u.Section.cSectorsToLoad = 4;
|
---|
2300 | pOpts->cBootCatEntries = ++i;
|
---|
2301 | }
|
---|
2302 |
|
---|
2303 | *pidxBootCat = i - 1;
|
---|
2304 | return VINF_SUCCESS;
|
---|
2305 | }
|
---|
2306 |
|
---|
2307 |
|
---|
2308 | /**
|
---|
2309 | * Deals with: --boot-catalog <path-spec>
|
---|
2310 | *
|
---|
2311 | * This enters the boot catalog into the namespaces of the image. The path-spec
|
---|
2312 | * is similar to what rtFsIsoMakerCmdAddSomething processes, only there isn't a
|
---|
2313 | * source file part.
|
---|
2314 | *
|
---|
2315 | * @returns IPRT status code
|
---|
2316 | * @param pOpts The ISO maker command instance.
|
---|
2317 | * @param pszGenericBootImage The generic boot image source.
|
---|
2318 | */
|
---|
2319 | static int rtFsIsoMakerCmdOptEltoritoSetBootCatalogPath(PRTFSISOMAKERCMDOPTS pOpts, const char *pszBootCat)
|
---|
2320 | {
|
---|
2321 | /* Make sure we'll fail later if no other boot options are present. */
|
---|
2322 | rtFsIsoMakerCmdOptEltoritoEnsureValidationEntry(pOpts);
|
---|
2323 |
|
---|
2324 | /* Parse the name spec. */
|
---|
2325 | RTFSISOMKCMDPARSEDNAMES Parsed;
|
---|
2326 | int rc = rtFsIsoMakerCmdParseNameSpec(pOpts, pszBootCat, false /*fWithSrc*/, &Parsed);
|
---|
2327 | if (RT_SUCCESS(rc))
|
---|
2328 | {
|
---|
2329 | /* Query/create the boot catalog and enter it into the name spaces. */
|
---|
2330 | uint32_t idxBootCatObj;
|
---|
2331 | rc = RTFsIsoMakerQueryObjIdxForBootCatalog(pOpts->hIsoMaker, &idxBootCatObj);
|
---|
2332 | if (RT_SUCCESS(rc))
|
---|
2333 | rc = rtFsIsoMakerCmdSetObjPaths(pOpts, idxBootCatObj, &Parsed, "boot catalog");
|
---|
2334 | else
|
---|
2335 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerQueryBootCatalogPathObjIdx failed: %Rrc", rc);
|
---|
2336 | }
|
---|
2337 | return rc;
|
---|
2338 | }
|
---|
2339 |
|
---|
2340 |
|
---|
2341 | /**
|
---|
2342 | * Deals with: --eltorito-add-image {file-spec}
|
---|
2343 | *
|
---|
2344 | * This differs from -b|--eltorito-boot in that it takes a source file
|
---|
2345 | * specification identical to what rtFsIsoMakerCmdAddSomething processes instead
|
---|
2346 | * of a reference to a file in the image.
|
---|
2347 | *
|
---|
2348 | * This operates on the current eltorito boot catalog entry.
|
---|
2349 | *
|
---|
2350 | * @returns IPRT status code
|
---|
2351 | * @param pOpts The ISO maker command instance.
|
---|
2352 | * @param pszGenericBootImage The generic boot image source.
|
---|
2353 | */
|
---|
2354 | static int rtFsIsoMakerCmdOptEltoritoAddImage(PRTFSISOMAKERCMDOPTS pOpts, const char *pszBootImageSpec)
|
---|
2355 | {
|
---|
2356 | /* Parse the name spec. */
|
---|
2357 | RTFSISOMKCMDPARSEDNAMES Parsed;
|
---|
2358 | int rc = rtFsIsoMakerCmdParseNameSpec(pOpts, pszBootImageSpec, true /*fWithSrc*/, &Parsed);
|
---|
2359 | if (RT_SUCCESS(rc))
|
---|
2360 | {
|
---|
2361 | uint32_t idxBootCat;
|
---|
2362 | rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2363 | if (RT_SUCCESS(rc))
|
---|
2364 | {
|
---|
2365 | if ( pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj != UINT32_MAX
|
---|
2366 | || pOpts->aBootCatEntries[idxBootCat].u.Section.pszImageNameInIso != NULL)
|
---|
2367 | rc = rtFsIsoMakerCmdSyntaxError(pOpts, "boot image already given for current El Torito entry (%#u)", idxBootCat);
|
---|
2368 | else
|
---|
2369 | {
|
---|
2370 | uint32_t idxImageObj;
|
---|
2371 | rc = rtFsIsoMakerCmdStatAndAddFile(pOpts, Parsed.aNames[Parsed.cNamesWithSrc - 1].szPath, &Parsed, &idxImageObj);
|
---|
2372 | if (RT_SUCCESS(rc))
|
---|
2373 | pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj = idxImageObj;
|
---|
2374 | }
|
---|
2375 | }
|
---|
2376 | }
|
---|
2377 |
|
---|
2378 | return rc;
|
---|
2379 | }
|
---|
2380 |
|
---|
2381 |
|
---|
2382 | /**
|
---|
2383 | * Deals with: -b|--eltorito-boot {file-in-iso}
|
---|
2384 | *
|
---|
2385 | * This operates on the current eltorito boot catalog entry.
|
---|
2386 | *
|
---|
2387 | * @returns IPRT status code
|
---|
2388 | * @param pOpts The ISO maker command instance.
|
---|
2389 | * @param pszGenericBootImage The generic boot image source.
|
---|
2390 | */
|
---|
2391 | static int rtFsIsoMakerCmdOptEltoritoBoot(PRTFSISOMAKERCMDOPTS pOpts, const char *pszBootImage)
|
---|
2392 | {
|
---|
2393 | uint32_t idxBootCat;
|
---|
2394 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2395 | if (RT_SUCCESS(rc))
|
---|
2396 | {
|
---|
2397 | if ( pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj != UINT32_MAX
|
---|
2398 | || pOpts->aBootCatEntries[idxBootCat].u.Section.pszImageNameInIso != NULL)
|
---|
2399 | return rtFsIsoMakerCmdSyntaxError(pOpts, "boot image already given for current El Torito entry (%#u)", idxBootCat);
|
---|
2400 |
|
---|
2401 | uint32_t idxImageObj = RTFsIsoMakerGetObjIdxForPath(pOpts->hIsoMaker, RTFSISOMAKER_NAMESPACE_ALL, pszBootImage);
|
---|
2402 | if (idxImageObj == UINT32_MAX)
|
---|
2403 | pOpts->aBootCatEntries[idxBootCat].u.Section.pszImageNameInIso = pszBootImage;
|
---|
2404 | pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj = idxImageObj;
|
---|
2405 | }
|
---|
2406 | return rc;
|
---|
2407 | }
|
---|
2408 |
|
---|
2409 |
|
---|
2410 | /**
|
---|
2411 | * Deals with: --eltorito-platform-id {x86|PPC|Mac|efi|number}
|
---|
2412 | *
|
---|
2413 | * Operates on the validation entry or a section header.
|
---|
2414 | *
|
---|
2415 | * @returns IPRT status code
|
---|
2416 | * @param pOpts The ISO maker command instance.
|
---|
2417 | * @param pszPlatformId The platform ID.
|
---|
2418 | */
|
---|
2419 | static int rtFsIsoMakerCmdOptEltoritoPlatformId(PRTFSISOMAKERCMDOPTS pOpts, const char *pszPlatformId)
|
---|
2420 | {
|
---|
2421 | /* Decode it. */
|
---|
2422 | uint8_t idPlatform;
|
---|
2423 | if (strcmp(pszPlatformId, "x86") == 0)
|
---|
2424 | idPlatform = ISO9660_ELTORITO_PLATFORM_ID_X86;
|
---|
2425 | else if (strcmp(pszPlatformId, "PPC") == 0)
|
---|
2426 | idPlatform = ISO9660_ELTORITO_PLATFORM_ID_PPC;
|
---|
2427 | else if (strcmp(pszPlatformId, "Mac") == 0)
|
---|
2428 | idPlatform = ISO9660_ELTORITO_PLATFORM_ID_MAC;
|
---|
2429 | else if (strcmp(pszPlatformId, "efi") == 0)
|
---|
2430 | idPlatform = ISO9660_ELTORITO_PLATFORM_ID_EFI;
|
---|
2431 | else
|
---|
2432 | {
|
---|
2433 | int rc = RTStrToUInt8Full(pszPlatformId, 0, &idPlatform);
|
---|
2434 | if (rc != VINF_SUCCESS)
|
---|
2435 | return rtFsIsoMakerCmdSyntaxError(pOpts, "invalid or unknown platform ID: %s", pszPlatformId);
|
---|
2436 | }
|
---|
2437 |
|
---|
2438 | /* If this option comes before anything related to the default entry, work
|
---|
2439 | on the validation entry. */
|
---|
2440 | if (pOpts->cBootCatEntries <= 1)
|
---|
2441 | {
|
---|
2442 | rtFsIsoMakerCmdOptEltoritoEnsureValidationEntry(pOpts);
|
---|
2443 | pOpts->aBootCatEntries[0].u.Validation.idPlatform = idPlatform;
|
---|
2444 | }
|
---|
2445 | /* Otherwise, work on the current section header, creating a new one if necessary. */
|
---|
2446 | else
|
---|
2447 | {
|
---|
2448 | uint32_t idxBootCat = pOpts->cBootCatEntries - 1;
|
---|
2449 | if (pOpts->aBootCatEntries[idxBootCat].enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader)
|
---|
2450 | pOpts->aBootCatEntries[idxBootCat].u.SectionHeader.idPlatform = idPlatform;
|
---|
2451 | else
|
---|
2452 | {
|
---|
2453 | idxBootCat++;
|
---|
2454 | if (idxBootCat + 2 > RT_ELEMENTS(pOpts->aBootCatEntries))
|
---|
2455 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_BUFFER_OVERFLOW, "Too many boot catalog entries");
|
---|
2456 |
|
---|
2457 | pOpts->aBootCatEntries[idxBootCat].enmType = RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader;
|
---|
2458 | pOpts->aBootCatEntries[idxBootCat].u.SectionHeader.idPlatform = idPlatform;
|
---|
2459 | pOpts->aBootCatEntries[idxBootCat].u.SectionHeader.pszString = NULL;
|
---|
2460 | pOpts->cBootCatEntries = idxBootCat + 1;
|
---|
2461 | }
|
---|
2462 | }
|
---|
2463 | return VINF_SUCCESS;
|
---|
2464 | }
|
---|
2465 |
|
---|
2466 |
|
---|
2467 | /**
|
---|
2468 | * Deals with: -no-boot
|
---|
2469 | *
|
---|
2470 | * This operates on the current eltorito boot catalog entry.
|
---|
2471 | *
|
---|
2472 | * @returns IPRT status code
|
---|
2473 | * @param pOpts The ISO maker command instance.
|
---|
2474 | */
|
---|
2475 | static int rtFsIsoMakerCmdOptEltoritoSetNotBootable(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2476 | {
|
---|
2477 | uint32_t idxBootCat;
|
---|
2478 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2479 | if (RT_SUCCESS(rc))
|
---|
2480 | pOpts->aBootCatEntries[idxBootCat].u.Section.fBootable = false;
|
---|
2481 | return rc;
|
---|
2482 | }
|
---|
2483 |
|
---|
2484 |
|
---|
2485 | /**
|
---|
2486 | * Deals with: -hard-disk-boot, -no-emulation-boot, --eltorito-floppy-12,
|
---|
2487 | * --eltorito-floppy-144, --eltorito-floppy-288
|
---|
2488 | *
|
---|
2489 | * This operates on the current eltorito boot catalog entry.
|
---|
2490 | *
|
---|
2491 | * @returns IPRT status code
|
---|
2492 | * @param pOpts The ISO maker command instance.
|
---|
2493 | * @param bMediaType The media type.
|
---|
2494 | */
|
---|
2495 | static int rtFsIsoMakerCmdOptEltoritoSetMediaType(PRTFSISOMAKERCMDOPTS pOpts, uint8_t bMediaType)
|
---|
2496 | {
|
---|
2497 | uint32_t idxBootCat;
|
---|
2498 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2499 | if (RT_SUCCESS(rc))
|
---|
2500 | pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType = bMediaType;
|
---|
2501 | return rc;
|
---|
2502 | }
|
---|
2503 |
|
---|
2504 |
|
---|
2505 | /**
|
---|
2506 | * Deals with: -boot-load-seg {seg}
|
---|
2507 | *
|
---|
2508 | * This operates on the current eltorito boot catalog entry.
|
---|
2509 | *
|
---|
2510 | * @returns IPRT status code
|
---|
2511 | * @param pOpts The ISO maker command instance.
|
---|
2512 | * @param uSeg The load segment.
|
---|
2513 | */
|
---|
2514 | static int rtFsIsoMakerCmdOptEltoritoSetLoadSegment(PRTFSISOMAKERCMDOPTS pOpts, uint16_t uSeg)
|
---|
2515 | {
|
---|
2516 | uint32_t idxBootCat;
|
---|
2517 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2518 | if (RT_SUCCESS(rc))
|
---|
2519 | pOpts->aBootCatEntries[idxBootCat].u.Section.uLoadSeg = uSeg;
|
---|
2520 | return rc;
|
---|
2521 | }
|
---|
2522 |
|
---|
2523 |
|
---|
2524 | /**
|
---|
2525 | * Deals with: -boot-load-size {sectors}
|
---|
2526 | *
|
---|
2527 | * This operates on the current eltorito boot catalog entry.
|
---|
2528 | *
|
---|
2529 | * @returns IPRT status code
|
---|
2530 | * @param pOpts The ISO maker command instance.
|
---|
2531 | * @param cSectors Number of emulated sectors to load
|
---|
2532 | */
|
---|
2533 | static int rtFsIsoMakerCmdOptEltoritoSetLoadSectorCount(PRTFSISOMAKERCMDOPTS pOpts, uint16_t cSectors)
|
---|
2534 | {
|
---|
2535 | uint32_t idxBootCat;
|
---|
2536 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2537 | if (RT_SUCCESS(rc))
|
---|
2538 | pOpts->aBootCatEntries[idxBootCat].u.Section.cSectorsToLoad = cSectors;
|
---|
2539 | return rc;
|
---|
2540 | }
|
---|
2541 |
|
---|
2542 |
|
---|
2543 | /**
|
---|
2544 | * Deals with: -boot-info-table
|
---|
2545 | *
|
---|
2546 | * This operates on the current eltorito boot catalog entry.
|
---|
2547 | *
|
---|
2548 | * @returns IPRT status code
|
---|
2549 | * @param pOpts The ISO maker command instance.
|
---|
2550 | */
|
---|
2551 | static int rtFsIsoMakerCmdOptEltoritoEnableBootInfoTablePatching(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2552 | {
|
---|
2553 | uint32_t idxBootCat;
|
---|
2554 | int rc = rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, false /*fForceNew*/, &idxBootCat);
|
---|
2555 | if (RT_SUCCESS(rc))
|
---|
2556 | pOpts->aBootCatEntries[idxBootCat].u.Section.fInsertBootInfoTable = true;
|
---|
2557 | return rc;
|
---|
2558 | }
|
---|
2559 |
|
---|
2560 |
|
---|
2561 | /**
|
---|
2562 | * Validates and commits the boot catalog stuff.
|
---|
2563 | *
|
---|
2564 | * ASSUMING this is called after all options are parsed and there is only this
|
---|
2565 | * one call.
|
---|
2566 | *
|
---|
2567 | * @returns IPRT status code
|
---|
2568 | * @param pOpts The ISO maker command instance.
|
---|
2569 | */
|
---|
2570 | static int rtFsIsoMakerCmdOptEltoritoCommitBootCatalog(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2571 | {
|
---|
2572 | if (pOpts->cBootCatEntries == 0)
|
---|
2573 | return VINF_SUCCESS;
|
---|
2574 |
|
---|
2575 | /*
|
---|
2576 | * Locate and configure the boot images first.
|
---|
2577 | */
|
---|
2578 | int rc;
|
---|
2579 | PRTFSISOMKCMDELTORITOENTRY pBootCatEntry = &pOpts->aBootCatEntries[1];
|
---|
2580 | for (uint32_t idxBootCat = 1; idxBootCat < pOpts->cBootCatEntries; idxBootCat++, pBootCatEntry++)
|
---|
2581 | if ( pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Default
|
---|
2582 | || pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Section)
|
---|
2583 | {
|
---|
2584 | /* Make sure we've got a boot image. */
|
---|
2585 | uint32_t idxImageObj = pBootCatEntry->u.Section.idxImageObj;
|
---|
2586 | if (idxImageObj == UINT32_MAX)
|
---|
2587 | {
|
---|
2588 | const char *pszBootImage = pBootCatEntry->u.Section.pszImageNameInIso;
|
---|
2589 | if (pszBootImage == NULL)
|
---|
2590 | return rtFsIsoMakerCmdSyntaxError(pOpts, "No image name given for boot catalog entry #%u", idxBootCat);
|
---|
2591 |
|
---|
2592 | idxImageObj = RTFsIsoMakerGetObjIdxForPath(pOpts->hIsoMaker, RTFSISOMAKER_NAMESPACE_ALL, pszBootImage);
|
---|
2593 | if (idxImageObj == UINT32_MAX)
|
---|
2594 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Unable to locate image for boot catalog entry #%u: %s",
|
---|
2595 | idxBootCat, pszBootImage);
|
---|
2596 | pBootCatEntry->u.Section.idxImageObj = idxImageObj;
|
---|
2597 | }
|
---|
2598 |
|
---|
2599 | /* Enable patching it? */
|
---|
2600 | if (pBootCatEntry->u.Section.fInsertBootInfoTable)
|
---|
2601 | {
|
---|
2602 | rc = RTFsIsoMakerObjEnableBootInfoTablePatching(pOpts->hIsoMaker, idxImageObj, true);
|
---|
2603 | if (RT_FAILURE(rc))
|
---|
2604 | return rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
2605 | "RTFsIsoMakerObjEnableBootInfoTablePatching failed on entry #%u: %Rrc",
|
---|
2606 | idxBootCat, rc);
|
---|
2607 | }
|
---|
2608 |
|
---|
2609 | /* Figure out the floppy type given the object size. */
|
---|
2610 | if (pBootCatEntry->u.Section.bBootMediaType == ISO9660_ELTORITO_BOOT_MEDIA_TYPE_MASK)
|
---|
2611 | {
|
---|
2612 | uint64_t cbImage;
|
---|
2613 | rc = RTFsIsoMakerObjQueryDataSize(pOpts->hIsoMaker, idxImageObj, &cbImage);
|
---|
2614 | if (RT_FAILURE(rc))
|
---|
2615 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerObjGetDataSize failed on entry #%u: %Rrc",
|
---|
2616 | idxBootCat, rc);
|
---|
2617 | if (cbImage == 1228800)
|
---|
2618 | pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_2_MB;
|
---|
2619 | else if (cbImage <= 1474560)
|
---|
2620 | pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_44_MB;
|
---|
2621 | else if (cbImage <= 2949120)
|
---|
2622 | pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_2_88_MB;
|
---|
2623 | else
|
---|
2624 | pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_HARD_DISK;
|
---|
2625 | }
|
---|
2626 | }
|
---|
2627 |
|
---|
2628 | /*
|
---|
2629 | * Add the boot catalog entries.
|
---|
2630 | */
|
---|
2631 | pBootCatEntry = &pOpts->aBootCatEntries[0];
|
---|
2632 | for (uint32_t idxBootCat = 0; idxBootCat < pOpts->cBootCatEntries; idxBootCat++, pBootCatEntry++)
|
---|
2633 | switch (pBootCatEntry->enmType)
|
---|
2634 | {
|
---|
2635 | case RTFSISOMKCMDELTORITOENTRY::kEntryType_Validation:
|
---|
2636 | Assert(idxBootCat == 0);
|
---|
2637 | rc = RTFsIsoMakerBootCatSetValidationEntry(pOpts->hIsoMaker, pBootCatEntry->u.Validation.idPlatform,
|
---|
2638 | pBootCatEntry->u.Validation.pszString);
|
---|
2639 | if (RT_FAILURE(rc))
|
---|
2640 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetValidationEntry failed: %Rrc", rc);
|
---|
2641 | break;
|
---|
2642 |
|
---|
2643 | case RTFSISOMKCMDELTORITOENTRY::kEntryType_Default:
|
---|
2644 | case RTFSISOMKCMDELTORITOENTRY::kEntryType_Section:
|
---|
2645 | Assert(pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Default ? idxBootCat == 1 : idxBootCat > 2);
|
---|
2646 | rc = RTFsIsoMakerBootCatSetSectionEntry(pOpts->hIsoMaker, idxBootCat,
|
---|
2647 | pBootCatEntry->u.Section.idxImageObj,
|
---|
2648 | pBootCatEntry->u.Section.bBootMediaType,
|
---|
2649 | pBootCatEntry->u.Section.bSystemType,
|
---|
2650 | pBootCatEntry->u.Section.fBootable,
|
---|
2651 | pBootCatEntry->u.Section.uLoadSeg,
|
---|
2652 | pBootCatEntry->u.Section.cSectorsToLoad,
|
---|
2653 | ISO9660_ELTORITO_SEL_CRIT_TYPE_NONE, NULL, 0);
|
---|
2654 | if (RT_FAILURE(rc))
|
---|
2655 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetSectionEntry failed on entry #%u: %Rrc",
|
---|
2656 | idxBootCat, rc);
|
---|
2657 | break;
|
---|
2658 |
|
---|
2659 | case RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader:
|
---|
2660 | {
|
---|
2661 | uint32_t cEntries = 1;
|
---|
2662 | while ( idxBootCat + cEntries < pOpts->cBootCatEntries
|
---|
2663 | && pBootCatEntry[cEntries].enmType != RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader)
|
---|
2664 | cEntries++;
|
---|
2665 | cEntries--;
|
---|
2666 |
|
---|
2667 | Assert(idxBootCat > 1);
|
---|
2668 | rc = RTFsIsoMakerBootCatSetSectionHeaderEntry(pOpts->hIsoMaker, idxBootCat, cEntries,
|
---|
2669 | pBootCatEntry->u.SectionHeader.idPlatform,
|
---|
2670 | pBootCatEntry->u.SectionHeader.pszString);
|
---|
2671 | if (RT_FAILURE(rc))
|
---|
2672 | return rtFsIsoMakerCmdErrorRc(pOpts, rc,
|
---|
2673 | "RTFsIsoMakerBootCatSetSectionHeaderEntry failed on entry #%u: %Rrc",
|
---|
2674 | idxBootCat, rc);
|
---|
2675 | break;
|
---|
2676 | }
|
---|
2677 |
|
---|
2678 | default:
|
---|
2679 | AssertFailedReturn(VERR_INTERNAL_ERROR_3);
|
---|
2680 | }
|
---|
2681 |
|
---|
2682 | return VINF_SUCCESS;
|
---|
2683 | }
|
---|
2684 |
|
---|
2685 |
|
---|
2686 | /**
|
---|
2687 | * Deals with: --eltorito-new-entry, --eltorito-alt-boot
|
---|
2688 | *
|
---|
2689 | * This operates on the current eltorito boot catalog entry.
|
---|
2690 | *
|
---|
2691 | * @returns IPRT status code
|
---|
2692 | * @param pOpts The ISO maker command instance.
|
---|
2693 | */
|
---|
2694 | static int rtFsIsoMakerCmdOptEltoritoNewEntry(PRTFSISOMAKERCMDOPTS pOpts)
|
---|
2695 | {
|
---|
2696 | uint32_t idxBootCat;
|
---|
2697 | return rtFsIsoMakerCmdOptEltoritoEnsureSectionEntry(pOpts, true /*fForceNew*/, &idxBootCat);
|
---|
2698 | }
|
---|
2699 |
|
---|
2700 |
|
---|
2701 | /**
|
---|
2702 | * Sets a string property in all namespaces.
|
---|
2703 | *
|
---|
2704 | * @returns IPRT status code.
|
---|
2705 | * @param pOpts The ISO maker command instance.
|
---|
2706 | * @param pszValue The new string value.
|
---|
2707 | * @param enmStringProp The string property.
|
---|
2708 | */
|
---|
2709 | static int rtFsIsoMakerCmdOptSetStringProp(PRTFSISOMAKERCMDOPTS pOpts, const char *pszValue, RTFSISOMAKERSTRINGPROP enmStringProp)
|
---|
2710 | {
|
---|
2711 | int rc = RTFsIsoMakerSetStringProp(pOpts->hIsoMaker, enmStringProp, pOpts->fDstNamespaces, pszValue);
|
---|
2712 | if (RT_FAILURE(rc))
|
---|
2713 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set string property %d to '%s': %Rrc", enmStringProp, pszValue, rc);
|
---|
2714 | return rc;
|
---|
2715 | }
|
---|
2716 |
|
---|
2717 |
|
---|
2718 | /**
|
---|
2719 | * Handles the --dir-mode and --file-mode options.
|
---|
2720 | *
|
---|
2721 | * @returns IPRT status code.
|
---|
2722 | * @param pOpts The ISO maker command instance.
|
---|
2723 | * @param fDir True if applies to dir, false if applies to
|
---|
2724 | * files.
|
---|
2725 | * @param fMode The forced mode.
|
---|
2726 | */
|
---|
2727 | static int rtFsIsoMakerCmdOptSetFileOrDirMode(PRTFSISOMAKERCMDOPTS pOpts, bool fDir, RTFMODE fMode)
|
---|
2728 | {
|
---|
2729 | /* Change the mode masks. */
|
---|
2730 | int rc;
|
---|
2731 | if (fDir)
|
---|
2732 | rc = RTFsIsoMakerSetForcedDirMode(pOpts->hIsoMaker, fMode, true /*fForced*/);
|
---|
2733 | else
|
---|
2734 | rc = RTFsIsoMakerSetForcedFileMode(pOpts->hIsoMaker, fMode, true /*fForced*/);
|
---|
2735 | if (RT_SUCCESS(rc))
|
---|
2736 | {
|
---|
2737 | /* Then enable rock.*/
|
---|
2738 | rc = RTFsIsoMakerSetRockRidgeLevel(pOpts->hIsoMaker, 2);
|
---|
2739 | if (RT_SUCCESS(rc))
|
---|
2740 | return VINF_SUCCESS;
|
---|
2741 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to enable rock ridge: %Rrc", rc);
|
---|
2742 | }
|
---|
2743 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set %s force & default mode mask to %04o: %Rrc",
|
---|
2744 | fMode, fDir ? "directory" : "file", rc);
|
---|
2745 | }
|
---|
2746 |
|
---|
2747 |
|
---|
2748 | /**
|
---|
2749 | * Handles the --no-dir-mode and --no-file-mode options that counters
|
---|
2750 | * --dir-mode and --file-mode.
|
---|
2751 | *
|
---|
2752 | * @returns IPRT status code.
|
---|
2753 | * @param pOpts The ISO maker command instance.
|
---|
2754 | * @param fDir True if applies to dir, false if applies to
|
---|
2755 | * files.
|
---|
2756 | */
|
---|
2757 | static int rtFsIsoMakerCmdOptDisableFileOrDirMode(PRTFSISOMAKERCMDOPTS pOpts, bool fDir)
|
---|
2758 | {
|
---|
2759 | int rc;
|
---|
2760 | if (fDir)
|
---|
2761 | rc = RTFsIsoMakerSetForcedDirMode(pOpts->hIsoMaker, 0, false /*fForced*/);
|
---|
2762 | else
|
---|
2763 | rc = RTFsIsoMakerSetForcedFileMode(pOpts->hIsoMaker, 0, true /*fForced*/);
|
---|
2764 | if (RT_SUCCESS(rc))
|
---|
2765 | return VINF_SUCCESS;
|
---|
2766 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to disable forced %s mode mask: %Rrc", fDir ? "directory" : "file", rc);
|
---|
2767 | }
|
---|
2768 |
|
---|
2769 |
|
---|
2770 |
|
---|
2771 | /**
|
---|
2772 | * Handles the --new-dir-mode option.
|
---|
2773 | *
|
---|
2774 | * @returns IPRT status code.
|
---|
2775 | * @param pOpts The ISO maker command instance.
|
---|
2776 | * @param fMode The forced mode.
|
---|
2777 | */
|
---|
2778 | static int rtFsIsoMakerCmdOptSetNewDirMode(PRTFSISOMAKERCMDOPTS pOpts, RTFMODE fMode)
|
---|
2779 | {
|
---|
2780 | int rc = RTFsIsoMakerSetDefaultDirMode(pOpts->hIsoMaker, fMode);
|
---|
2781 | if (RT_SUCCESS(rc))
|
---|
2782 | return VINF_SUCCESS;
|
---|
2783 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set default dir mode mask to %04o: %Rrc", fMode, rc);
|
---|
2784 | }
|
---|
2785 |
|
---|
2786 |
|
---|
2787 | /**
|
---|
2788 | * Handles the --chmod option.
|
---|
2789 | *
|
---|
2790 | * @returns IPRT status code
|
---|
2791 | * @param pOpts The ISO maker command instance.
|
---|
2792 | * @param pszSpec The option value.
|
---|
2793 | */
|
---|
2794 | static int rtFsIsoMakerCmdOptChmod(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSpec)
|
---|
2795 | {
|
---|
2796 | /*
|
---|
2797 | * Parse the mode part.
|
---|
2798 | */
|
---|
2799 | int rc;
|
---|
2800 | uint32_t fUnset = 07777;
|
---|
2801 | uint32_t fSet = 0;
|
---|
2802 | const char *pszPath = pszSpec;
|
---|
2803 | if (RT_C_IS_DIGIT(*pszPath))
|
---|
2804 | {
|
---|
2805 | rc = RTStrToUInt32Ex(pszSpec, (char **)&pszPath, 8, &fSet);
|
---|
2806 | if (rc != VWRN_TRAILING_CHARS)
|
---|
2807 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --chmod, octal mode parse failed: %s (%Rrc)", pszSpec, rc);
|
---|
2808 | if (fSet & ~07777)
|
---|
2809 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --chmod, invalid mode mask: 0%o, max 07777", fSet);
|
---|
2810 | if (*pszPath != ':')
|
---|
2811 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --chmod, expected colon after mode: %s", pszSpec);
|
---|
2812 | }
|
---|
2813 | else
|
---|
2814 | {
|
---|
2815 | pszPath = strchr(pszPath, ':');
|
---|
2816 | if (pszPath == NULL)
|
---|
2817 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --chmod, expected colon after mode: %s", pszSpec);
|
---|
2818 | size_t const cchMode = pszPath - pszSpec;
|
---|
2819 |
|
---|
2820 | /* We currently only matches certain patterns. Later this needs to be generalized into a RTFile or RTPath method. */
|
---|
2821 | fUnset = 0;
|
---|
2822 | #define MATCH_MODE_STR(a_szMode) (cchMode == sizeof(a_szMode) - 1U && memcmp(pszSpec, a_szMode, sizeof(a_szMode) - 1) == 0)
|
---|
2823 | if (MATCH_MODE_STR("a+x"))
|
---|
2824 | fSet = 0111;
|
---|
2825 | else if (MATCH_MODE_STR("a+r"))
|
---|
2826 | fSet = 0444;
|
---|
2827 | else if (MATCH_MODE_STR("a+rx"))
|
---|
2828 | fSet = 0555;
|
---|
2829 | else
|
---|
2830 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Sorry, --chmod doesn't understand complicated mode expressions: %s", pszSpec);
|
---|
2831 | #undef MATCH_MODE_STR
|
---|
2832 | }
|
---|
2833 |
|
---|
2834 | /*
|
---|
2835 | * Check that the file starts with a slash.
|
---|
2836 | */
|
---|
2837 | pszPath++;
|
---|
2838 | if (!RTPATH_IS_SLASH(*pszPath))
|
---|
2839 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --chmod, path must start with a slash: %s", pszSpec);
|
---|
2840 |
|
---|
2841 | /*
|
---|
2842 | * Do the job.
|
---|
2843 | */
|
---|
2844 | rc = RTFsIsoMakerSetPathMode(pOpts->hIsoMaker, pszPath, pOpts->fDstNamespaces, fSet, fUnset, 0 /*fFlags*/, NULL /*pcHits*/);
|
---|
2845 | if (rc == VWRN_NOT_FOUND)
|
---|
2846 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Could not find --chmod path: %s", pszPath);
|
---|
2847 | if (RT_SUCCESS(rc))
|
---|
2848 | return VINF_SUCCESS;
|
---|
2849 | return rtFsIsoMakerCmdSyntaxError(pOpts, "RTFsIsoMakerSetPathMode(,%s,%#x,%o,%o,0,) failed: %Rrc",
|
---|
2850 | pszPath, pOpts->fDstNamespaces, fSet, fUnset, rc);
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 |
|
---|
2854 | /**
|
---|
2855 | * Handles the --chown and --chgrp options.
|
---|
2856 | *
|
---|
2857 | * @returns IPRT status code
|
---|
2858 | * @param pOpts The ISO maker command instance.
|
---|
2859 | * @param pszSpec The option value.
|
---|
2860 | * @param fIsChOwn Set if 'chown', clear if 'chgrp'.
|
---|
2861 | */
|
---|
2862 | static int rtFsIsoMakerCmdOptChangeOwnerGroup(PRTFSISOMAKERCMDOPTS pOpts, const char *pszSpec, bool fIsChOwn)
|
---|
2863 | {
|
---|
2864 | const char * const pszOpt = fIsChOwn ? "chown" : "chgrp";
|
---|
2865 |
|
---|
2866 | /*
|
---|
2867 | * Parse out the ID and path .
|
---|
2868 | */
|
---|
2869 | uint32_t idValue;
|
---|
2870 | const char *pszPath = pszSpec;
|
---|
2871 | int rc = RTStrToUInt32Ex(pszSpec, (char **)&pszPath, 0, &idValue);
|
---|
2872 | if (rc != VWRN_TRAILING_CHARS)
|
---|
2873 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --%s, numeric ID parse failed: %s (%Rrc)", pszOpt, pszSpec, rc);
|
---|
2874 | if (*pszPath != ':')
|
---|
2875 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --%s, expected colon after ID: %s", pszOpt, pszSpec);
|
---|
2876 | pszPath++;
|
---|
2877 | if (!RTPATH_IS_SLASH(*pszPath))
|
---|
2878 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Malformed --%s, path must start with a slash: %s", pszOpt, pszSpec);
|
---|
2879 |
|
---|
2880 | /*
|
---|
2881 | * Do the job.
|
---|
2882 | */
|
---|
2883 | if (fIsChOwn)
|
---|
2884 | rc = RTFsIsoMakerSetPathOwnerId(pOpts->hIsoMaker, pszPath, pOpts->fDstNamespaces, idValue, NULL /*pcHits*/);
|
---|
2885 | else
|
---|
2886 | rc = RTFsIsoMakerSetPathGroupId(pOpts->hIsoMaker, pszPath, pOpts->fDstNamespaces, idValue, NULL /*pcHits*/);
|
---|
2887 | if (rc == VWRN_NOT_FOUND)
|
---|
2888 | return rtFsIsoMakerCmdSyntaxError(pOpts, "Could not find --%s path: %s", pszOpt, pszPath);
|
---|
2889 | if (RT_SUCCESS(rc))
|
---|
2890 | return VINF_SUCCESS;
|
---|
2891 | return rtFsIsoMakerCmdSyntaxError(pOpts, "RTFsIsoMakerSetPath%sId(,%s,%#x,%u,) failed: %Rrc",
|
---|
2892 | fIsChOwn ? "Owner" : "Group", pszPath, pOpts->fDstNamespaces, idValue, rc);
|
---|
2893 | }
|
---|
2894 |
|
---|
2895 |
|
---|
2896 | /**
|
---|
2897 | * Loads an argument file (e.g. a .iso-file) and parses it.
|
---|
2898 | *
|
---|
2899 | * @returns IPRT status code.
|
---|
2900 | * @param pOpts The ISO maker command instance.
|
---|
2901 | * @param pszFileSpec The file to parse.
|
---|
2902 | * @param cDepth The current nesting depth.
|
---|
2903 | */
|
---|
2904 | static int rtFsIsoMakerCmdParseArgumentFile(PRTFSISOMAKERCMDOPTS pOpts, const char *pszFileSpec, unsigned cDepth)
|
---|
2905 | {
|
---|
2906 | if (cDepth > 2)
|
---|
2907 | return rtFsIsoMakerCmdErrorRc(pOpts, VERR_INVALID_PARAMETER, "Too many nested argument files!");
|
---|
2908 |
|
---|
2909 | /*
|
---|
2910 | * Read the file into memory.
|
---|
2911 | */
|
---|
2912 | RTERRINFOSTATIC ErrInfo;
|
---|
2913 | uint32_t offError;
|
---|
2914 | RTVFSFILE hVfsFile;
|
---|
2915 | int rc = RTVfsChainOpenFile(pszFileSpec, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFile,
|
---|
2916 | &offError, RTErrInfoInitStatic(&ErrInfo));
|
---|
2917 | if (RT_FAILURE(rc))
|
---|
2918 | return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainOpenFile", pszFileSpec, rc, offError, &ErrInfo.Core);
|
---|
2919 |
|
---|
2920 | uint64_t cbFile = 0;
|
---|
2921 | rc = RTVfsFileGetSize(hVfsFile, &cbFile);
|
---|
2922 | if (RT_SUCCESS(rc))
|
---|
2923 | {
|
---|
2924 | if (cbFile < _2M)
|
---|
2925 | {
|
---|
2926 | char *pszContent = (char *)RTMemTmpAllocZ((size_t)cbFile + 1);
|
---|
2927 | if (pszContent)
|
---|
2928 | {
|
---|
2929 | rc = RTVfsFileRead(hVfsFile, pszContent, (size_t)cbFile, NULL);
|
---|
2930 | if (RT_SUCCESS(rc))
|
---|
2931 | {
|
---|
2932 | /*
|
---|
2933 | * Check that it's valid UTF-8 and turn it into an argument vector.
|
---|
2934 | */
|
---|
2935 | rc = RTStrValidateEncodingEx(pszContent, (size_t)cbFile + 1,
|
---|
2936 | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
|
---|
2937 | if (RT_SUCCESS(rc))
|
---|
2938 | {
|
---|
2939 | uint32_t fGetOpt = strstr(pszContent, "--iprt-iso-maker-file-marker-ms") == NULL
|
---|
2940 | ? RTGETOPTARGV_CNV_QUOTE_BOURNE_SH : RTGETOPTARGV_CNV_QUOTE_MS_CRT;
|
---|
2941 | fGetOpt |= RTGETOPTARGV_CNV_MODIFY_INPUT;
|
---|
2942 | char **papszArgs;
|
---|
2943 | int cArgs;
|
---|
2944 | rc = RTGetOptArgvFromString(&papszArgs, &cArgs, pszContent, fGetOpt, NULL);
|
---|
2945 | if (RT_SUCCESS(rc))
|
---|
2946 | {
|
---|
2947 | /*
|
---|
2948 | * Parse them.
|
---|
2949 | */
|
---|
2950 | rc = rtFsIsoMakerCmdParse(pOpts, cArgs, papszArgs, cDepth + 1);
|
---|
2951 |
|
---|
2952 | RTGetOptArgvFreeEx(papszArgs, fGetOpt);
|
---|
2953 | }
|
---|
2954 | else
|
---|
2955 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s: RTGetOptArgvFromString failed: %Rrc", pszFileSpec, rc);
|
---|
2956 |
|
---|
2957 | }
|
---|
2958 | else
|
---|
2959 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s: invalid encoding", pszFileSpec);
|
---|
2960 | }
|
---|
2961 | else
|
---|
2962 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s: error to read it into memory: %Rrc", pszFileSpec, rc);
|
---|
2963 | RTMemTmpFree(pszContent);
|
---|
2964 | }
|
---|
2965 | else
|
---|
2966 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_NO_TMP_MEMORY, "%s: failed to allocte %zu bytes for reading",
|
---|
2967 | pszFileSpec, (size_t)cbFile + 1);
|
---|
2968 | }
|
---|
2969 | else
|
---|
2970 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_FILE_TOO_BIG, "%s: file is too big: %'RU64 bytes, max 2MB", pszFileSpec, cbFile);
|
---|
2971 | }
|
---|
2972 | else
|
---|
2973 | rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s: RTVfsFileGetSize failed: %Rrc", pszFileSpec, rc);
|
---|
2974 | RTVfsFileRelease(hVfsFile);
|
---|
2975 | return rc;
|
---|
2976 | }
|
---|
2977 |
|
---|
2978 |
|
---|
2979 | /**
|
---|
2980 | * Parses the given command line options.
|
---|
2981 | *
|
---|
2982 | * @returns IPRT status code.
|
---|
2983 | * @retval VINF_CALLBACK_RETURN if exit successfully (help, version).
|
---|
2984 | * @param pOpts The ISO maker command instance.
|
---|
2985 | * @param cArgs Number of arguments in papszArgs.
|
---|
2986 | * @param papszArgs The argument vector to parse.
|
---|
2987 | */
|
---|
2988 | static int rtFsIsoMakerCmdParse(PRTFSISOMAKERCMDOPTS pOpts, unsigned cArgs, char **papszArgs, unsigned cDepth)
|
---|
2989 | {
|
---|
2990 | /* Setup option parsing. */
|
---|
2991 | RTGETOPTSTATE GetState;
|
---|
2992 | int rc = RTGetOptInit(&GetState, cArgs, papszArgs, g_aRtFsIsoMakerOptions, RT_ELEMENTS(g_aRtFsIsoMakerOptions),
|
---|
2993 | cDepth == 0 ? 1 : 0 /*iFirst*/, 0 /*fFlags*/);
|
---|
2994 | if (RT_FAILURE(rc))
|
---|
2995 | return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTGetOpt failed: %Rrc", rc);
|
---|
2996 |
|
---|
2997 | /*
|
---|
2998 | * Parse parameters. Parameters are position dependent.
|
---|
2999 | */
|
---|
3000 | RTGETOPTUNION ValueUnion;
|
---|
3001 | while ( RT_SUCCESS(rc)
|
---|
3002 | && (rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
|
---|
3003 | {
|
---|
3004 | switch (rc)
|
---|
3005 | {
|
---|
3006 | /*
|
---|
3007 | * Files and directories.
|
---|
3008 | */
|
---|
3009 | case VINF_GETOPT_NOT_OPTION:
|
---|
3010 | if ( *ValueUnion.psz != '@'
|
---|
3011 | || strchr(ValueUnion.psz, '='))
|
---|
3012 | rc = rtFsIsoMakerCmdAddSomething(pOpts, ValueUnion.psz);
|
---|
3013 | else
|
---|
3014 | rc = rtFsIsoMakerCmdParseArgumentFile(pOpts, ValueUnion.psz + 1, cDepth);
|
---|
3015 | break;
|
---|
3016 |
|
---|
3017 |
|
---|
3018 | /*
|
---|
3019 | * General options
|
---|
3020 | */
|
---|
3021 | case 'o':
|
---|
3022 | if (pOpts->fVirtualImageMaker)
|
---|
3023 | return rtFsIsoMakerCmdSyntaxError(pOpts, "The --output option is not allowed");
|
---|
3024 | if (pOpts->pszOutFile)
|
---|
3025 | return rtFsIsoMakerCmdSyntaxError(pOpts, "The --output option is specified more than once");
|
---|
3026 | pOpts->pszOutFile = ValueUnion.psz;
|
---|
3027 | break;
|
---|
3028 |
|
---|
3029 | case RTFSISOMAKERCMD_OPT_NAME_SETUP:
|
---|
3030 | rc = rtFsIsoMakerCmdOptNameSetup(pOpts, ValueUnion.psz);
|
---|
3031 | break;
|
---|
3032 |
|
---|
3033 | case RTFSISOMAKERCMD_OPT_PUSH_ISO:
|
---|
3034 | rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso", 0);
|
---|
3035 | break;
|
---|
3036 |
|
---|
3037 | case RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_JOLIET:
|
---|
3038 | rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso-no-joliet", RTFSISO9660_F_NO_JOLIET);
|
---|
3039 | break;
|
---|
3040 |
|
---|
3041 | case RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK:
|
---|
3042 | rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso-no-rock", RTFSISO9660_F_NO_ROCK);
|
---|
3043 | break;
|
---|
3044 |
|
---|
3045 | case RTFSISOMAKERCMD_OPT_PUSH_ISO_NO_ROCK_NO_JOLIET:
|
---|
3046 | rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso-no-rock-no-joliet",
|
---|
3047 | RTFSISO9660_F_NO_ROCK | RTFSISO9660_F_NO_JOLIET);
|
---|
3048 | break;
|
---|
3049 |
|
---|
3050 | case RTFSISOMAKERCMD_OPT_POP:
|
---|
3051 | rc = rtFsIsoMakerCmdOptPop(pOpts);
|
---|
3052 | break;
|
---|
3053 |
|
---|
3054 | case RTFSISOMAKERCMD_OPT_IMPORT_ISO:
|
---|
3055 | rc = rtFsIsoMakerCmdOptImportIso(pOpts, ValueUnion.psz);
|
---|
3056 | break;
|
---|
3057 |
|
---|
3058 |
|
---|
3059 | /*
|
---|
3060 | * Namespace configuration.
|
---|
3061 | */
|
---|
3062 | case RTFSISOMAKERCMD_OPT_ISO_LEVEL:
|
---|
3063 | rc = rtFsIsoMakerCmdOptSetIsoLevel(pOpts, ValueUnion.u8);
|
---|
3064 | break;
|
---|
3065 |
|
---|
3066 | case RTFSISOMAKERCMD_OPT_ROCK_RIDGE:
|
---|
3067 | rc = rtFsIsoMakerCmdOptSetPrimaryRockLevel(pOpts, 2);
|
---|
3068 | break;
|
---|
3069 |
|
---|
3070 | case RTFSISOMAKERCMD_OPT_LIMITED_ROCK_RIDGE:
|
---|
3071 | rc = rtFsIsoMakerCmdOptSetPrimaryRockLevel(pOpts, 1);
|
---|
3072 | break;
|
---|
3073 |
|
---|
3074 | case RTFSISOMAKERCMD_OPT_NO_ROCK_RIDGE:
|
---|
3075 | rc = rtFsIsoMakerCmdOptSetPrimaryRockLevel(pOpts, 0);
|
---|
3076 | break;
|
---|
3077 |
|
---|
3078 | case 'J':
|
---|
3079 | rc = rtFsIsoMakerCmdOptSetJolietUcs2Level(pOpts, 3);
|
---|
3080 | break;
|
---|
3081 |
|
---|
3082 | case RTFSISOMAKERCMD_OPT_NO_JOLIET:
|
---|
3083 | rc = rtFsIsoMakerCmdOptSetJolietUcs2Level(pOpts, 0);
|
---|
3084 | break;
|
---|
3085 |
|
---|
3086 | case RTFSISOMAKERCMD_OPT_JOLIET_LEVEL:
|
---|
3087 | rc = rtFsIsoMakerCmdOptSetJolietUcs2Level(pOpts, ValueUnion.u8);
|
---|
3088 | break;
|
---|
3089 |
|
---|
3090 |
|
---|
3091 | /*
|
---|
3092 | * File attributes.
|
---|
3093 | */
|
---|
3094 | case RTFSISOMAKERCMD_OPT_RATIONAL_ATTRIBS:
|
---|
3095 | rc = rtFsIsoMakerCmdOptSetAttribInheritStyle(pOpts, false /*fStrict*/);
|
---|
3096 | break;
|
---|
3097 |
|
---|
3098 | case RTFSISOMAKERCMD_OPT_STRICT_ATTRIBS:
|
---|
3099 | rc = rtFsIsoMakerCmdOptSetAttribInheritStyle(pOpts, true /*fStrict*/);
|
---|
3100 | break;
|
---|
3101 |
|
---|
3102 | case RTFSISOMAKERCMD_OPT_FILE_MODE:
|
---|
3103 | rc = rtFsIsoMakerCmdOptSetFileOrDirMode(pOpts, false /*fDir*/, ValueUnion.u32);
|
---|
3104 | break;
|
---|
3105 |
|
---|
3106 | case RTFSISOMAKERCMD_OPT_NO_FILE_MODE:
|
---|
3107 | rc = rtFsIsoMakerCmdOptDisableFileOrDirMode(pOpts, false /*fDir*/);
|
---|
3108 | break;
|
---|
3109 |
|
---|
3110 | case RTFSISOMAKERCMD_OPT_DIR_MODE:
|
---|
3111 | rc = rtFsIsoMakerCmdOptSetFileOrDirMode(pOpts, true /*fDir*/, ValueUnion.u32);
|
---|
3112 | break;
|
---|
3113 |
|
---|
3114 | case RTFSISOMAKERCMD_OPT_NO_DIR_MODE:
|
---|
3115 | rc = rtFsIsoMakerCmdOptDisableFileOrDirMode(pOpts, true /*fDir*/);
|
---|
3116 | break;
|
---|
3117 |
|
---|
3118 | case RTFSISOMAKERCMD_OPT_NEW_DIR_MODE:
|
---|
3119 | rc = rtFsIsoMakerCmdOptSetNewDirMode(pOpts, ValueUnion.u32);
|
---|
3120 | break;
|
---|
3121 |
|
---|
3122 | case RTFSISOMAKERCMD_OPT_CHMOD:
|
---|
3123 | rc = rtFsIsoMakerCmdOptChmod(pOpts, ValueUnion.psz);
|
---|
3124 | break;
|
---|
3125 |
|
---|
3126 | case RTFSISOMAKERCMD_OPT_CHOWN:
|
---|
3127 | rc = rtFsIsoMakerCmdOptChangeOwnerGroup(pOpts, ValueUnion.psz, true /*fIsChOwn*/);
|
---|
3128 | break;
|
---|
3129 |
|
---|
3130 | case RTFSISOMAKERCMD_OPT_CHGRP:
|
---|
3131 | rc = rtFsIsoMakerCmdOptChangeOwnerGroup(pOpts, ValueUnion.psz, false /*fIsChOwn*/);
|
---|
3132 | break;
|
---|
3133 |
|
---|
3134 |
|
---|
3135 | /*
|
---|
3136 | * Boot related options.
|
---|
3137 | */
|
---|
3138 | case 'G': /* --generic-boot <file> */
|
---|
3139 | rc = rtFsIsoMakerCmdOptGenericBoot(pOpts, ValueUnion.psz);
|
---|
3140 | break;
|
---|
3141 |
|
---|
3142 | case RTFSISOMAKERCMD_OPT_ELTORITO_ADD_IMAGE:
|
---|
3143 | rc = rtFsIsoMakerCmdOptEltoritoAddImage(pOpts, ValueUnion.psz);
|
---|
3144 | break;
|
---|
3145 |
|
---|
3146 | case 'b': /* --eltorito-boot <boot.img> */
|
---|
3147 | rc = rtFsIsoMakerCmdOptEltoritoBoot(pOpts, ValueUnion.psz);
|
---|
3148 | break;
|
---|
3149 |
|
---|
3150 | case RTFSISOMAKERCMD_OPT_ELTORITO_NEW_ENTRY:
|
---|
3151 | rc = rtFsIsoMakerCmdOptEltoritoNewEntry(pOpts);
|
---|
3152 | break;
|
---|
3153 |
|
---|
3154 | case RTFSISOMAKERCMD_OPT_ELTORITO_PLATFORM_ID:
|
---|
3155 | rc = rtFsIsoMakerCmdOptEltoritoPlatformId(pOpts, ValueUnion.psz);
|
---|
3156 | break;
|
---|
3157 |
|
---|
3158 | case RTFSISOMAKERCMD_OPT_ELTORITO_NO_BOOT:
|
---|
3159 | rc = rtFsIsoMakerCmdOptEltoritoSetNotBootable(pOpts);
|
---|
3160 | break;
|
---|
3161 |
|
---|
3162 | case RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_12:
|
---|
3163 | rc = rtFsIsoMakerCmdOptEltoritoSetMediaType(pOpts, ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_2_MB);
|
---|
3164 | break;
|
---|
3165 | case RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_144:
|
---|
3166 | rc = rtFsIsoMakerCmdOptEltoritoSetMediaType(pOpts, ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_44_MB);
|
---|
3167 | break;
|
---|
3168 | case RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_288:
|
---|
3169 | rc = rtFsIsoMakerCmdOptEltoritoSetMediaType(pOpts, ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_2_88_MB);
|
---|
3170 | break;
|
---|
3171 | case RTFSISOMAKERCMD_OPT_ELTORITO_HARD_DISK_BOOT:
|
---|
3172 | rc = rtFsIsoMakerCmdOptEltoritoSetMediaType(pOpts, ISO9660_ELTORITO_BOOT_MEDIA_TYPE_HARD_DISK);
|
---|
3173 | break;
|
---|
3174 | case RTFSISOMAKERCMD_OPT_ELTORITO_NO_EMULATION_BOOT:
|
---|
3175 | rc = rtFsIsoMakerCmdOptEltoritoSetMediaType(pOpts, ISO9660_ELTORITO_BOOT_MEDIA_TYPE_NO_EMULATION);
|
---|
3176 | break;
|
---|
3177 |
|
---|
3178 | case RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SEG:
|
---|
3179 | rc = rtFsIsoMakerCmdOptEltoritoSetLoadSegment(pOpts, ValueUnion.u16);
|
---|
3180 | break;
|
---|
3181 |
|
---|
3182 | case RTFSISOMAKERCMD_OPT_ELTORITO_LOAD_SIZE:
|
---|
3183 | rc = rtFsIsoMakerCmdOptEltoritoSetLoadSectorCount(pOpts, ValueUnion.u16);
|
---|
3184 | break;
|
---|
3185 |
|
---|
3186 | case RTFSISOMAKERCMD_OPT_ELTORITO_INFO_TABLE:
|
---|
3187 | rc = rtFsIsoMakerCmdOptEltoritoEnableBootInfoTablePatching(pOpts);
|
---|
3188 | break;
|
---|
3189 |
|
---|
3190 | case 'c': /* --boot-catalog <cd-path> */
|
---|
3191 | rc = rtFsIsoMakerCmdOptEltoritoSetBootCatalogPath(pOpts, ValueUnion.psz);
|
---|
3192 | break;
|
---|
3193 |
|
---|
3194 |
|
---|
3195 | /*
|
---|
3196 | * Image/namespace property related options.
|
---|
3197 | */
|
---|
3198 | case RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID:
|
---|
3199 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_ABSTRACT_FILE_ID);
|
---|
3200 | break;
|
---|
3201 |
|
---|
3202 | case 'A': /* --application-id */
|
---|
3203 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_APPLICATION_ID);
|
---|
3204 | break;
|
---|
3205 |
|
---|
3206 | case RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID:
|
---|
3207 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_BIBLIOGRAPHIC_FILE_ID);
|
---|
3208 | break;
|
---|
3209 |
|
---|
3210 | case RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID:
|
---|
3211 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_COPYRIGHT_FILE_ID);
|
---|
3212 | break;
|
---|
3213 |
|
---|
3214 | case 'P': /* -publisher */
|
---|
3215 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_PUBLISHER_ID);
|
---|
3216 | break;
|
---|
3217 |
|
---|
3218 | case 'p': /* --preparer*/
|
---|
3219 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_DATA_PREPARER_ID);
|
---|
3220 | break;
|
---|
3221 |
|
---|
3222 | case RTFSISOMAKERCMD_OPT_SYSTEM_ID:
|
---|
3223 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_SYSTEM_ID);
|
---|
3224 | break;
|
---|
3225 |
|
---|
3226 | case RTFSISOMAKERCMD_OPT_VOLUME_ID: /* (should've been '-V') */
|
---|
3227 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_VOLUME_ID);
|
---|
3228 | break;
|
---|
3229 |
|
---|
3230 | case RTFSISOMAKERCMD_OPT_VOLUME_SET_ID:
|
---|
3231 | rc = rtFsIsoMakerCmdOptSetStringProp(pOpts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_VOLUME_SET_ID);
|
---|
3232 | break;
|
---|
3233 |
|
---|
3234 |
|
---|
3235 | /*
|
---|
3236 | * Compatibility.
|
---|
3237 | */
|
---|
3238 | case RTFSISOMAKERCMD_OPT_GRAFT_POINTS:
|
---|
3239 | rc = rtFsIsoMakerCmdOptNameSetup(pOpts, "iso+joliet+udf+hfs");
|
---|
3240 | break;
|
---|
3241 |
|
---|
3242 | case 'l':
|
---|
3243 | if (RTFsIsoMakerGetIso9660Level(pOpts->hIsoMaker) >= 2)
|
---|
3244 | rc = rtFsIsoMakerCmdOptSetIsoLevel(pOpts, 2);
|
---|
3245 | break;
|
---|
3246 |
|
---|
3247 | case 'R':
|
---|
3248 | rc = rtFsIsoMakerCmdOptSetPrimaryRockLevel(pOpts, 2);
|
---|
3249 | if (RT_SUCCESS(rc))
|
---|
3250 | rc = rtFsIsoMakerCmdOptSetAttribInheritStyle(pOpts, true /*fStrict*/);
|
---|
3251 | break;
|
---|
3252 |
|
---|
3253 | case 'r':
|
---|
3254 | rc = rtFsIsoMakerCmdOptSetPrimaryRockLevel(pOpts, 2);
|
---|
3255 | if (RT_SUCCESS(rc))
|
---|
3256 | rc = rtFsIsoMakerCmdOptSetAttribInheritStyle(pOpts, false /*fStrict*/);
|
---|
3257 | break;
|
---|
3258 |
|
---|
3259 | case RTFSISOMAKERCMD_OPT_PAD:
|
---|
3260 | rc = RTFsIsoMakerSetImagePadding(pOpts->hIsoMaker, 150);
|
---|
3261 | if (RT_FAILURE(rc))
|
---|
3262 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerSetImagePadding failed: %Rrc", rc);
|
---|
3263 | break;
|
---|
3264 |
|
---|
3265 | case RTFSISOMAKERCMD_OPT_NO_PAD:
|
---|
3266 | rc = RTFsIsoMakerSetImagePadding(pOpts->hIsoMaker, 0);
|
---|
3267 | if (RT_FAILURE(rc))
|
---|
3268 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerSetImagePadding failed: %Rrc", rc);
|
---|
3269 | break;
|
---|
3270 |
|
---|
3271 |
|
---|
3272 | /*
|
---|
3273 | * VISO specific
|
---|
3274 | */
|
---|
3275 | case RTFSISOMAKERCMD_OPT_IPRT_ISO_MAKER_FILE_MARKER:
|
---|
3276 | /* ignored */
|
---|
3277 | break;
|
---|
3278 |
|
---|
3279 |
|
---|
3280 | /*
|
---|
3281 | * Testing.
|
---|
3282 | */
|
---|
3283 | case RTFSISOMAKERCMD_OPT_OUTPUT_BUFFER_SIZE: /* --output-buffer-size {cb} */
|
---|
3284 | pOpts->cbOutputReadBuffer = ValueUnion.u32;
|
---|
3285 | break;
|
---|
3286 |
|
---|
3287 | case RTFSISOMAKERCMD_OPT_RANDOM_OUTPUT_BUFFER_SIZE: /* --random-output-buffer-size */
|
---|
3288 | pOpts->fRandomOutputReadBufferSize = true;
|
---|
3289 | break;
|
---|
3290 |
|
---|
3291 | case RTFSISOMAKERCMD_OPT_RANDOM_ORDER_VERIFICATION: /* --random-order-verification {cb} */
|
---|
3292 | pOpts->cbRandomOrderVerifciationBlock = ValueUnion.u32;
|
---|
3293 | break;
|
---|
3294 |
|
---|
3295 |
|
---|
3296 | /*
|
---|
3297 | * Standard bits.
|
---|
3298 | */
|
---|
3299 | case 'h':
|
---|
3300 | rtFsIsoMakerCmdUsage(pOpts, papszArgs[0]);
|
---|
3301 | return pOpts->fVirtualImageMaker ? VERR_NOT_FOUND : VINF_CALLBACK_RETURN;
|
---|
3302 |
|
---|
3303 | case 'V':
|
---|
3304 | rtFsIsoMakerPrintf(pOpts, "%sr%d\n", RTBldCfgVersion(), RTBldCfgRevision());
|
---|
3305 | return pOpts->fVirtualImageMaker ? VERR_NOT_FOUND : VINF_CALLBACK_RETURN;
|
---|
3306 |
|
---|
3307 | default:
|
---|
3308 | if (rc > 0 && RT_C_IS_GRAPH(rc))
|
---|
3309 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_GETOPT_UNKNOWN_OPTION, "Unhandled option: -%c", rc);
|
---|
3310 | else if (rc > 0)
|
---|
3311 | rc = rtFsIsoMakerCmdErrorRc(pOpts, VERR_GETOPT_UNKNOWN_OPTION, "Unhandled option: %i (%#x)", rc, rc);
|
---|
3312 | else if (rc == VERR_GETOPT_UNKNOWN_OPTION)
|
---|
3313 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Unknown option: '%s'", ValueUnion.psz);
|
---|
3314 | else if (ValueUnion.pDef)
|
---|
3315 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s: %Rrs", ValueUnion.pDef->pszLong, rc);
|
---|
3316 | else
|
---|
3317 | rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%Rrs", rc);
|
---|
3318 | return rc;
|
---|
3319 | }
|
---|
3320 | if (RT_FAILURE(rc))
|
---|
3321 | return rc;
|
---|
3322 | }
|
---|
3323 | return VINF_SUCCESS;
|
---|
3324 | }
|
---|
3325 |
|
---|
3326 |
|
---|
3327 | /**
|
---|
3328 | * Extended ISO maker command.
|
---|
3329 | *
|
---|
3330 | * This can be used as a ISO maker command that produces a image file, or
|
---|
3331 | * alternatively for setting up a virtual ISO in memory.
|
---|
3332 | *
|
---|
3333 | * @returns IPRT status code
|
---|
3334 | * @param cArgs Number of arguments.
|
---|
3335 | * @param papszArgs Pointer to argument array.
|
---|
3336 | * @param phVfsFile Where to return the virtual ISO. Pass NULL to
|
---|
3337 | * for normal operation (creates file on disk).
|
---|
3338 | * @param pErrInfo Where to return extended error information in
|
---|
3339 | * the virtual ISO mode.
|
---|
3340 | */
|
---|
3341 | RTDECL(int) RTFsIsoMakerCmdEx(unsigned cArgs, char **papszArgs, PRTVFSFILE phVfsFile, PRTERRINFO pErrInfo)
|
---|
3342 | {
|
---|
3343 | /*
|
---|
3344 | * Create instance.
|
---|
3345 | */
|
---|
3346 | RTFSISOMAKERCMDOPTS Opts;
|
---|
3347 | RT_ZERO(Opts);
|
---|
3348 | Opts.hIsoMaker = NIL_RTFSISOMAKER;
|
---|
3349 | Opts.pErrInfo = pErrInfo;
|
---|
3350 | Opts.fVirtualImageMaker = phVfsFile != NULL;
|
---|
3351 | Opts.hSrcVfs = NIL_RTVFS;
|
---|
3352 | Opts.cNameSpecifiers = 1;
|
---|
3353 | Opts.afNameSpecifiers[0] = RTFSISOMAKERCMDNAME_MAJOR_MASK;
|
---|
3354 | Opts.fDstNamespaces = RTFSISOMAKERCMDNAME_MAJOR_MASK;
|
---|
3355 | Opts.pszTransTbl = "TRANS.TBL"; /** @todo query this below */
|
---|
3356 | if (phVfsFile)
|
---|
3357 | *phVfsFile = NIL_RTVFSFILE;
|
---|
3358 | for (uint32_t i = 0; i < RT_ELEMENTS(Opts.aBootCatEntries); i++)
|
---|
3359 | Opts.aBootCatEntries[i].u.Section.idxImageObj = UINT32_MAX;
|
---|
3360 |
|
---|
3361 | /* Create the ISO creator instance. */
|
---|
3362 | int rc = RTFsIsoMakerCreate(&Opts.hIsoMaker);
|
---|
3363 | if (RT_FAILURE(rc))
|
---|
3364 | return rtFsIsoMakerCmdErrorRc(&Opts, rc, "RTFsIsoMakerCreate failed: %Rrc", rc);
|
---|
3365 |
|
---|
3366 | /*
|
---|
3367 | * Parse the command line and check for mandatory options.
|
---|
3368 | */
|
---|
3369 | rc = rtFsIsoMakerCmdParse(&Opts, cArgs, papszArgs, 0);
|
---|
3370 | if (RT_SUCCESS(rc) && rc != VINF_CALLBACK_RETURN)
|
---|
3371 | {
|
---|
3372 | if (!Opts.cItemsAdded)
|
---|
3373 | rc = rtFsIsoMakerCmdErrorRc(&Opts, VERR_NO_DATA, "Cowardly refuses to create empty ISO image");
|
---|
3374 | else if (!Opts.pszOutFile && !Opts.fVirtualImageMaker)
|
---|
3375 | rc = rtFsIsoMakerCmdErrorRc(&Opts, VERR_INVALID_PARAMETER, "No output file specified (--output <file>)");
|
---|
3376 |
|
---|
3377 | /*
|
---|
3378 | * Final actions.
|
---|
3379 | */
|
---|
3380 | if (RT_SUCCESS(rc))
|
---|
3381 | rc = rtFsIsoMakerCmdOptEltoritoCommitBootCatalog(&Opts);
|
---|
3382 | if (RT_SUCCESS(rc))
|
---|
3383 | {
|
---|
3384 | /*
|
---|
3385 | * Finalize the image and get the virtual file.
|
---|
3386 | */
|
---|
3387 | rc = RTFsIsoMakerFinalize(Opts.hIsoMaker);
|
---|
3388 | if (RT_SUCCESS(rc))
|
---|
3389 | {
|
---|
3390 | RTVFSFILE hVfsFile;
|
---|
3391 | rc = RTFsIsoMakerCreateVfsOutputFile(Opts.hIsoMaker, &hVfsFile);
|
---|
3392 | if (RT_SUCCESS(rc))
|
---|
3393 | {
|
---|
3394 | /*
|
---|
3395 | * We're done now if we're only setting up a virtual image.
|
---|
3396 | */
|
---|
3397 | if (Opts.fVirtualImageMaker)
|
---|
3398 | *phVfsFile = hVfsFile;
|
---|
3399 | else
|
---|
3400 | {
|
---|
3401 | rc = rtFsIsoMakerCmdWriteImage(&Opts, hVfsFile);
|
---|
3402 | RTVfsFileRelease(hVfsFile);
|
---|
3403 | }
|
---|
3404 | }
|
---|
3405 | else
|
---|
3406 | rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "RTFsIsoMakerCreateVfsOutputFile failed: %Rrc", rc);
|
---|
3407 | }
|
---|
3408 | else
|
---|
3409 | rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "RTFsIsoMakerFinalize failed: %Rrc", rc);
|
---|
3410 | }
|
---|
3411 | }
|
---|
3412 |
|
---|
3413 | return rtFsIsoMakerCmdDeleteState(&Opts, rc);
|
---|
3414 | }
|
---|
3415 |
|
---|
3416 |
|
---|
3417 | /**
|
---|
3418 | * ISO maker command (creates image file on disk).
|
---|
3419 | *
|
---|
3420 | * @returns IPRT status code
|
---|
3421 | * @param cArgs Number of arguments.
|
---|
3422 | * @param papszArgs Pointer to argument array.
|
---|
3423 | */
|
---|
3424 | RTDECL(RTEXITCODE) RTFsIsoMakerCmd(unsigned cArgs, char **papszArgs)
|
---|
3425 | {
|
---|
3426 | int rc = RTFsIsoMakerCmdEx(cArgs, papszArgs, NULL, NULL);
|
---|
3427 | return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
|
---|
3428 | }
|
---|
3429 |
|
---|