setup.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. setup.h
  5. Abstract:
  6. This header contains definitions for the setup application.
  7. Author:
  8. Evan Green 10-Apr-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #define RTL_API __DLLEXPORT
  14. #include <minoca/lib/minocaos.h>
  15. #include <minoca/lib/partlib.h>
  16. #include "chalk.h"
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // Define the assumed block size of the install media.
  22. //
  23. #define SETUP_BLOCK_SIZE 512
  24. //
  25. // Set this flag to enable more printing.
  26. //
  27. #define SETUP_FLAG_VERBOSE 0x00000001
  28. //
  29. // Set this flag to reboot at the end of the installation.
  30. //
  31. #define SETUP_FLAG_REBOOT 0x00000002
  32. //
  33. // Set this flag to enable debugging in the new boot configuration.
  34. //
  35. #define SETUP_FLAG_INSTALL_DEBUG 0x00000004
  36. //
  37. // Set this flag to enable boot debugging in the target.
  38. //
  39. #define SETUP_FLAG_INSTALL_BOOT_DEBUG 0x00000008
  40. //
  41. // Set this flag to run in automated mode, where setup will try to install to
  42. // any free partition that is not the current system partition. This flag
  43. // shouldn't be used by real users, only test automation.
  44. //
  45. #define SETUP_FLAG_AUTO_DEPLOY 0x00000010
  46. //
  47. // Set this flag to print nothing but errors.
  48. //
  49. #define SETUP_FLAG_QUIET 0x00000020
  50. //
  51. // Define the name of the source install image.
  52. //
  53. #define SETUP_DEFAULT_IMAGE_NAME "./install.img"
  54. //
  55. // Define the path of the page file.
  56. //
  57. #define SETUP_PAGE_FILE_PATH "pagefile.sys"
  58. //
  59. // This flag is set if this is the system disk or partition.
  60. //
  61. #define SETUP_DEVICE_FLAG_SYSTEM 0x00000001
  62. //
  63. // Define the well known offsets of the boot sector where its LBA and size are
  64. // stored.
  65. //
  66. #define SETUP_BOOT_SECTOR_BLOCK_ADDRESS_OFFSET 0x5C
  67. #define SETUP_BOOT_SECTOR_BLOCK_LENGTH_OFFSET 0x60
  68. #define SETUP_SYMLINK_MAX 512
  69. //
  70. // Define away some things on Windows.
  71. //
  72. #ifdef _WIN32
  73. #define S_IRGRP 0
  74. #define S_ISLNK(_Mode) (((_Mode) & S_IFMT) == S_IFLNK)
  75. #define S_IFLNK 0x0000A000
  76. #define O_NOFOLLOW 0
  77. #endif
  78. //
  79. // ------------------------------------------------------ Data Type Definitions
  80. //
  81. //
  82. // Define setup recipe IDs, alphabetized by config file name.
  83. //
  84. typedef enum _SETUP_RECIPE_ID {
  85. SetupRecipeNone,
  86. SetupRecipeBeagleBoneBlack,
  87. SetupRecipeCommon,
  88. SetupRecipeGalileo,
  89. SetupRecipeInstallArmv6,
  90. SetupRecipeInstallArmv7,
  91. SetupRecipeInstallX86,
  92. SetupRecipeIntegratorCpRamDisk,
  93. SetupRecipePandaBoard,
  94. SetupRecipePandaBoardUsb,
  95. SetupRecipePc,
  96. SetupRecipePcEfi,
  97. SetupRecipePcTiny,
  98. SetupRecipeRaspberryPi,
  99. SetupRecipeRaspberryPi2,
  100. SetupRecipeVeyron,
  101. SetupRecipeCount
  102. } SETUP_RECIPE_ID, *PSETUP_RECIPE_ID;
  103. typedef enum _SETUP_DESTINATION_TYPE {
  104. SetupDestinationInvalid,
  105. SetupDestinationDisk,
  106. SetupDestinationPartition,
  107. SetupDestinationDirectory,
  108. SetupDestinationImage,
  109. SetupDestinationFile,
  110. } SETUP_DESTINATION_TYPE, *PSETUP_DESTINATION_TYPE;
  111. typedef enum _SETUP_VOLUME_FORMAT_CHOICE {
  112. SetupVolumeFormatInvalid,
  113. SetupVolumeFormatAlways,
  114. SetupVolumeFormatNever,
  115. SetupVolumeFormatIfIncompatible,
  116. } SETUP_VOLUME_FORMAT_CHOICE, *PSETUP_VOLUME_FORMAT_CHOICE;
  117. typedef enum _SETUP_SCRIPT_ORDER {
  118. SetupScriptOrderNow,
  119. SetupScriptOrderInitialization,
  120. SetupScriptOrderUserInitialization,
  121. SetupScriptOrderPlatform,
  122. SetupScriptOrderUserCustomization
  123. } SETUP_SCRIPT_ORDER, *PSETUP_SCRIPT_ORDER;
  124. typedef struct _SETUP_CONFIGURATION SETUP_CONFIGURATION, *PSETUP_CONFIGURATION;
  125. /*++
  126. Structure Description:
  127. This structure defines a destination for setup.
  128. Members:
  129. Type - Stores the type of object this destination refers to.
  130. Path - Stores a pointer to a heap-allocated path to the destination. If
  131. this is NULL, then the destination is assumed to point to a device ID.
  132. IsDeviceId - Stores a boolean indicating if the destination is a device ID
  133. (TRUE) or a path (FALSE).
  134. DeviceId - Stores the device ID of the destination.
  135. --*/
  136. typedef struct _SETUP_DESTINATION {
  137. SETUP_DESTINATION_TYPE Type;
  138. PSTR Path;
  139. ULONGLONG DeviceId;
  140. } SETUP_DESTINATION, *PSETUP_DESTINATION;
  141. /*++
  142. Structure Description:
  143. This structure describes a partition.
  144. Members:
  145. Partition - Stores the partition information.
  146. Destination - Stores a pointer to the destination needed to open this
  147. partition.
  148. Flags - Stores a bitfield of flags about the device. See
  149. SETUP_DEVICE_FLAG_* definitions.
  150. --*/
  151. typedef struct _SETUP_PARTITION_DESCRIPTION {
  152. PARTITION_DEVICE_INFORMATION Partition;
  153. PSETUP_DESTINATION Destination;
  154. ULONG Flags;
  155. } SETUP_PARTITION_DESCRIPTION, *PSETUP_PARTITION_DESCRIPTION;
  156. /*++
  157. Structure Description:
  158. This structure describes setup's application context.
  159. Members:
  160. Flags - Stores a bitfield of flags governing the behavior. See
  161. SETUP_FLAG_* definitions.
  162. PartitionContext - Stores a pointer to the partition library context for
  163. the disk layout.
  164. CurrentPartitionOffset - Stores the offset in blocks to the partition
  165. being actively read from and written to.
  166. CurrentPartitionSize - Stores the size in blocks of the partition being
  167. actively read from and written to.
  168. DiskPath - Stores an optional pointer to the disk to install to.
  169. PartitionPath - Stores an optional pointer to the partition to install to.
  170. DirectoryPath - Stores an optional pointer to the directory to install to.
  171. BootPartitionPath - Stores an optional pointer to the boot partition to
  172. update.
  173. DiskSize - Stores the override disk size.
  174. Disk - Stores a pointer to the install disk.
  175. SourceVolume - Stores a pointer to the install source volume.
  176. HostFileSystem - Stores an open volume pointer to an empty host path.
  177. RecipeIndex - Stores the recipe index to follow.
  178. PageFileSize - Stores the size in megabytes of the page file.
  179. Interpreter - Stores the interpreter context.
  180. Configuration - Stores the installation configuration.
  181. --*/
  182. typedef struct _SETUP_CONTEXT {
  183. ULONG Flags;
  184. PARTITION_CONTEXT PartitionContext;
  185. LONGLONG CurrentPartitionOffset;
  186. ULONGLONG CurrentPartitionSize;
  187. PSETUP_DESTINATION DiskPath;
  188. PSETUP_DESTINATION PartitionPath;
  189. PSETUP_DESTINATION DirectoryPath;
  190. PSETUP_DESTINATION BootPartitionPath;
  191. ULONGLONG DiskSize;
  192. PVOID Disk;
  193. PVOID SourceVolume;
  194. PVOID HostFileSystem;
  195. LONG RecipeIndex;
  196. ULONGLONG PageFileSize;
  197. CHALK_INTERPRETER Interpreter;
  198. PSETUP_CONFIGURATION Configuration;
  199. } SETUP_CONTEXT, *PSETUP_CONTEXT;
  200. /*++
  201. Structure Description:
  202. This structure describes a handle to a volume in the setup app.
  203. Members:
  204. Context - Stores a pointer back to tha application context.
  205. DestinationType - Stores the destination type of the open volume.
  206. PathPrefix - Stores the path to prefix onto every open file operation.
  207. BlockHandle - Stores a pointer to the native OS handle to the disk,
  208. partition, or image.
  209. VolumeToken - Stores the mounted file system token.
  210. OpenFiles - Stores the number of files opened against this volume.
  211. --*/
  212. typedef struct _SETUP_VOLUME {
  213. PSETUP_CONTEXT Context;
  214. SETUP_DESTINATION_TYPE DestinationType;
  215. PSTR PathPrefix;
  216. PVOID BlockHandle;
  217. PVOID VolumeToken;
  218. ULONG OpenFiles;
  219. } SETUP_VOLUME, *PSETUP_VOLUME;
  220. //
  221. // -------------------------------------------------------------------- Globals
  222. //
  223. extern UCHAR SetupZeroDiskIdentifier[DISK_IDENTIFIER_SIZE];
  224. extern UCHAR SetupZeroPartitionIdentifier[PARTITION_IDENTIFIER_SIZE];
  225. //
  226. // -------------------------------------------------------- Function Prototypes
  227. //
  228. //
  229. // OS specific functions
  230. //
  231. INT
  232. SetupOsEnumerateDevices (
  233. PSETUP_PARTITION_DESCRIPTION *DeviceArray,
  234. PULONG DeviceCount
  235. );
  236. /*++
  237. Routine Description:
  238. This routine enumerates all the disks and partitions on the system.
  239. Arguments:
  240. DeviceArray - Supplies a pointer where an array of partition structures
  241. will be returned on success.
  242. DeviceCount - Supplies a pointer where the number of elements in the
  243. partition array will be returned on success.
  244. Return Value:
  245. 0 on success.
  246. Returns an error code on failure.
  247. --*/
  248. INT
  249. SetupOsGetPartitionInformation (
  250. PSETUP_DESTINATION Destination,
  251. PPARTITION_DEVICE_INFORMATION Information
  252. );
  253. /*++
  254. Routine Description:
  255. This routine returns the partition information for the given destination.
  256. Arguments:
  257. Destination - Supplies a pointer to the partition to query.
  258. Information - Supplies a pointer where the information will be returned
  259. on success.
  260. Return Value:
  261. 0 on success.
  262. Returns an error code on failure.
  263. --*/
  264. PVOID
  265. SetupOsOpenBootVolume (
  266. PSETUP_CONTEXT Context
  267. );
  268. /*++
  269. Routine Description:
  270. This routine opens the boot volume on the current machine.
  271. Arguments:
  272. Context - Supplies a pointer to the application context.
  273. Return Value:
  274. Returns the open handle to the boot volume on success.
  275. NULL on failure.
  276. --*/
  277. //
  278. // OS specific native file interface.
  279. //
  280. INT
  281. SetupOsReadLink (
  282. PSTR Path,
  283. PSTR *LinkTarget,
  284. INT *LinkTargetSize
  285. );
  286. /*++
  287. Routine Description:
  288. This routine attempts to read a symbolic link.
  289. Arguments:
  290. Path - Supplies a pointer to the path to open.
  291. LinkTarget - Supplies a pointer where an allocated link target will be
  292. returned on success. The caller is responsible for freeing this memory.
  293. LinkTargetSize - Supplies a pointer where the size of the link target will
  294. be returned on success.
  295. Return Value:
  296. 0 on success.
  297. Returns an error number on failure.
  298. --*/
  299. INT
  300. SetupOsSymlink (
  301. PSTR Path,
  302. PSTR LinkTarget,
  303. INT LinkTargetSize
  304. );
  305. /*++
  306. Routine Description:
  307. This routine creates a symbolic link.
  308. Arguments:
  309. Path - Supplies a pointer to the path of the symbolic link to create.
  310. LinkTarget - Supplies a pointer to the target of the link.
  311. LinkTargetSize - Supplies a the size of the link target buffer in bytes.
  312. Return Value:
  313. Returns the link size on success.
  314. -1 on failure.
  315. --*/
  316. PVOID
  317. SetupOsOpenDestination (
  318. PSETUP_DESTINATION Destination,
  319. INT Flags,
  320. INT CreatePermissions
  321. );
  322. /*++
  323. Routine Description:
  324. This routine opens a handle to a given destination.
  325. Arguments:
  326. Destination - Supplies a pointer to the destination to open.
  327. Flags - Supplies open flags. See O_* definitions.
  328. CreatePermissions - Supplies optional create permissions.
  329. Return Value:
  330. Returns a pointer to an opaque context on success.
  331. NULL on failure.
  332. --*/
  333. VOID
  334. SetupOsClose (
  335. PVOID Handle
  336. );
  337. /*++
  338. Routine Description:
  339. This routine closes a handle.
  340. Arguments:
  341. Handle - Supplies a pointer to the destination to open.
  342. Return Value:
  343. None.
  344. --*/
  345. ssize_t
  346. SetupOsRead (
  347. PVOID Handle,
  348. void *Buffer,
  349. size_t ByteCount
  350. );
  351. /*++
  352. Routine Description:
  353. This routine reads from an open handle.
  354. Arguments:
  355. Handle - Supplies the handle.
  356. Buffer - Supplies a pointer where the read bytes will be returned.
  357. ByteCount - Supplies the number of bytes to read.
  358. Return Value:
  359. Returns the number of bytes read.
  360. -1 on failure.
  361. --*/
  362. ssize_t
  363. SetupOsWrite (
  364. PVOID Handle,
  365. void *Buffer,
  366. size_t ByteCount
  367. );
  368. /*++
  369. Routine Description:
  370. This routine writes data to an open handle.
  371. Arguments:
  372. Handle - Supplies the handle.
  373. Buffer - Supplies a pointer to the bytes to write.
  374. ByteCount - Supplies the number of bytes to read.
  375. Return Value:
  376. Returns the number of bytes written.
  377. -1 on failure.
  378. --*/
  379. LONGLONG
  380. SetupOsSeek (
  381. PVOID Handle,
  382. LONGLONG Offset
  383. );
  384. /*++
  385. Routine Description:
  386. This routine seeks in the current file or device.
  387. Arguments:
  388. Handle - Supplies the handle.
  389. Offset - Supplies the new offset to set.
  390. Return Value:
  391. Returns the resulting file offset after the operation.
  392. -1 on failure, and errno will contain more information. The file offset
  393. will remain unchanged.
  394. --*/
  395. LONGLONG
  396. SetupOsTell (
  397. PVOID Handle
  398. );
  399. /*++
  400. Routine Description:
  401. This routine returns the current offset in the given file or device.
  402. Arguments:
  403. Handle - Supplies the handle.
  404. Return Value:
  405. Returns the file offset on success.
  406. -1 on failure, and errno will contain more information. The file offset
  407. will remain unchanged.
  408. --*/
  409. INT
  410. SetupOsFstat (
  411. PVOID Handle,
  412. PULONGLONG FileSize,
  413. time_t *ModificationDate,
  414. mode_t *Mode
  415. );
  416. /*++
  417. Routine Description:
  418. This routine gets details for the given open file.
  419. Arguments:
  420. Handle - Supplies the handle.
  421. FileSize - Supplies an optional pointer where the file size will be
  422. returned on success.
  423. ModificationDate - Supplies an optional pointer where the file's
  424. modification date will be returned on success.
  425. Mode - Supplies an optional pointer where the file's mode information will
  426. be returned on success.
  427. Return Value:
  428. 0 on success.
  429. Non-zero on failure.
  430. --*/
  431. INT
  432. SetupOsFtruncate (
  433. PVOID Handle,
  434. ULONGLONG NewSize
  435. );
  436. /*++
  437. Routine Description:
  438. This routine sets the file size of the given file.
  439. Arguments:
  440. Handle - Supplies the handle.
  441. NewSize - Supplies the new file size.
  442. Return Value:
  443. 0 on success.
  444. Non-zero on failure.
  445. --*/
  446. INT
  447. SetupOsEnumerateDirectory (
  448. PVOID Handle,
  449. PSTR DirectoryPath,
  450. PSTR *Enumeration
  451. );
  452. /*++
  453. Routine Description:
  454. This routine enumerates the contents of a given directory.
  455. Arguments:
  456. Handle - Supplies the open volume handle.
  457. DirectoryPath - Supplies a pointer to a string containing the path to the
  458. directory to enumerate.
  459. Enumeration - Supplies a pointer where a pointer to a sequence of
  460. strings will be returned containing the files in the directory. The
  461. sequence will be terminated by an empty string. The caller is
  462. responsible for freeing this memory when done.
  463. Return Value:
  464. 0 on success.
  465. Non-zero on failure.
  466. --*/
  467. INT
  468. SetupOsCreateDirectory (
  469. PSTR Path,
  470. mode_t Permissions
  471. );
  472. /*++
  473. Routine Description:
  474. This routine creates a new directory.
  475. Arguments:
  476. Path - Supplies the path string of the directory to create.
  477. Permissions - Supplies the permission bits to create the file with.
  478. Return Value:
  479. 0 on success.
  480. Non-zero on failure.
  481. --*/
  482. INT
  483. SetupOsSetAttributes (
  484. PSTR Path,
  485. time_t ModificationDate,
  486. mode_t Permissions
  487. );
  488. /*++
  489. Routine Description:
  490. This routine sets attributes on a given path.
  491. Arguments:
  492. Path - Supplies the path string of the file to modify.
  493. ModificationDate - Supplies the new modification date to set.
  494. Permissions - Supplies the new permissions to set.
  495. Return Value:
  496. 0 on success.
  497. Non-zero on failure.
  498. --*/
  499. VOID
  500. SetupOsDetermineExecuteBit (
  501. PVOID Handle,
  502. PSTR Path,
  503. mode_t *Mode
  504. );
  505. /*++
  506. Routine Description:
  507. This routine determines whether the open file is executable.
  508. Arguments:
  509. Handle - Supplies the open file handle.
  510. Path - Supplies the path the file was opened from (sometimes the file name
  511. is used as a hint).
  512. Mode - Supplies a pointer to the current mode bits. This routine may add
  513. the executable bit to user/group/other if it determines this file is
  514. executable.
  515. Return Value:
  516. None.
  517. --*/
  518. INT
  519. SetupOsReboot (
  520. VOID
  521. );
  522. /*++
  523. Routine Description:
  524. This routine reboots the machine.
  525. Arguments:
  526. None.
  527. Return Value:
  528. 0 on success.
  529. Non-zero on failure.
  530. --*/
  531. INT
  532. SetupOsGetPlatformName (
  533. PSTR *Name,
  534. PSETUP_RECIPE_ID Fallback
  535. );
  536. /*++
  537. Routine Description:
  538. This routine gets the platform name.
  539. Arguments:
  540. Name - Supplies a pointer where a pointer to an allocated string containing
  541. the SMBIOS system information product name will be returned if
  542. available. The caller is responsible for freeing this memory when done.
  543. Fallback - Supplies a fallback platform to use if the given platform
  544. string was not returned or did not match a known platform.
  545. Return Value:
  546. 0 on success.
  547. Non-zero on failure.
  548. --*/
  549. INT
  550. SetupOsGetSystemMemorySize (
  551. PULONGLONG Megabytes
  552. );
  553. /*++
  554. Routine Description:
  555. This routine returns the number of megabytes of memory installed on the
  556. currently running system.
  557. Arguments:
  558. Megabytes - Supplies a pointer to where the system memory capacity in
  559. megabytes will be returned on success.
  560. Return Value:
  561. 0 on success.
  562. Non-zero on failure.
  563. --*/
  564. //
  565. // Cache wrapper functions for OS layer functionality.
  566. //
  567. PVOID
  568. SetupOpenDestination (
  569. PSETUP_DESTINATION Destination,
  570. INT Flags,
  571. INT CreatePermissions
  572. );
  573. /*++
  574. Routine Description:
  575. This routine opens a handle to a given destination.
  576. Arguments:
  577. Destination - Supplies a pointer to the destination to open.
  578. Flags - Supplies open flags. See O_* definitions.
  579. CreatePermissions - Supplies optional create permissions.
  580. Return Value:
  581. Returns a pointer to an opaque context on success.
  582. NULL on failure.
  583. --*/
  584. VOID
  585. SetupClose (
  586. PVOID Handle
  587. );
  588. /*++
  589. Routine Description:
  590. This routine closes a handle.
  591. Arguments:
  592. Handle - Supplies a pointer to the destination to open.
  593. Return Value:
  594. None.
  595. --*/
  596. ssize_t
  597. SetupRead (
  598. PVOID Handle,
  599. void *Buffer,
  600. size_t ByteCount
  601. );
  602. /*++
  603. Routine Description:
  604. This routine reads from an open handle.
  605. Arguments:
  606. Handle - Supplies the handle.
  607. Buffer - Supplies a pointer where the read bytes will be returned.
  608. ByteCount - Supplies the number of bytes to read.
  609. Return Value:
  610. Returns the number of bytes read.
  611. -1 on failure.
  612. --*/
  613. ssize_t
  614. SetupWrite (
  615. PVOID Handle,
  616. void *Buffer,
  617. size_t ByteCount
  618. );
  619. /*++
  620. Routine Description:
  621. This routine writes data to an open handle.
  622. Arguments:
  623. Handle - Supplies the handle.
  624. Buffer - Supplies a pointer to the bytes to write.
  625. ByteCount - Supplies the number of bytes to read.
  626. Return Value:
  627. Returns the number of bytes written.
  628. -1 on failure.
  629. --*/
  630. LONGLONG
  631. SetupSeek (
  632. PVOID Handle,
  633. LONGLONG Offset
  634. );
  635. /*++
  636. Routine Description:
  637. This routine seeks in the current file or device.
  638. Arguments:
  639. Handle - Supplies the handle.
  640. Offset - Supplies the new offset to set.
  641. Return Value:
  642. Returns the resulting file offset after the operation.
  643. -1 on failure, and errno will contain more information. The file offset
  644. will remain unchanged.
  645. --*/
  646. INT
  647. SetupFstat (
  648. PVOID Handle,
  649. PULONGLONG FileSize,
  650. time_t *ModificationDate,
  651. mode_t *Mode
  652. );
  653. /*++
  654. Routine Description:
  655. This routine gets details for the given open file.
  656. Arguments:
  657. Handle - Supplies the handle.
  658. FileSize - Supplies an optional pointer where the file size will be
  659. returned on success.
  660. ModificationDate - Supplies an optional pointer where the file's
  661. modification date will be returned on success.
  662. Mode - Supplies an optional pointer where the file's mode information will
  663. be returned on success.
  664. Return Value:
  665. 0 on success.
  666. Non-zero on failure.
  667. --*/
  668. INT
  669. SetupFtruncate (
  670. PVOID Handle,
  671. ULONGLONG NewSize
  672. );
  673. /*++
  674. Routine Description:
  675. This routine sets the file size of the given file.
  676. Arguments:
  677. Handle - Supplies the handle.
  678. NewSize - Supplies the new file size.
  679. Return Value:
  680. 0 on success.
  681. Non-zero on failure.
  682. --*/
  683. INT
  684. SetupEnumerateDirectory (
  685. PVOID VolumeHandle,
  686. PSTR DirectoryPath,
  687. PSTR *Enumeration
  688. );
  689. /*++
  690. Routine Description:
  691. This routine enumerates the contents of a given directory.
  692. Arguments:
  693. VolumeHandle - Supplies the open volume handle.
  694. DirectoryPath - Supplies a pointer to a string containing the path to the
  695. directory to enumerate.
  696. Enumeration - Supplies a pointer where a pointer to a sequence of
  697. strings will be returned containing the files in the directory. The
  698. sequence will be terminated by an empty string. The caller is
  699. responsible for freeing this memory when done.
  700. Return Value:
  701. 0 on success.
  702. Non-zero on failure.
  703. --*/
  704. VOID
  705. SetupDetermineExecuteBit (
  706. PVOID Handle,
  707. PSTR Path,
  708. mode_t *Mode
  709. );
  710. /*++
  711. Routine Description:
  712. This routine determines whether the open file is executable.
  713. Arguments:
  714. Handle - Supplies the open file handle.
  715. Path - Supplies the path the file was opened from (sometimes the file name
  716. is used as a hint).
  717. Mode - Supplies a pointer to the current mode bits. This routine may add
  718. the executable bit to user/group/other if it determines this file is
  719. executable.
  720. Return Value:
  721. None.
  722. --*/
  723. //
  724. // File I/O functions
  725. //
  726. PVOID
  727. SetupVolumeOpen (
  728. PSETUP_CONTEXT Context,
  729. PSETUP_DESTINATION Destination,
  730. SETUP_VOLUME_FORMAT_CHOICE Format,
  731. BOOL CompatibilityMode
  732. );
  733. /*++
  734. Routine Description:
  735. This routine opens a handle to a given volume.
  736. Arguments:
  737. Context - Supplies a pointer to the application context.
  738. Destination - Supplies a pointer to the destination to open.
  739. Format - Supplies the disposition for formatting the volume.
  740. CompatibilityMode - Supplies a boolean indicating whether to run the
  741. file system in the most compatible way possible.
  742. Return Value:
  743. Returns a pointer to an opaque context on success.
  744. NULL on failure.
  745. --*/
  746. VOID
  747. SetupVolumeClose (
  748. PSETUP_CONTEXT Context,
  749. PVOID Handle
  750. );
  751. /*++
  752. Routine Description:
  753. This routine closes a volume.
  754. Arguments:
  755. Context - Supplies a pointer to the application context.
  756. Handle - Supplies a pointer to the open volume handle.
  757. Return Value:
  758. None.
  759. --*/
  760. INT
  761. SetupFileReadLink (
  762. PVOID Handle,
  763. PSTR Path,
  764. PSTR *LinkTarget,
  765. INT *LinkTargetSize
  766. );
  767. /*++
  768. Routine Description:
  769. This routine attempts to read a symbolic link.
  770. Arguments:
  771. Handle - Supplies the volume handle.
  772. Path - Supplies a pointer to the path to open.
  773. LinkTarget - Supplies a pointer where an allocated link target will be
  774. returned on success. The caller is responsible for freeing this memory.
  775. LinkTargetSize - Supplies a pointer where the size of the link target will
  776. be returned on success.
  777. Return Value:
  778. Returns the link size on success.
  779. -1 on failure.
  780. --*/
  781. INT
  782. SetupFileSymlink (
  783. PVOID Handle,
  784. PSTR Path,
  785. PSTR LinkTarget,
  786. INT LinkTargetSize
  787. );
  788. /*++
  789. Routine Description:
  790. This routine creates a symbolic link.
  791. Arguments:
  792. Handle - Supplies the volume handle.
  793. Path - Supplies a pointer to the path of the symbolic link to create.
  794. LinkTarget - Supplies a pointer to the target of the link.
  795. LinkTargetSize - Supplies a the size of the link target buffer in bytes.
  796. Return Value:
  797. Returns the link size on success.
  798. -1 on failure.
  799. --*/
  800. PVOID
  801. SetupFileOpen (
  802. PVOID Handle,
  803. PSTR Path,
  804. INT Flags,
  805. INT CreatePermissions
  806. );
  807. /*++
  808. Routine Description:
  809. This routine opens a handle to a file in a volume.
  810. Arguments:
  811. Handle - Supplies the volume handle.
  812. Path - Supplies a pointer to the path to open.
  813. Flags - Supplies open flags. See O_* definitions.
  814. CreatePermissions - Supplies optional create permissions.
  815. Return Value:
  816. Returns a pointer to an opaque context on success.
  817. NULL on failure.
  818. --*/
  819. VOID
  820. SetupFileClose (
  821. PVOID Handle
  822. );
  823. /*++
  824. Routine Description:
  825. This routine closes a file.
  826. Arguments:
  827. Handle - Supplies the handle to close.
  828. Return Value:
  829. None.
  830. --*/
  831. ssize_t
  832. SetupFileRead (
  833. PVOID Handle,
  834. void *Buffer,
  835. size_t ByteCount
  836. );
  837. /*++
  838. Routine Description:
  839. This routine reads from a file.
  840. Arguments:
  841. Handle - Supplies the handle.
  842. Buffer - Supplies a pointer where the read bytes will be returned.
  843. ByteCount - Supplies the number of bytes to read.
  844. Return Value:
  845. Returns the number of bytes read on success.
  846. --*/
  847. ssize_t
  848. SetupFileWrite (
  849. PVOID Handle,
  850. void *Buffer,
  851. size_t ByteCount
  852. );
  853. /*++
  854. Routine Description:
  855. This routine writes data to an open file handle.
  856. Arguments:
  857. Handle - Supplies the handle.
  858. Buffer - Supplies a pointer to the bytes to write.
  859. ByteCount - Supplies the number of bytes to read.
  860. Return Value:
  861. Returns the number of bytes written.
  862. -1 on failure.
  863. --*/
  864. LONGLONG
  865. SetupFileSeek (
  866. PVOID Handle,
  867. LONGLONG Offset
  868. );
  869. /*++
  870. Routine Description:
  871. This routine seeks in the given file.
  872. Arguments:
  873. Handle - Supplies the handle.
  874. Offset - Supplies the new offset to set.
  875. Return Value:
  876. Returns the resulting file offset after the operation.
  877. -1 on failure, and errno will contain more information. The file offset
  878. will remain unchanged.
  879. --*/
  880. INT
  881. SetupFileFileStat (
  882. PVOID Handle,
  883. PULONGLONG FileSize,
  884. time_t *ModificationDate,
  885. mode_t *Mode
  886. );
  887. /*++
  888. Routine Description:
  889. This routine gets details for the given open file.
  890. Arguments:
  891. Handle - Supplies the handle.
  892. FileSize - Supplies an optional pointer where the file size will be
  893. returned on success.
  894. ModificationDate - Supplies an optional pointer where the file's
  895. modification date will be returned on success.
  896. Mode - Supplies an optional pointer where the file's mode information will
  897. be returned on success.
  898. Return Value:
  899. 0 on success.
  900. Non-zero on failure.
  901. --*/
  902. INT
  903. SetupFileFileTruncate (
  904. PVOID Handle,
  905. ULONGLONG NewSize
  906. );
  907. /*++
  908. Routine Description:
  909. This routine sets the file size of the given file.
  910. Arguments:
  911. Handle - Supplies the handle.
  912. NewSize - Supplies the new file size.
  913. Return Value:
  914. 0 on success.
  915. Non-zero on failure.
  916. --*/
  917. INT
  918. SetupFileEnumerateDirectory (
  919. PVOID VolumeHandle,
  920. PSTR DirectoryPath,
  921. PSTR *Enumeration
  922. );
  923. /*++
  924. Routine Description:
  925. This routine enumerates the contents of a given directory.
  926. Arguments:
  927. VolumeHandle - Supplies the open volume handle.
  928. DirectoryPath - Supplies a pointer to a string containing the path to the
  929. directory to enumerate.
  930. Enumeration - Supplies a pointer where a pointer to a sequence of
  931. strings will be returned containing the files in the directory. The
  932. sequence will be terminated by an empty string. The caller is
  933. responsible for freeing this memory when done.
  934. Return Value:
  935. 0 on success.
  936. Non-zero on failure.
  937. --*/
  938. INT
  939. SetupFileCreateDirectory (
  940. PVOID VolumeHandle,
  941. PSTR Path,
  942. mode_t Permissions
  943. );
  944. /*++
  945. Routine Description:
  946. This routine creates a new directory.
  947. Arguments:
  948. VolumeHandle - Supplies a pointer to the volume handle.
  949. Path - Supplies the path string of the directory to create.
  950. Permissions - Supplies the permission bits to create the file with.
  951. Return Value:
  952. 0 on success.
  953. Non-zero on failure.
  954. --*/
  955. INT
  956. SetupFileSetAttributes (
  957. PVOID VolumeHandle,
  958. PSTR Path,
  959. time_t ModificationDate,
  960. mode_t Permissions
  961. );
  962. /*++
  963. Routine Description:
  964. This routine sets attributes on a given path.
  965. Arguments:
  966. VolumeHandle - Supplies a pointer to the volume handle.
  967. Path - Supplies the path string of the file to modify.
  968. ModificationDate - Supplies the new modification date to set.
  969. Permissions - Supplies the new permissions to set.
  970. Return Value:
  971. 0 on success.
  972. Non-zero on failure.
  973. --*/
  974. VOID
  975. SetupFileDetermineExecuteBit (
  976. PVOID Handle,
  977. PSTR Path,
  978. mode_t *Mode
  979. );
  980. /*++
  981. Routine Description:
  982. This routine determines whether the open file is executable.
  983. Arguments:
  984. Handle - Supplies the open file handle.
  985. Path - Supplies the path the file was opened from (sometimes the file name
  986. is used as a hint).
  987. Mode - Supplies a pointer to the current mode bits. This routine may add
  988. the executable bit to user/group/other if it determines this file is
  989. executable.
  990. Return Value:
  991. None.
  992. --*/
  993. //
  994. // Partition I/O functions
  995. //
  996. PVOID
  997. SetupPartitionOpen (
  998. PSETUP_CONTEXT Context,
  999. PSETUP_DESTINATION Destination,
  1000. PPARTITION_DEVICE_INFORMATION PartitionInformation
  1001. );
  1002. /*++
  1003. Routine Description:
  1004. This routine opens a handle to a given partition destination.
  1005. Arguments:
  1006. Context - Supplies a pointer to the application context.
  1007. Destination - Supplies a pointer to the destination to open.
  1008. PartitionInformation - Supplies an optional pointer where the partition
  1009. information will be returned on success.
  1010. Return Value:
  1011. Returns a pointer to an opaque context on success.
  1012. NULL on failure.
  1013. --*/
  1014. VOID
  1015. SetupPartitionClose (
  1016. PSETUP_CONTEXT Context,
  1017. PVOID Handle
  1018. );
  1019. /*++
  1020. Routine Description:
  1021. This routine closes a partition.
  1022. Arguments:
  1023. Context - Supplies a pointer to the application context.
  1024. Handle - Supplies the open handle.
  1025. Return Value:
  1026. None.
  1027. --*/
  1028. ssize_t
  1029. SetupPartitionRead (
  1030. PSETUP_CONTEXT Context,
  1031. PVOID Handle,
  1032. void *Buffer,
  1033. size_t ByteCount
  1034. );
  1035. /*++
  1036. Routine Description:
  1037. This routine reads from a partition.
  1038. Arguments:
  1039. Context - Supplies a pointer to the application context.
  1040. Handle - Supplies the handle.
  1041. Buffer - Supplies a pointer where the read bytes will be returned.
  1042. ByteCount - Supplies the number of bytes to read.
  1043. Return Value:
  1044. Returns the number of bytes read on success.
  1045. --*/
  1046. ssize_t
  1047. SetupPartitionWrite (
  1048. PSETUP_CONTEXT Context,
  1049. PVOID Handle,
  1050. void *Buffer,
  1051. size_t ByteCount
  1052. );
  1053. /*++
  1054. Routine Description:
  1055. This routine writes to a partition.
  1056. Arguments:
  1057. Context - Supplies a pointer to the application context.
  1058. Handle - Supplies the handle.
  1059. Buffer - Supplies a pointer to the data to write.
  1060. ByteCount - Supplies the number of bytes to read.
  1061. Return Value:
  1062. Returns the number of bytes written.
  1063. --*/
  1064. LONGLONG
  1065. SetupPartitionSeek (
  1066. PSETUP_CONTEXT Context,
  1067. PVOID Handle,
  1068. LONGLONG Offset
  1069. );
  1070. /*++
  1071. Routine Description:
  1072. This routine seeks in the current file or device.
  1073. Arguments:
  1074. Context - Supplies a pointer to the application context.
  1075. Handle - Supplies the handle.
  1076. Offset - Supplies the offset in blocks to seek to.
  1077. Return Value:
  1078. Returns the resulting file offset in blocks after the operation.
  1079. -1 on failure, and errno will contain more information. The file offset
  1080. will remain unchanged.
  1081. --*/
  1082. //
  1083. // Disk functions
  1084. //
  1085. INT
  1086. SetupFormatDisk (
  1087. PSETUP_CONTEXT Context
  1088. );
  1089. /*++
  1090. Routine Description:
  1091. This routine partitions a disk.
  1092. Arguments:
  1093. Context - Supplies a pointer to the application context.
  1094. Return Value:
  1095. 0 on success.
  1096. Non-zero on failure.
  1097. --*/
  1098. //
  1099. // Platform support functions
  1100. //
  1101. BOOL
  1102. SetupParsePlatformString (
  1103. PSETUP_CONTEXT Context,
  1104. PSTR PlatformString
  1105. );
  1106. /*++
  1107. Routine Description:
  1108. This routine converts a platform string into a platform identifier, and
  1109. sets it in the setup context.
  1110. Arguments:
  1111. Context - Supplies a pointer to the setup context.
  1112. PlatformString - Supplies a pointer to the string to convert to a
  1113. platform identifier.
  1114. Return Value:
  1115. TRUE if the platform name was successfully converted.
  1116. FALSE if the name was invalid.
  1117. --*/
  1118. VOID
  1119. SetupPrintPlatformList (
  1120. VOID
  1121. );
  1122. /*++
  1123. Routine Description:
  1124. This routine prints the supported platform list.
  1125. Arguments:
  1126. None.
  1127. Return Value:
  1128. None.
  1129. --*/
  1130. INT
  1131. SetupDeterminePlatform (
  1132. PSETUP_CONTEXT Context
  1133. );
  1134. /*++
  1135. Routine Description:
  1136. This routine finalizes the setup platform recipe to use.
  1137. Arguments:
  1138. Context - Supplies a pointer to the setup context.
  1139. Return Value:
  1140. 0 on success.
  1141. Non-zero on failure.
  1142. --*/
  1143. INT
  1144. SetupAddRecipeScript (
  1145. PSETUP_CONTEXT Context
  1146. );
  1147. /*++
  1148. Routine Description:
  1149. This routine adds the platform recipe script.
  1150. Arguments:
  1151. Context - Supplies a pointer to the setup context.
  1152. Return Value:
  1153. 0 on success.
  1154. Non-zero on failure.
  1155. --*/
  1156. INT
  1157. SetupAddCommonScripts (
  1158. PSETUP_CONTEXT Context
  1159. );
  1160. /*++
  1161. Routine Description:
  1162. This routine adds the common scripts that are added no matter what.
  1163. Arguments:
  1164. Context - Supplies a pointer to the setup context.
  1165. Return Value:
  1166. 0 on success.
  1167. Non-zero on failure.
  1168. --*/
  1169. //
  1170. // Utility functions
  1171. //
  1172. PSETUP_DESTINATION
  1173. SetupCreateDestination (
  1174. SETUP_DESTINATION_TYPE Type,
  1175. PSTR Path,
  1176. DEVICE_ID DeviceId
  1177. );
  1178. /*++
  1179. Routine Description:
  1180. This routine creates a setup destination structure.
  1181. Arguments:
  1182. Type - Supplies the destination type.
  1183. Path - Supplies an optional pointer to the path. A copy of this string will
  1184. be made.
  1185. DeviceId - Supplies an optional device ID.
  1186. Return Value:
  1187. Returns a pointer to the newly created destination on success.
  1188. NULL on allocation failure.
  1189. --*/
  1190. VOID
  1191. SetupDestroyDestination (
  1192. PSETUP_DESTINATION Destination
  1193. );
  1194. /*++
  1195. Routine Description:
  1196. This routine destroys a setup destination structure.
  1197. Arguments:
  1198. Destination - Supplies a pointer to the destination structure to free.
  1199. Return Value:
  1200. None.
  1201. --*/
  1202. VOID
  1203. SetupDestroyDeviceDescriptions (
  1204. PSETUP_PARTITION_DESCRIPTION Devices,
  1205. ULONG DeviceCount
  1206. );
  1207. /*++
  1208. Routine Description:
  1209. This routine destroys an array of device descriptions.
  1210. Arguments:
  1211. Devices - Supplies a pointer to the array to destroy.
  1212. DeviceCount - Supplies the number of elements in the array.
  1213. Return Value:
  1214. None.
  1215. --*/
  1216. VOID
  1217. SetupPrintDeviceDescription (
  1218. PSETUP_PARTITION_DESCRIPTION Device,
  1219. BOOL PrintHeader
  1220. );
  1221. /*++
  1222. Routine Description:
  1223. This routine prints a device description.
  1224. Arguments:
  1225. Device - Supplies a pointer to the device description.
  1226. PrintHeader - Supplies a boolean indicating if the column descriptions
  1227. should be printed.
  1228. Return Value:
  1229. None.
  1230. --*/
  1231. ULONG
  1232. SetupPrintSize (
  1233. PCHAR String,
  1234. ULONG StringSize,
  1235. ULONGLONG Value
  1236. );
  1237. /*++
  1238. Routine Description:
  1239. This routine prints a formatted size a la 5.8M (M for megabytes).
  1240. Arguments:
  1241. String - Supplies a pointer to the string buffer to print to.
  1242. StringSize - Supplies the total size of the string buffer in bytes.
  1243. Value - Supplies the value in bytes to print.
  1244. Return Value:
  1245. Returns the number of bytes successfully converted.
  1246. --*/
  1247. VOID
  1248. SetupPrintDestination (
  1249. PSETUP_DESTINATION Destination
  1250. );
  1251. /*++
  1252. Routine Description:
  1253. This routine prints a destination structure.
  1254. Arguments:
  1255. Destination - Supplies a pointer to the destination.
  1256. Return Value:
  1257. None.
  1258. --*/
  1259. PSETUP_DESTINATION
  1260. SetupParseDestination (
  1261. SETUP_DESTINATION_TYPE DestinationType,
  1262. PSTR Argument
  1263. );
  1264. /*++
  1265. Routine Description:
  1266. This routine converts a string argument into a destination. Device ID
  1267. destinations can start with "0x", and everything else is treated as a
  1268. path. An empty string is not valid.
  1269. Arguments:
  1270. DestinationType - Supplies the destination type.
  1271. Argument - Supplies the string argument.
  1272. Return Value:
  1273. Returns a pointer to a newly created destination on success. The caller
  1274. is responsible for destroying this structure.
  1275. NULL if the argument is not valid.
  1276. --*/
  1277. PSTR
  1278. SetupAppendPaths (
  1279. PSTR Path1,
  1280. PSTR Path2
  1281. );
  1282. /*++
  1283. Routine Description:
  1284. This routine appends two paths to one another.
  1285. Arguments:
  1286. Path1 - Supplies a pointer to the first path.
  1287. Path2 - Supplies a pointer to the second path.
  1288. Return Value:
  1289. Returns a pointer to a newly created combined path on success. The caller
  1290. is responsible for freeing this new path.
  1291. NULL on allocation failure.
  1292. --*/
  1293. INT
  1294. SetupConvertStringArrayToLines (
  1295. PSTR *StringArray,
  1296. PSTR *ResultBuffer,
  1297. PUINTN ResultBufferSize
  1298. );
  1299. /*++
  1300. Routine Description:
  1301. This routine converts a null-terminated array of strings into a single
  1302. buffer where each element is separated by a newline.
  1303. Arguments:
  1304. StringArray - Supplies a pointer to the array of strings. The array must be
  1305. terminated by a NULL entry.
  1306. ResultBuffer - Supplies a pointer where a string will be returned
  1307. containing all the lines. The caller is responsible for freeing this
  1308. buffer.
  1309. ResultBufferSize - Supplies a pointer where size of the buffer in bytes
  1310. will be returned, including the null terminator.
  1311. Return Value:
  1312. 0 on success.
  1313. ENOMEM on allocation failure.
  1314. --*/
  1315. INT
  1316. SetupCopyFile (
  1317. PSETUP_CONTEXT Context,
  1318. PVOID Destination,
  1319. PVOID Source,
  1320. PSTR DestinationPath,
  1321. PSTR SourcePath,
  1322. ULONG Flags
  1323. );
  1324. /*++
  1325. Routine Description:
  1326. This routine copies the given path from the source to the destination. If
  1327. the source is a directory, the contents of that directory are recursively
  1328. copied to the destination.
  1329. Arguments:
  1330. Context - Supplies a pointer to the applicaton context.
  1331. Destination - Supplies a pointer to the open destination volume
  1332. handle.
  1333. Source - Supplies a pointer to the open source volume handle.
  1334. DestinationPath - Supplies a pointer to the path of the file to create at
  1335. the destination.
  1336. SourcePath - Supplies the source path of the copy.
  1337. Flags - Supplies a bitfield of flags governing the operation. See
  1338. SETUP_COPY_FLAG_* definitions.
  1339. Return Value:
  1340. 0 on success.
  1341. Non-zero on failure.
  1342. --*/
  1343. INT
  1344. SetupCreateAndWriteFile (
  1345. PSETUP_CONTEXT Context,
  1346. PVOID Destination,
  1347. PSTR DestinationPath,
  1348. PVOID Contents,
  1349. ULONG ContentsSize
  1350. );
  1351. /*++
  1352. Routine Description:
  1353. This routine creates a file and writes the given contents out to it.
  1354. Arguments:
  1355. Context - Supplies a pointer to the applicaton context.
  1356. Destination - Supplies a pointer to the open destination volume
  1357. handle.
  1358. DestinationPath - Supplies a pointer to the path of the file to create at
  1359. the destination.
  1360. Contents - Supplies the buffer containing the file contents to write.
  1361. ContentsSize - Supplies the size of the buffer in bytes.
  1362. Return Value:
  1363. 0 on success.
  1364. Non-zero on failure.
  1365. --*/
  1366. INT
  1367. SetupCreateDirectories (
  1368. PSETUP_CONTEXT Context,
  1369. PVOID Volume,
  1370. PSTR Path
  1371. );
  1372. /*++
  1373. Routine Description:
  1374. This routine creates directories up to but not including the final
  1375. component of the given path.
  1376. Arguments:
  1377. Context - Supplies a pointer to the applicaton context.
  1378. Volume - Supplies a pointer to the open destination volume handle.
  1379. Path - Supplies the full file path. The file itself won't be created, but
  1380. all directories leading up to it will. If the path ends in a slash,
  1381. all components will be created.
  1382. Return Value:
  1383. 0 on success.
  1384. Non-zero on failure.
  1385. --*/