setup.h 38 KB

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