unistd.h 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU Lesser General Public
  4. License version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details.
  6. Module Name:
  7. unistd.h
  8. Abstract:
  9. This header contains standard system types and definitions.
  10. Author:
  11. Evan Green 5-Mar-2013
  12. --*/
  13. #ifndef _UNISTD_H
  14. #define _UNISTD_H
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. #include <sys/types.h>
  19. #include <stddef.h>
  20. #include <stdint.h>
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. //
  28. // Define the POSIX version this implementation (mostly) conforms to.
  29. //
  30. #define _POSIX_VERSION 200809L
  31. #define _POSIX2_VERSION 200809L
  32. #define _XOPEN_VERSION 700
  33. //
  34. // Define the POSIX constants for options and option groups.
  35. //
  36. #define _POSIX_BARRIERS 200809L
  37. #define _POSIX_CHOWN_RESTRICTED 1
  38. #define _POSIX_CLOCK_SELECTION 200809L
  39. #define _POSIX_CPUTIME -1
  40. #define _POSIX_FSYNC 200809L
  41. #define _POSIX_IPV6 200809L
  42. #define _POSIX_JOB_CONTROL 1
  43. #define _POSIX_MAPPED_FILES 200809L
  44. #define _POSIX_MEMLOCK -1
  45. #define _POSIX_MEMLOCK_RANGE -1
  46. #define _POSIX_MEMORY_PROTECTION 200809L
  47. #define _POSIX_MESSAGE_PASSING -1
  48. #define _POSIX_MONOTONIC_CLOCK 200809L
  49. #define _POSIX_NO_TRUNC 0
  50. #define _POSIX_PRIORITIZED_IO -1
  51. #define _POSIX_PRIORITY_SCHEDULING -1
  52. #define _POSIX_RAW_SOCKETS 200809L
  53. #define _POSIX_READER_WRITER_LOCKS 200809L
  54. #define _POSIX_REALTIME_SIGNALS 200809L
  55. #define _POSIX_REGEXP 1
  56. #define _POSIX_SAVED_IDS 1
  57. #define _POSIX_SEMAPHORES 200809L
  58. #define _POSIX_SHARED_MEMORY_OBJECTS 200809L
  59. #define _POSIX_SHELL 1
  60. #define _POSIX_SPAWN 200809L
  61. #define _POSIX_SPIN_LOCKS -1
  62. #define _POSIX_SPORADIC_SERVER -1
  63. #define _POSIX_SYNCHRONIZED_IO 200890L
  64. #define _POSIX_THREAD_ATTR_STACKADDR 200809L
  65. #define _POSIX_THREAD_ATTR_STACKSIZE 200809L
  66. #define _POSIX_THREAD_CPUTIME -1
  67. #define _POSIX_THREAD_PRIO_INHERIT -1
  68. #define _POSIX_THREAD_PRIO_PROTECT -1
  69. #define _POSIX_THREAD_PRIORITY_SCHEDULING -1
  70. #define _POSIX_THREAD_PROCESS_SHARED 200809L
  71. #define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
  72. #define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
  73. #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
  74. #define _POSIX_THREAD_SPORADIC_SERVER -1
  75. #define _POSIX_THREADS 200809L
  76. #define _POSIX_TIMEOUTS 200809L
  77. #define _POSIX_TIMERS 200809L
  78. #define _POSIX_TRACE -1
  79. #define _POSIX_TRACE_EVENT_FILTER -1
  80. #define _POSIX_TRACE_INHERIT -1
  81. #define _POSIX_TRACE_LOG -1
  82. #define _POSIX_TYPED_MEMORY_OBJECTS -1
  83. #if (__SIZEOF_POINTER__ == 8)
  84. #define _POSIX_V6_ILP32_OFF32 -1
  85. #define _POSIX_V6_ILP32_OFFBIG -1
  86. #define _POSIX_V6_LP64_OFF64 1
  87. #define _POSIX_V6_LPBIG_OFFBIG -1
  88. #define _POSIX_V7_ILP32_OFF32 -1
  89. #define _POSIX_V7_ILP32_OFFBIG -1
  90. #define _POSIX_V7_LP64_OFF64 1
  91. #define _POSIX_V7_LPBIG_OFFBIG -1
  92. #else
  93. #define _POSIX_V6_ILP32_OFF32 -1
  94. #define _POSIX_V6_ILP32_OFFBIG 1
  95. #define _POSIX_V6_LP64_OFF64 -1
  96. #define _POSIX_V6_LPBIG_OFFBIG -1
  97. #define _POSIX_V7_ILP32_OFF32 -1
  98. #define _POSIX_V7_ILP32_OFFBIG 1
  99. #define _POSIX_V7_LP64_OFF64 -1
  100. #define _POSIX_V7_LPBIG_OFFBIG -1
  101. #endif
  102. #define _POSIX2_C_BIND 200809L
  103. #define _POSIX2_C_DEV 200809L
  104. #define _POSIX2_CHAR_TERM 1
  105. #define _POSIX2_FORT_DEV -1
  106. #define _POSIX2_FORT_RUN -1
  107. #define _POSIX2_LOCALEDEF 200809L
  108. #define _POSIX2_PBS -1
  109. #define _POSIX2_PBS_ACCOUNTING -1
  110. #define _POSIX2_PBS_CHECKPOINT -1
  111. #define _POSIX2_PBS_LOCATE -1
  112. #define _POSIX2_PBS_MESSAGE -1
  113. #define _POSIX2_PBS_TRACK -1
  114. #define _POSIX2_SW_DEV 200809L
  115. #define _POSIX2_UPE 200809L
  116. #define _XOPEN_CRYPT 1
  117. #define _XOPEN_ENH_I18N 1
  118. #define _XOPEN_REALTIME -1
  119. #define _XOPEN_REALTIME_THREADS -1
  120. #define _XOPEN_SHM 1
  121. #define _XOPEN_STREAMS -1
  122. #define _XOPEN_UNIX 1
  123. #define _XOPEN_UUCP -1
  124. //
  125. // Define all libcrypt API functions to be imports unless otherwise specified.
  126. //
  127. #ifndef LIBCRYPT_API
  128. #define LIBCRYPT_API __DLLIMPORT
  129. #endif
  130. //
  131. // Define the value of a character that shall disable terminal special
  132. // character handling.
  133. //
  134. #define _POSIX_VDISABLE '\0'
  135. //
  136. // Define the standard file descriptors.
  137. //
  138. #define STDIN_FILENO 0
  139. #define STDOUT_FILENO 1
  140. #define STDERR_FILENO 2
  141. //
  142. // Define flags used in calls to "access" that specify whether a given path
  143. // is readable, writable, or executable. Also define a flag indicating if the
  144. // file exists at all. Note that these constants match up with the
  145. // EFFECTIVE_ACCESS_* definitions used by the kernel.
  146. //
  147. #define F_OK 0x00000000
  148. #define X_OK 0x00000001
  149. #define W_OK 0x00000002
  150. #define R_OK 0x00000004
  151. //
  152. // Define sysconf constants.
  153. //
  154. //
  155. // Determine the number of clock ticks per second for the clock_t type.
  156. //
  157. #define _SC_CLK_TCK 1
  158. //
  159. // Determine the size of a page on this system.
  160. //
  161. #define _SC_PAGE_SIZE 2
  162. #define _SC_PAGESIZE _SC_PAGE_SIZE
  163. //
  164. // Determine the maximum length of arguments to the exec functions.
  165. //
  166. #define _SC_ARG_MAX 3
  167. //
  168. // Determine the number of simultaneous processes per user ID.
  169. //
  170. #define _SC_CHILD_MAX 4
  171. //
  172. // Determine the maximum length of a hostname, not including the null
  173. // terminator, as returned by gethostname.
  174. //
  175. #define _SC_HOST_NAME_MAX 5
  176. //
  177. // Determine the maximum length of a login name, including the null terminator.
  178. //
  179. #define _SC_LOGIN_NAME_MAX 6
  180. //
  181. // Determine the maximum number of files that a process can have open at any
  182. // time.
  183. //
  184. #define _SC_OPEN_MAX 7
  185. //
  186. // Determine the maximum number of repeated occurrences of a BRE permitted by
  187. // regexec and regcomp.
  188. //
  189. #define _SC_RE_DUP_MAX 8
  190. //
  191. // Determine the maximum number of streams that a process can have open at any
  192. // time.
  193. //
  194. #define _SC_STREAM_MAX 9
  195. //
  196. // Determine the maximum number of symbolic links seen in a pathname before
  197. // resolution returns ELOOP.
  198. //
  199. #define _SC_SYMLOOP_MAX 10
  200. //
  201. // Determine the maximum length of a terminal device name, including the null
  202. // terminator.
  203. //
  204. #define _SC_TTY_NAME_MAX 11
  205. //
  206. // Determine the maximum number of bytes in a timezone name.
  207. //
  208. #define _SC_TZNAME_MAX 12
  209. //
  210. // Determine the year and month the POSIX.1 standard was approved in the
  211. // format YYYYMML. The value 199009 indicates the September 1990 revision.
  212. //
  213. #define _SC_VERSION 13
  214. //
  215. // Determine the maximum obase value accepted by the bc utility.
  216. //
  217. #define _SC_BC_BASE_MAX 14
  218. //
  219. // Determine the maximum value of elements permitted in an array by the bc
  220. // utility.
  221. //
  222. #define _SC_BC_DIM_MAX 15
  223. //
  224. // Determine the maximum scale value allowed by the bc utility.
  225. //
  226. #define _SC_BC_SCALE_MAX 16
  227. //
  228. // Determine the maximum length of a string accepted by the bc utility.
  229. //
  230. #define _SC_BC_STRING_MAX 17
  231. //
  232. // Determine the maximum number of weights that can be assigned to an entry
  233. // of the LC_COLLATE order keyword in the locale definition file.
  234. //
  235. #define _SC_COLL_WEIGHTS_MAX 18
  236. //
  237. // Determine the maximum number of expressions which can be nested within
  238. // parentheses by the expr utility.
  239. //
  240. #define _SC_EXPR_NEST_MAX 19
  241. //
  242. // Determine the maximum length of a utility's input line, either from standard
  243. // input or from a file. This includes space for a trailing newline.
  244. //
  245. //
  246. #define _SC_LINE_MAX 20
  247. //
  248. // Determine the version of the POSIX.2 standard in the format of YYYYMML.
  249. //
  250. #define _SC_2_VERSION 21
  251. //
  252. // Determine whether the POSIX.2 C language development facilities are
  253. // supported.
  254. //
  255. #define _SC_2_C_DEV 22
  256. //
  257. // Determine whether the POSIX.2 FORTRAN development utilities are supported.
  258. //
  259. #define _SC_2_FORT_DEV 23
  260. //
  261. // Determine whether the POSIX.2 FORTRAN runtime utilities are supported.
  262. //
  263. #define _SC_2_FORT_RUN 24
  264. //
  265. // Determine whether the POSIX.2 creation of locales via localedef is supported.
  266. //
  267. #define _SC_2_LOCALEDEF 25
  268. //
  269. // Determine whether the POSIX.2 software development utilities option is
  270. // supported.
  271. //
  272. #define _SC_2_SW_DEV 26
  273. //
  274. // Determine the total number of physical pages in the system.
  275. //
  276. #define _SC_PHYS_PAGES 27
  277. //
  278. // Determine the total number of physical pages in the system that are
  279. // currently allocated.
  280. //
  281. #define _SC_AVPHYS_PAGES 28
  282. //
  283. // Determine the number of processors configured.
  284. //
  285. #define _SC_NPROCESSORS_CONF 29
  286. //
  287. // Determine the number of processors online.
  288. //
  289. #define _SC_NPROCESSORS_ONLN 30
  290. //
  291. // Define the maximum size of getgrgid_r and getgrnam_r data buffers.
  292. //
  293. #define _SC_GETGR_R_SIZE_MAX 31
  294. //
  295. // Define the maximum size of getpwuid_r and getpwnam_r data buffers.
  296. //
  297. #define _SC_GETPW_R_SIZE_MAX 32
  298. //
  299. // Define the maximum number of groups in the system.
  300. //
  301. #define _SC_NGROUPS_MAX 33
  302. //
  303. // Determine whether POSIX thread barriers are supported.
  304. //
  305. #define _SC_BARRIERS 34
  306. //
  307. // Determine whether POSIX clock selection is supported.
  308. //
  309. #define _SC_CLOCK_SELECTION 35
  310. //
  311. // Determine whether the Process CPU-Time Clocks option is supported.
  312. //
  313. #define _SC_CPUTIME 36
  314. //
  315. // Determine whether the File Synchronization option is supported.
  316. //
  317. #define _SC_FSYNC 37
  318. //
  319. // Determine whether the IPv6 option is supported.
  320. //
  321. #define _SC_IPV6 38
  322. //
  323. // Determine whether job control is supported.
  324. //
  325. #define _SC_JOB_CONTROL 39
  326. //
  327. // Determine whether memory mapped files are supported.
  328. //
  329. #define _SC_MAPPED_FILES 40
  330. //
  331. // Determine whether the Process Memory Locking option is supported.
  332. //
  333. #define _SC_MEMLOCK 41
  334. //
  335. // Determine whether the Range Memory Locking option is supported.
  336. //
  337. #define _SC_MEMLOCK_RANGE 42
  338. //
  339. // Determine whether memory protection is supported.
  340. //
  341. #define _SC_MEMORY_PROTECTION 43
  342. //
  343. // Determine whether the Message Passing option is supported.
  344. //
  345. #define _SC_MESSAGE_PASSING 44
  346. //
  347. // Determine whether the the Monotonic Clock option is supported.
  348. //
  349. #define _SC_MONOTONIC_CLOCK 45
  350. //
  351. // Determine whether the Prioritized Input and Output option is supported.
  352. //
  353. #define _SC_PRIORITIZED_IO 46
  354. //
  355. // Determine whether the Process Scheduling opion is supported.
  356. //
  357. #define _SC_PRIORITY_SCHEDULING 47
  358. //
  359. // Determine whether the Raw Sockets options is supported.
  360. //
  361. #define _SC_RAW_SOCKETS 48
  362. //
  363. // Determine whether read-write locks are supported.
  364. //
  365. #define _SC_READER_WRITER_LOCKS 49
  366. //
  367. // Determine whether realtime signals are supported.
  368. //
  369. #define _SC_REALTIME_SIGNALS 50
  370. //
  371. // Determine whether regular expression handling is supported.
  372. //
  373. #define _SC_REGEXP 51
  374. //
  375. // Determine whether each process has a saved set-user-ID and a saved
  376. // set-group-ID.
  377. //
  378. #define _SC_SAVED_IDS 52
  379. //
  380. // Determine whether semaphores are supported.
  381. //
  382. #define _SC_SEMAPHORES 53
  383. //
  384. // Determine whether the Shared Memory Objects option is supported.
  385. //
  386. #define _SC_SHARED_MEMORY_OBJECTS 54
  387. //
  388. // Determine whether the POSIX shell is supported.
  389. //
  390. #define _SC_SHELL 55
  391. //
  392. // Determine whetherthe Spawn option is supported.
  393. //
  394. #define _SC_SPAWN 56
  395. //
  396. // Determine whether the Spin Locks options is supported.
  397. //
  398. #define _SC_SPIN_LOCKS 57
  399. //
  400. // Determine whether the Process Sporadic Server option is supported.
  401. //
  402. #define _SC_SPORADIC_SERVER 58
  403. //
  404. // Determine whether the Synchronized Input and Output option is supported.
  405. //
  406. #define _SC_SYNCHRONIZED_IO 59
  407. //
  408. // Determine whether the Thread Stack Address Attribute option is supported.
  409. //
  410. #define _SC_THREAD_ATTR_STACKADDR 60
  411. //
  412. // Determine whether the Thread Stack Size Attribute option is supported.
  413. //
  414. #define _SC_THREAD_ATTR_STACKSIZE 61
  415. //
  416. // Determine whether the Thread CPU-Time Clocks option is supported.
  417. //
  418. #define _SC_THREAD_CPUTIME 62
  419. //
  420. // Determine whether the Non-Robust Mutex Priority Inheritance option is
  421. // supported.
  422. //
  423. #define _SC_THREAD_PRIO_INHERIT 63
  424. //
  425. // Determine whether the Non-Robust Mutex Priority Protection option is
  426. // supported.
  427. //
  428. #define _SC_THREAD_PRIO_PROTECT 64
  429. //
  430. // Determine whether the Thread Execution Scheduilng option is supported.
  431. //
  432. #define _SC_THREAD_PRIORITY_SCHEDULING 65
  433. //
  434. // Determine whether the Thread Process-Shared Synchronization option is
  435. // supported.
  436. //
  437. #define _SC_THREAD_PROCESS_SHARED 66
  438. //
  439. // Determine whether the Robust Mutex Priority Inheritance option is supported.
  440. //
  441. #define _SC_THREAD_ROBUST_PRIO_INHERIT 67
  442. //
  443. // Determine whether the Robust Mutex Priority Protection option is supported.
  444. //
  445. #define _SC_THREAD_ROBUST_PRIO_PROTECT 68
  446. //
  447. // Determine whether thread-safe functions are supported.
  448. //
  449. #define _SC_THREAD_SAFE_FUNCTIONS 69
  450. //
  451. // Determine whether the Thread Sporadic Server option is supported.
  452. //
  453. #define _SC_THREAD_SPORADIC_SERVER 70
  454. //
  455. // Determine whether threads are supported.
  456. //
  457. #define _SC_THREADS 71
  458. //
  459. // Determine whether timeouts are supported.
  460. //
  461. #define _SC_TIMEOUTS 72
  462. //
  463. // Determine whether timers are supported.
  464. //
  465. #define _SC_TIMERS 73
  466. //
  467. // Determine whether the Trace option is supported.
  468. //
  469. #define _SC_TRACE 74
  470. //
  471. // Determine whether the Trace Event Filter option is supported.
  472. //
  473. #define _SC_TRACE_EVENT_FILTER 75
  474. //
  475. // Determine whether the Trace Inherit option is supported.
  476. //
  477. #define _SC_TRACE_INHERIT 76
  478. //
  479. // Determine whether the Trace Log option is supported.
  480. //
  481. #define _SC_TRACE_LOG 77
  482. //
  483. // Determine whether the Typed Memory Objects option is supported.
  484. //
  485. #define _SC_TYPED_MEMORY_OBJECTS 78
  486. //
  487. // Determine whether the C-language compilation environment has 32-bit int,
  488. // long, pointer, and off_t types.
  489. //
  490. #define _SC_V6_ILP32_OFF32 79
  491. //
  492. // Determine whether the C-language compilation environment has 32-bit int,
  493. // long, and pointer types, and an off_t type of at least 64-bits.
  494. //
  495. #define _SC_V6_ILP32_OFFBIG 80
  496. //
  497. // Determine whether the C-language compilation environment has 32-bit int and
  498. // 64-bit long, pointer, and off_t types.
  499. //
  500. #define _SC_V6_LP64_OFF64 81
  501. //
  502. // Determine whether the C-language compilation environment has an int type of
  503. // at least 32-bits and long, pointer, and off_t types of at least 64-bits.
  504. //
  505. #define _SC_V6_LPBIG_OFFBIG 82
  506. //
  507. // Determine whether the C-language compilation environment has 32-bit int,
  508. // long, pointer, and off_t types.
  509. //
  510. #define _SC_V7_ILP32_OFF32 83
  511. //
  512. // Determine whether the C-language compilation environment has 32-bit int,
  513. // long, and pointer types, and an off_t type of at least 64-bits.
  514. //
  515. #define _SC_V7_ILP32_OFFBIG 84
  516. //
  517. // Determine whether the C-language compilation environment has 32-bit int and
  518. // 64-bit long, pointer, and off_t types.
  519. //
  520. #define _SC_V7_LP64_OFF64 85
  521. //
  522. // Determine whether the C-language compilation environment has an int type of
  523. // at least 32-bits and long, pointer, and off_t types of at least 64-bits.
  524. //
  525. #define _SC_V7_LPBIG_OFFBIG 86
  526. //
  527. // Determine whether the C-Language Binding option is supported.
  528. //
  529. #define _SC_2_C_BIND 87
  530. //
  531. // Determine whether the Terminal Characteristics option is supported.
  532. //
  533. #define _SC_2_CHAR_TERM 88
  534. //
  535. // Determine whether the Batch Environment Services and Utilities option is
  536. // supported.
  537. //
  538. #define _SC_2_PBS 89
  539. //
  540. // Determine whether the Batch Accounting option is supported.
  541. //
  542. #define _SC_2_PBS_ACCOUNTING 90
  543. //
  544. // Determine whether the Batch Checkpoint/Restart option is supported.
  545. //
  546. #define _SC_2_PBS_CHECKPOINT 91
  547. //
  548. // Determine whether the Locate Batch Job Request option is supported.
  549. //
  550. #define _SC_2_PBS_LOCATE 92
  551. //
  552. // Determine whether the Batch Job Message Request option is supported.
  553. //
  554. #define _SC_2_PBS_MESSAGE 93
  555. //
  556. // Determine whether the Track Batch Job Request option is supported.
  557. //
  558. #define _SC_2_PBS_TRACK 94
  559. //
  560. // Determine whether the User Portability Utilities option is supported.
  561. //
  562. #define _SC_2_UPE 95
  563. //
  564. // Determine whether the X/Open Encryption Option Group is supported.
  565. //
  566. #define _SC_XOPEN_CRYPT 96
  567. //
  568. // Determine whether the Issue 4, Version 2 Enhanced Internationalization
  569. // Option Group is supported.
  570. //
  571. #define _SC_XOPEN_ENH_I18N 97
  572. //
  573. // Determine whether the X/Open Realtime Option Group is supported.
  574. //
  575. #define _SC_XOPEN_REALTIME 98
  576. //
  577. // Determine whether the X/Open Realtime Threads Option Group is supported.
  578. //
  579. #define _SC_XOPEN_REALTIME_THREADS 99
  580. //
  581. // Determine whether the Issue 4, Version 2 Shared Memory Option Group is
  582. // supported.
  583. //
  584. #define _SC_XOPEN_SHM 100
  585. //
  586. // Determine whether the XSI STREAMS Option Group is supported.
  587. //
  588. #define _SC_XOPEN_STREAMS 101
  589. //
  590. // Determine whether the XSI option is supported.
  591. //
  592. #define _SC_XOPEN_UNIX 102
  593. //
  594. // Determine whether the UUCP Utilities option is supported.
  595. //
  596. #define _SC_XOPEN_UUCP 103
  597. //
  598. // Determine the version of the X/Open Portability Guide.
  599. //
  600. #define _SC_XOPEN_VERSION 104
  601. //
  602. // Define pathconf and fpathconf constants.
  603. //
  604. //
  605. // When referring to a directory, the system supports the creation of symbolic
  606. // links within that directory.
  607. //
  608. #define _PC_2_SYMLINKS 1
  609. //
  610. // Get the minimum number of bytes of storage actually allocated for any
  611. // portion of a file.
  612. //
  613. #define _PC_ALLOC_SIZE_MIN 2
  614. //
  615. // Determine whether asynchronous I/O operations may be performed for the
  616. // associated file.
  617. //
  618. #define _PC_ASYNC_IO 3
  619. //
  620. // Determine whether the use of chown and fchown is restricted to a process
  621. // with appropriate privileges, and to changing the group ID of a file only to
  622. // the effective group ID of the process or to one of its supplementary group
  623. // IDs.
  624. //
  625. #define _PC_CHOWN_RESTRICTED 4
  626. //
  627. // Determine the minimum number of bits needed to represent, as a signed
  628. // integer, the maximum size of a regular file allowed in the specified
  629. // directory.
  630. //
  631. #define _PC_FILESIZEBITS 5
  632. //
  633. // Determine the maximum number of links to a single file.
  634. //
  635. #define _PC_LINK_MAX 6
  636. //
  637. // Determine the maximum number of bytes in a terminal canonical input line.
  638. //
  639. #define _PC_MAX_CANON 7
  640. //
  641. // Determine the minimum number of bytes for which space is available in the
  642. // terminal input queue. This is also the maximum number of bytes a conforming
  643. // application may require to be typed as input before reading them.
  644. //
  645. #define _PC_MAX_INPUT 8
  646. //
  647. // Determine the maximum number of bytes in a file name, not including the
  648. // null terminator.
  649. //
  650. #define _PC_NAME_MAX 9
  651. //
  652. // Determine whether pathname components longer than NAME_MAX generate an error.
  653. //
  654. #define _PC_NO_TRUNC 10
  655. //
  656. // Determine the minimum number of bytes in a path name, including the null
  657. // terminator.
  658. //
  659. #define _PC_PATH_MAX 11
  660. //
  661. // Determine the maximum number of bytes that is guaranteed to be atomic when
  662. // writing to a pipe.
  663. //
  664. #define _PC_PIPE_BUF 12
  665. //
  666. // Determine whether prioritized input or output operations may be performed
  667. // for the associated file.
  668. //
  669. #define _PC_PRIO_IO 13
  670. //
  671. // Determine the recommended increment for file transfer sizes between
  672. // POSIX_REC_MIN_XFER_SIZE and POSIX_REC_MAX_XFER_SIZE.
  673. //
  674. #define _PC_REC_INCR_XFER_SIZE 14
  675. //
  676. // Determine the minimum recommended transfer size.
  677. //
  678. #define _PC_REC_MIN_XFER_SIZE 15
  679. //
  680. // Determine the recommended transfer alignment.
  681. //
  682. #define _PC_REC_XFER_ALIGN 16
  683. //
  684. // Determine the maximum number of bytes in a symbolic link.
  685. //
  686. #define _PC_SYMLINK_MAX 17
  687. //
  688. // Determine whether synchronized input or output operations may be performed
  689. // for the associated file.
  690. //
  691. #define _PC_SYNC_IO 18
  692. //
  693. // Determine the value of a character that shall disable terminal special
  694. // character handling.
  695. //
  696. #define _PC_VDISABLE 19
  697. //
  698. // Define function values that can be passed to the lockf function.
  699. //
  700. //
  701. // Use this function to unlock a previously locked region.
  702. //
  703. #define F_ULOCK 0
  704. //
  705. // Use this function to lock a region for exclusive use.
  706. //
  707. #define F_LOCK 1
  708. //
  709. // Use this function to test and lock a region for exclusive use, without
  710. // blocking.
  711. //
  712. #define F_TLOCK 2
  713. //
  714. // Use this function to test a region for locks held by other processes.
  715. //
  716. #define F_TEST 3
  717. //
  718. // ------------------------------------------------------ Data Type Definitions
  719. //
  720. //
  721. // -------------------------------------------------------------------- Globals
  722. //
  723. //
  724. // Define the environment.
  725. //
  726. LIBC_API extern char **environ;
  727. //
  728. // Define some globals from getopt.h. See getopt.h for full descriptions of
  729. // each of these variables. The header getopt.h is not included in this file
  730. // because some declarations (like struct option) should not be included here.
  731. //
  732. LIBC_API extern char *optarg;
  733. LIBC_API extern int optind;
  734. LIBC_API extern int opterr;
  735. LIBC_API extern int optopt;
  736. LIBC_API extern int optreset;
  737. //
  738. // -------------------------------------------------------- Function Prototypes
  739. //
  740. LIBC_API
  741. int
  742. brk (
  743. void *Address
  744. );
  745. /*++
  746. Routine Description:
  747. This routine sets the current program break to the specified address.
  748. New programs should use malloc and free in favor of this deprecated
  749. legacy function. This function is likely to fail if any other memory
  750. functions such as malloc or free are used. Other functions, including the
  751. C library, may use malloc and free silently. This function is neither
  752. thread-safe nor reentrant.
  753. Arguments:
  754. Address - Supplies the new address of the program break.
  755. Return Value:
  756. 0 on success.
  757. -1 on failure, and errno is set to indicate the error.
  758. --*/
  759. LIBC_API
  760. void *
  761. sbrk (
  762. intptr_t Increment
  763. );
  764. /*++
  765. Routine Description:
  766. This routine increments the current program break by the given number of
  767. bytes. If the value is negative, the program break is decreased.
  768. New programs should use malloc and free in favor of this deprecated
  769. legacy function. This function is likely to fail if any other memory
  770. functions such as malloc or free are used. Other functions, including the
  771. C library, may use malloc and free silently. This function is neither
  772. thread-safe nor reentrant.
  773. Arguments:
  774. Increment - Supplies the amount to add or remove from the program break.
  775. Return Value:
  776. Returns the original program break address before this function changed it
  777. on success.
  778. (void *)-1 on failure, and errno is set to indicate the error.
  779. --*/
  780. LIBC_API
  781. int
  782. execl (
  783. const char *Path,
  784. const char *Argument0,
  785. ...
  786. );
  787. /*++
  788. Routine Description:
  789. This routine replaces the current process image with a new image.
  790. Arguments:
  791. Path - Supplies a pointer to a string containing the fully specified path
  792. of the file to execute.
  793. Argument0 - Supplies the first argument to execute, usually the same as
  794. the command name.
  795. ... - Supplies the arguments to the program. The argument list must be
  796. terminated with a NULL.
  797. Return Value:
  798. Does not return on success, the current process is gutted and replaced with
  799. the specified image.
  800. -1 on error, and the errno variable will be set to contain more information.
  801. --*/
  802. LIBC_API
  803. int
  804. execv (
  805. const char *Path,
  806. char *const Arguments[]
  807. );
  808. /*++
  809. Routine Description:
  810. This routine replaces the current process image with a new image.
  811. Arguments:
  812. Path - Supplies a pointer to a string containing the fully specified path
  813. of the file to execute.
  814. Arguments - Supplies an array of pointers to strings containing the
  815. arguments to pass to the program.
  816. Return Value:
  817. Does not return on success, the current process is gutted and replaced with
  818. the specified image.
  819. -1 on error, and the errno variable will be set to contain more information.
  820. --*/
  821. LIBC_API
  822. int
  823. execle (
  824. const char *Path,
  825. const char *Argument0,
  826. ...
  827. );
  828. /*++
  829. Routine Description:
  830. This routine replaces the current process image with a new image. The
  831. parameters to this function also include the environment variables to use.
  832. Arguments:
  833. Path - Supplies a pointer to a string containing the fully specified path
  834. of the file to execute.
  835. Argument0 - Supplies the first argument to the program, usually the same
  836. as the program name.
  837. ... - Supplies the arguments to the program. The argument list must be
  838. terminated with a NULL. After the NULL an array of strings representing
  839. the environment is expected (think of it like a final argument after
  840. the NULL in the form const char *envp[]).
  841. Return Value:
  842. Does not return on success, the current process is gutted and replaced with
  843. the specified image.
  844. -1 on error, and the errno variable will be set to contain more information.
  845. --*/
  846. LIBC_API
  847. int
  848. execve (
  849. const char *Path,
  850. char *const Arguments[],
  851. char *const Environment[]
  852. );
  853. /*++
  854. Routine Description:
  855. This routine replaces the current process image with a new image. The
  856. parameters to this function also include the environment variables to use.
  857. Arguments:
  858. Path - Supplies a pointer to a string containing the fully specified path
  859. of the file to execute.
  860. Arguments - Supplies an array of pointers to strings containing the
  861. arguments to pass to the program.
  862. Environment - Supplies an array of pointers to strings containing the
  863. environment variables to pass to the program.
  864. Return Value:
  865. Does not return on success, the current process is gutted and replaced with
  866. the specified image.
  867. -1 on error, and the errno variable will be set to contain more information.
  868. --*/
  869. LIBC_API
  870. int
  871. execlp (
  872. const char *File,
  873. const char *Argument0,
  874. ...
  875. );
  876. /*++
  877. Routine Description:
  878. This routine replaces the current process image with a new image. If the
  879. given file is found but of an unrecognized binary format, then a shell
  880. interpreter will be launched and passed the file.
  881. Arguments:
  882. File - Supplies a pointer to a string containing the name of the executable,
  883. which will be searched for on the PATH if the string does not contain a
  884. slash.
  885. Argument0 - Supplies the first argument to the program. Additional arguments
  886. follow in the ellipses. The argument list must be terminated with a
  887. NULL.
  888. ... - Supplies any remaining arguments.
  889. Return Value:
  890. Does not return on success, the current process is gutted and replaced with
  891. the specified image.
  892. -1 on error, and the errno variable will be set to contain more information.
  893. --*/
  894. LIBC_API
  895. int
  896. execvp (
  897. const char *File,
  898. char *const Arguments[]
  899. );
  900. /*++
  901. Routine Description:
  902. This routine replaces the current process image with a new image. If the
  903. given file is found but of an unrecognized binary format, then a shell
  904. interpreter will be launched and passed the file.
  905. Arguments:
  906. File - Supplies a pointer to a string containing the name of the executable,
  907. which will be searched for on the PATH if the string does not contain a
  908. slash.
  909. Arguments - Supplies an array of pointers to strings containing the
  910. arguments to pass to the program.
  911. Return Value:
  912. Does not return on success, the current process is gutted and replaced with
  913. the specified image.
  914. -1 on error, and the errno variable will be set to contain more information.
  915. --*/
  916. LIBC_API
  917. int
  918. execvpe (
  919. const char *File,
  920. char *const Arguments[],
  921. char *const Environment[]
  922. );
  923. /*++
  924. Routine Description:
  925. This routine replaces the current process image with a new image. The
  926. parameters to this function also include the environment variables to use.
  927. If the given file is found but of an unrecognized binary format, then a
  928. shell interpreter will be launched and passed the file.
  929. Arguments:
  930. File - Supplies a pointer to a string containing the name of the executable,
  931. which will be searched for on the PATH if the string does not contain a
  932. slash.
  933. Arguments - Supplies an array of pointers to strings containing the
  934. arguments to pass to the program.
  935. Environment - Supplies an array of pointers to strings containing the
  936. environment variables to pass to the program.
  937. Return Value:
  938. Does not return on success, the current process is gutted and replaced with
  939. the specified image.
  940. -1 on error, and the errno variable will be set to contain more information.
  941. --*/
  942. LIBC_API
  943. __NO_RETURN
  944. void
  945. _exit (
  946. int Status
  947. );
  948. /*++
  949. Routine Description:
  950. This routine terminates the current process. It does not call any routines
  951. registered to run upon exit.
  952. Arguments:
  953. Status - Supplies a status code to return to the parent program.
  954. Return Value:
  955. None. This routine does not return.
  956. --*/
  957. LIBC_API
  958. int
  959. close (
  960. int FileDescriptor
  961. );
  962. /*++
  963. Routine Description:
  964. This routine closes a file descriptor.
  965. Arguments:
  966. FileDescriptor - Supplies the file descriptor to close.
  967. Return Value:
  968. 0 on success.
  969. -1 if the file could not be closed properly. The state of the file
  970. descriptor is undefined, but in many cases is still open. The errno
  971. variable will be set to contain more detailed information.
  972. --*/
  973. LIBC_API
  974. int
  975. closefrom (
  976. int FileDescriptor
  977. );
  978. /*++
  979. Routine Description:
  980. This routine closes all file descriptors with a value greater than or
  981. equal to the given file descriptor.
  982. Arguments:
  983. FileDescriptor - Supplies the minimum file descriptor number.
  984. Return Value:
  985. 0 on success.
  986. -1 if a file descriptor could not be closed properly. The state of the file
  987. descriptor is undefined, but in many cases is still open. The errno
  988. variable will be set to contain more detailed information.
  989. --*/
  990. LIBC_API
  991. ssize_t
  992. read (
  993. int FileDescriptor,
  994. void *Buffer,
  995. size_t ByteCount
  996. );
  997. /*++
  998. Routine Description:
  999. This routine attempts to read the specifed number of bytes from the given
  1000. open file descriptor.
  1001. Arguments:
  1002. FileDescriptor - Supplies the file descriptor returned by the open function.
  1003. Buffer - Supplies a pointer to the buffer where the read bytes will be
  1004. returned.
  1005. ByteCount - Supplies the number of bytes to read.
  1006. Return Value:
  1007. Returns the number of bytes successfully read from the file.
  1008. -1 on failure, and errno will contain more information.
  1009. --*/
  1010. LIBC_API
  1011. ssize_t
  1012. pread (
  1013. int FileDescriptor,
  1014. void *Buffer,
  1015. size_t ByteCount,
  1016. off_t Offset
  1017. );
  1018. /*++
  1019. Routine Description:
  1020. This routine attempts to read the specifed number of bytes from the given
  1021. open file descriptor at a given offset. It does not change the current
  1022. file pointer.
  1023. Arguments:
  1024. FileDescriptor - Supplies the file descriptor returned by the open function.
  1025. Buffer - Supplies a pointer to the buffer where the read bytes will be
  1026. returned.
  1027. ByteCount - Supplies the number of bytes to read.
  1028. Offset - Supplies the offset from the start of the file to read from.
  1029. Return Value:
  1030. Returns the number of bytes successfully read from the file.
  1031. -1 on failure, and errno will contain more information.
  1032. --*/
  1033. LIBC_API
  1034. ssize_t
  1035. write (
  1036. int FileDescriptor,
  1037. const void *Buffer,
  1038. size_t ByteCount
  1039. );
  1040. /*++
  1041. Routine Description:
  1042. This routine attempts to write the specifed number of bytes to the given
  1043. open file descriptor.
  1044. Arguments:
  1045. FileDescriptor - Supplies the file descriptor returned by the open function.
  1046. Buffer - Supplies a pointer to the buffer containing the bytes to be
  1047. written.
  1048. ByteCount - Supplies the number of bytes to write.
  1049. Return Value:
  1050. Returns the number of bytes successfully written to the file.
  1051. -1 on failure, and errno will contain more information.
  1052. --*/
  1053. LIBC_API
  1054. ssize_t
  1055. pwrite (
  1056. int FileDescriptor,
  1057. const void *Buffer,
  1058. size_t ByteCount,
  1059. off_t Offset
  1060. );
  1061. /*++
  1062. Routine Description:
  1063. This routine attempts to write the specifed number of bytes to the given
  1064. open file descriptor at a given offset. It does not update the current
  1065. file position.
  1066. Arguments:
  1067. FileDescriptor - Supplies the file descriptor returned by the open function.
  1068. Buffer - Supplies a pointer to the buffer containing the bytes to be
  1069. written.
  1070. ByteCount - Supplies the number of bytes to write.
  1071. Offset - Supplies the offset from the start of the file to write to.
  1072. Return Value:
  1073. Returns the number of bytes successfully written to the file.
  1074. -1 on failure, and errno will contain more information.
  1075. --*/
  1076. LIBC_API
  1077. int
  1078. fsync (
  1079. int FileDescriptor
  1080. );
  1081. /*++
  1082. Routine Description:
  1083. This routine flushes all the data associated with the open file descriptor
  1084. to its corresponding backing device. It does not return until the data has
  1085. been flushed.
  1086. Arguments:
  1087. FileDescriptor - Supplies the file descriptor returned by the open function.
  1088. Return Value:
  1089. 0 on success.
  1090. -1 on failure, and the errno variable will be set to contain more
  1091. information.
  1092. --*/
  1093. LIBC_API
  1094. int
  1095. fdatasync (
  1096. int FileDescriptor
  1097. );
  1098. /*++
  1099. Routine Description:
  1100. This routine flushes all the data associated with the open file descriptor
  1101. to its corresponding backing device. It does not return until the data has
  1102. been flushed. It is similar to fsync but does not flush modified metadata
  1103. if that metadata is unimportant to retrieving the file later. For example,
  1104. last access and modified times wouldn't require a metadata flush, but file
  1105. size change would.
  1106. Arguments:
  1107. FileDescriptor - Supplies the file descriptor returned by the open function.
  1108. Return Value:
  1109. 0 on success.
  1110. -1 on failure, and the errno variable will be set to contain more
  1111. information.
  1112. --*/
  1113. LIBC_API
  1114. void
  1115. sync (
  1116. void
  1117. );
  1118. /*++
  1119. Routine Description:
  1120. This routine schedules a flush for all file system related data that is in
  1121. memory. Upon return, it is not guaranteed that the writing of the data is
  1122. complete.
  1123. Arguments:
  1124. None.
  1125. Return Value:
  1126. None.
  1127. --*/
  1128. LIBC_API
  1129. off_t
  1130. lseek (
  1131. int FileDescriptor,
  1132. off_t Offset,
  1133. int Whence
  1134. );
  1135. /*++
  1136. Routine Description:
  1137. This routine sets the file offset for the open file descriptor.
  1138. Arguments:
  1139. FileDescriptor - Supplies the file descriptor returned by the open function.
  1140. Offset - Supplies the offset from the reference location given in the
  1141. Whence argument.
  1142. Whence - Supplies the reference location to base the offset off of. Valid
  1143. value are:
  1144. SEEK_SET - The offset will be added to the the beginning of the file.
  1145. SEEK_CUR - The offset will be added to the current file position.
  1146. SEEK_END - The offset will be added to the end of the file.
  1147. Return Value:
  1148. Returns the resulting file offset after the operation.
  1149. -1 on failure, and errno will contain more information. The file offset
  1150. will remain unchanged.
  1151. --*/
  1152. LIBC_API
  1153. int
  1154. ftruncate (
  1155. int FileDescriptor,
  1156. off_t NewSize
  1157. );
  1158. /*++
  1159. Routine Description:
  1160. This routine sets the file size of the given file descriptor. If the new
  1161. size is smaller than the original size, then the remaining data will be
  1162. discarded. If the new size is larger than the original size, then the
  1163. extra space will be filled with zeroes.
  1164. Arguments:
  1165. FileDescriptor - Supplies the file descriptor whose size should be
  1166. modified.
  1167. NewSize - Supplies the new size of the file descriptor in bytes.
  1168. Return Value:
  1169. 0 on success.
  1170. -1 on failure. The errno variable will be set to indicate the error.
  1171. --*/
  1172. LIBC_API
  1173. int
  1174. truncate (
  1175. const char *Path,
  1176. off_t NewSize
  1177. );
  1178. /*++
  1179. Routine Description:
  1180. This routine sets the file size of the given file path. If the new size is
  1181. smaller than the original size, then the remaining data will be discarded.
  1182. If the new size is larger than the original size, then the extra space will
  1183. be filled with zeroes.
  1184. Arguments:
  1185. Path - Supplies a pointer to a null terminated string containing the path
  1186. of the file whose size should be changed.
  1187. NewSize - Supplies the new size of the file descriptor in bytes.
  1188. Return Value:
  1189. 0 on success.
  1190. -1 on failure. The errno variable will be set to indicate the error.
  1191. --*/
  1192. LIBC_API
  1193. int
  1194. pipe (
  1195. int FileDescriptors[2]
  1196. );
  1197. /*++
  1198. Routine Description:
  1199. This routine creates an anonymous pipe.
  1200. Arguments:
  1201. FileDescriptors - Supplies a pointer where handles will be returned
  1202. representing the read and write ends of the pipe.
  1203. Return Value:
  1204. 0 on success.
  1205. -1 on failure. The errno variable will be set to indicate the error.
  1206. --*/
  1207. LIBC_API
  1208. int
  1209. pipe2 (
  1210. int FileDescriptors[2],
  1211. int Flags
  1212. );
  1213. /*++
  1214. Routine Description:
  1215. This routine creates an anonymous pipe.
  1216. Arguments:
  1217. FileDescriptors - Supplies a pointer where handles will be returned
  1218. representing the read and write ends of the pipe.
  1219. Flags - Supplies a bitfield of open flags governing the behavior of the new
  1220. descriptors. Only O_NONBLOCK and O_CLOEXEC are honored.
  1221. Return Value:
  1222. 0 on success.
  1223. -1 on failure. The errno variable will be set to indicate the error.
  1224. --*/
  1225. LIBC_API
  1226. int
  1227. symlink (
  1228. const char *LinkTarget,
  1229. const char *LinkName
  1230. );
  1231. /*++
  1232. Routine Description:
  1233. This routine creates a symbolic link with the given name pointed at the
  1234. supplied target path.
  1235. Arguments:
  1236. LinkTarget - Supplies the location that the link points to.
  1237. LinkName - Supplies the path where the link should be created.
  1238. Return Value:
  1239. 0 on success.
  1240. -1 on failure, and errno will be set to contain more information.
  1241. --*/
  1242. LIBC_API
  1243. int
  1244. symlinkat (
  1245. const char *LinkTarget,
  1246. int Directory,
  1247. const char *LinkName
  1248. );
  1249. /*++
  1250. Routine Description:
  1251. This routine creates a symbolic link with the given name pointed at the
  1252. supplied target path.
  1253. Arguments:
  1254. LinkTarget - Supplies the location that the link points to.
  1255. Directory - Supplies an optional file descriptor. If the given path to the
  1256. link name is a relative path, the directory referenced by this
  1257. descriptor will be used as a starting point for path resolution. Supply
  1258. AT_FDCWD to use the working directory for relative paths.
  1259. LinkName - Supplies the path where the link should be created.
  1260. Return Value:
  1261. 0 on success.
  1262. -1 on failure, and errno will be set to contain more information.
  1263. --*/
  1264. LIBC_API
  1265. ssize_t
  1266. readlink (
  1267. const char *Path,
  1268. char *LinkDestinationBuffer,
  1269. size_t LinkDestinationBufferSize
  1270. );
  1271. /*++
  1272. Routine Description:
  1273. This routine reads the destination path of a symbolic link.
  1274. Arguments:
  1275. Path - Supplies a pointer to the symbolic link path.
  1276. LinkDestinationBuffer - Supplies a pointer to a buffer where the
  1277. destination of the link will be returned. A null terminator is not
  1278. written.
  1279. LinkDestinationBufferSize - Supplies the size of the link destination
  1280. buffer in bytes.
  1281. Return Value:
  1282. Returns the number of bytes placed into the buffer on success.
  1283. -1 on failure. The errno variable will be set to indicate the error, and
  1284. the buffer will remain unchanged.
  1285. --*/
  1286. LIBC_API
  1287. ssize_t
  1288. readlinkat (
  1289. int Directory,
  1290. const char *Path,
  1291. char *LinkDestinationBuffer,
  1292. size_t LinkDestinationBufferSize
  1293. );
  1294. /*++
  1295. Routine Description:
  1296. This routine reads the destination path of a symbolic link.
  1297. Arguments:
  1298. Directory - Supplies an optional file descriptor. If the given path
  1299. is a relative path, the directory referenced by this descriptor will
  1300. be used as a starting point for path resolution. Supply AT_FDCWD to
  1301. use the working directory for relative paths.
  1302. Path - Supplies a pointer to the symbolic link path.
  1303. LinkDestinationBuffer - Supplies a pointer to a buffer where the
  1304. destination of the link will be returned. A null terminator is not
  1305. written.
  1306. LinkDestinationBufferSize - Supplies the size of the link destination
  1307. buffer in bytes.
  1308. Return Value:
  1309. Returns the number of bytes placed into the buffer on success.
  1310. -1 on failure. The errno variable will be set to indicate the error, and
  1311. the buffer will remain unchanged.
  1312. --*/
  1313. LIBC_API
  1314. int
  1315. link (
  1316. const char *ExistingFile,
  1317. const char *LinkPath
  1318. );
  1319. /*++
  1320. Routine Description:
  1321. This routine creates a hard link to the given file.
  1322. Arguments:
  1323. ExistingFile - Supplies a pointer to a null-terminated string containing
  1324. the path to the file that already exists.
  1325. LinkPath - Supplies a pointer to a null-terminated string containing the
  1326. path of the new link to create.
  1327. Return Value:
  1328. 0 on success.
  1329. -1 on failure. The errno variable will be set to indicate the error.
  1330. --*/
  1331. LIBC_API
  1332. int
  1333. linkat (
  1334. int ExistingFileDirectory,
  1335. const char *ExistingFile,
  1336. int LinkPathDirectory,
  1337. const char *LinkPath,
  1338. int Flags
  1339. );
  1340. /*++
  1341. Routine Description:
  1342. This routine creates a hard link to the given file.
  1343. Arguments:
  1344. ExistingFileDirectory - Supplies an optional file descriptor. If the given
  1345. existing file path is a relative path, the directory referenced by this
  1346. descriptor will be used as a starting point for path resolution. Supply
  1347. AT_FDCWD to use the working directory for relative paths.
  1348. ExistingFile - Supplies a pointer to a null-terminated string containing
  1349. the path to the file that already exists.
  1350. LinkPathDirectory - Supplies an optional file descriptor. If the given new
  1351. link is a relative path, the directory referenced by this descriptor
  1352. will be used as a starting point for path resolution. Supply AT_FDCWD
  1353. to use the working directory for relative paths.
  1354. LinkPath - Supplies a pointer to a null-terminated string containing the
  1355. path of the new link to create.
  1356. Flags - Supplies AT_SYMLINK_FOLLOW if the routine should link to the
  1357. destination of the symbolic link if the existing file path is a
  1358. symbolic link. Supply 0 to create a link to the symbolic link itself.
  1359. Return Value:
  1360. 0 on success.
  1361. -1 on failure. The errno variable will be set to indicate the error.
  1362. --*/
  1363. LIBC_API
  1364. int
  1365. unlink (
  1366. const char *Path
  1367. );
  1368. /*++
  1369. Routine Description:
  1370. This routine attempts to delete the object at the given path. If the path
  1371. points to a directory, the directory must be empty. If the path points to
  1372. a file, the hard link count on the file is decremented. If the hard link
  1373. count reaches zero and no processes have the file open, the contents of the
  1374. file are destroyed. If processes have open handles to the file, the
  1375. destruction of the file contents are deferred until the last handle to the
  1376. old file is closed. If the path points to a symbolic link, the link itself
  1377. is removed and not the destination. The removal of the entry from the
  1378. directory is immediate.
  1379. Arguments:
  1380. Path - Supplies a pointer to a null terminated string containing the path
  1381. of the entry to remove.
  1382. Return Value:
  1383. 0 on success.
  1384. -1 on failure, and errno will be set to provide more details. In failure
  1385. cases, the directory will not be removed.
  1386. --*/
  1387. LIBC_API
  1388. int
  1389. unlinkat (
  1390. int Directory,
  1391. const char *Path,
  1392. int Flags
  1393. );
  1394. /*++
  1395. Routine Description:
  1396. This routine attempts to delete the object at the given path. If the path
  1397. points to a directory, the directory must be empty. If the path points to
  1398. a file, the hard link count on the file is decremented. If the hard link
  1399. count reaches zero and no processes have the file open, the contents of the
  1400. file are destroyed. If processes have open handles to the file, the
  1401. destruction of the file contents are deferred until the last handle to the
  1402. old file is closed. If the path points to a symbolic link, the link itself
  1403. is removed and not the destination. The removal of the entry from the
  1404. directory is immediate.
  1405. Arguments:
  1406. Directory - Supplies an optional file descriptor. If the given path
  1407. is a relative path, the directory referenced by this descriptor will
  1408. be used as a starting point for path resolution. Supply AT_FDCWD to
  1409. use the working directory for relative paths.
  1410. Path - Supplies a pointer to a null terminated string containing the path
  1411. of the entry to remove.
  1412. Flags - Supplies a bitfield of flags. Supply AT_REMOVEDIR to attempt to
  1413. remove a directory (and only a directory). Supply zero to attempt to
  1414. remove a non-directory.
  1415. Return Value:
  1416. 0 on success.
  1417. -1 on failure, and errno will be set to provide more details. In failure
  1418. cases, the directory will not be removed.
  1419. --*/
  1420. LIBC_API
  1421. int
  1422. dup (
  1423. int FileDescriptor
  1424. );
  1425. /*++
  1426. Routine Description:
  1427. This routine duplicates the given file descriptor.
  1428. Arguments:
  1429. FileDescriptor - Supplies the file descriptor to duplicate.
  1430. Return Value:
  1431. Returns the new file descriptor which represents a copy of the original
  1432. file descriptor.
  1433. -1 on failure, and errno will be set to contain more information.
  1434. --*/
  1435. LIBC_API
  1436. int
  1437. dup2 (
  1438. int FileDescriptor,
  1439. int CopyDescriptor
  1440. );
  1441. /*++
  1442. Routine Description:
  1443. This routine duplicates the given file descriptor to the destination
  1444. descriptor, closing the original destination descriptor file along the way.
  1445. Arguments:
  1446. FileDescriptor - Supplies the file descriptor to duplicate.
  1447. CopyDescriptor - Supplies the descriptor number of returned copy.
  1448. Return Value:
  1449. Returns the new file descriptor which represents a copy of the original,
  1450. which is also equal to the input copy descriptor parameter.
  1451. -1 on failure, and errno will be set to contain more information.
  1452. --*/
  1453. LIBC_API
  1454. int
  1455. dup3 (
  1456. int FileDescriptor,
  1457. int CopyDescriptor,
  1458. int Flags
  1459. );
  1460. /*++
  1461. Routine Description:
  1462. This routine duplicates the given file descriptor to the destination
  1463. descriptor, closing the original destination descriptor file along the way.
  1464. Arguments:
  1465. FileDescriptor - Supplies the file descriptor to duplicate.
  1466. CopyDescriptor - Supplies the descriptor number of returned copy. If this
  1467. is equal to the original file descriptor, then the call fails with
  1468. EINVAL.
  1469. Flags - Supplies O_* open flags governing the new descriptor. Only
  1470. O_CLOEXEC is permitted.
  1471. Return Value:
  1472. Returns the new file descriptor which represents a copy of the original,
  1473. which is also equal to the input copy descriptor parameter.
  1474. -1 on failure, and errno will be set to contain more information.
  1475. --*/
  1476. LIBC_API
  1477. int
  1478. lockf (
  1479. int FileDescriptor,
  1480. int Function,
  1481. off_t Size
  1482. );
  1483. /*++
  1484. Routine Description:
  1485. This routine locks or unlocks sections of a file with advisory-mode locks.
  1486. All locks for a process are removed when the process terminates. Record
  1487. locking is supported at least for regular files, and may be supported for
  1488. other file types.
  1489. Arguments:
  1490. FileDescriptor - Supplies the file descriptor to query. To establish a
  1491. lock, the given file descriptor must be opened with O_WRONLY or O_RDWR.
  1492. Function - Supplies the action to be taken. Valid values are:
  1493. F_ULOCK - Unlocks a locked section.
  1494. F_LOCK - Locks a section for exclusive use (blocking if already locked).
  1495. F_TLOCK - Test and lock for exclusive use, not blocking.
  1496. F_TEST - Test for a section of locks by other processes.
  1497. Size - Supplies the number of contiguous bytes to be locked or unlocked.
  1498. The section to be locked or unlocked starts at the current offset in
  1499. the file and extends forward for a positve size or backwards for a
  1500. negative size (the preceding bytes up to but not including the current
  1501. offset). If size is 0, the section from the current offset through the
  1502. largest possible offset shall be locked. Locks may exist past the
  1503. current end of file.
  1504. Return Value:
  1505. 0 on success.
  1506. -1 on error, and errno will be set to contain more information. The errno
  1507. variable may be set to the following values:
  1508. EACCES or EAGAIN if the function argument is F_TLOCK or F_TEST and the
  1509. section is already locked by another process.
  1510. EDEADLK if the function argument is F_LOCK and a deadlock is detected.
  1511. EINVAL if the function is valid or the size plus the current offset is less
  1512. than zero.
  1513. EOVERFLOW if the range cannot properly be represented in an off_t.
  1514. --*/
  1515. LIBC_API
  1516. int
  1517. isatty (
  1518. int FileDescriptor
  1519. );
  1520. /*++
  1521. Routine Description:
  1522. This routine determines if the given file descriptor is backed by an
  1523. interactive terminal device or not.
  1524. Arguments:
  1525. FileDescriptor - Supplies the file descriptor to query.
  1526. Return Value:
  1527. 1 if the given file descriptor is backed by a terminal device.
  1528. 0 on error or if the file descriptor is not a terminal device. On error,
  1529. the errno variable will be set to give more details.
  1530. --*/
  1531. LIBC_API
  1532. int
  1533. rmdir (
  1534. const char *Path
  1535. );
  1536. /*++
  1537. Routine Description:
  1538. This routine attempts to unlink a directory. The directory must be empty or
  1539. the operation will fail.
  1540. Arguments:
  1541. Path - Supplies a pointer to a null terminated string containing the path
  1542. of the directory to remove.
  1543. Return Value:
  1544. 0 on success.
  1545. -1 on failure, and errno will be set to provide more details. In failure
  1546. cases, the directory will not be removed.
  1547. --*/
  1548. LIBC_API
  1549. char *
  1550. getcwd (
  1551. char *Buffer,
  1552. size_t BufferSize
  1553. );
  1554. /*++
  1555. Routine Description:
  1556. This routine returns a pointer to a null terminated string containing the
  1557. path to the current working directory.
  1558. Arguments:
  1559. Buffer - Supplies a pointer to a buffer where the string should be returned.
  1560. If NULL is supplied, then malloc will be used to allocate a buffer of
  1561. the appropriate size, and it is therefore the caller's responsibility
  1562. to free this memory.
  1563. BufferSize - Supplies the size of the buffer, in bytes.
  1564. Return Value:
  1565. Returns a pointer to a string containing the current working directory on
  1566. success.
  1567. NULL on failure. Errno will contain more information.
  1568. --*/
  1569. LIBC_API
  1570. int
  1571. chdir (
  1572. const char *Path
  1573. );
  1574. /*++
  1575. Routine Description:
  1576. This routine changes the current working directory (the starting point for
  1577. all paths that don't begin with a path separator).
  1578. Arguments:
  1579. Path - Supplies a pointer to the null terminated string containing the
  1580. path of the new working directory.
  1581. Return Value:
  1582. 0 on success.
  1583. -1 on failure, and errno will be set to provide more details. On failure,
  1584. the current working directory will not be changed.
  1585. --*/
  1586. LIBC_API
  1587. int
  1588. fchdir (
  1589. int FileDescriptor
  1590. );
  1591. /*++
  1592. Routine Description:
  1593. This routine changes the current working directory (the starting point for
  1594. all paths that don't begin with a path separator) using an already open
  1595. file descriptor to that directory.
  1596. Arguments:
  1597. FileDescriptor - Supplies the open file handle to the directory to change
  1598. to.
  1599. Return Value:
  1600. 0 on success.
  1601. -1 on failure, and errno will be set to provide more details. On failure,
  1602. the current working directory will not be changed.
  1603. --*/
  1604. LIBC_API
  1605. int
  1606. chroot (
  1607. const char *Path
  1608. );
  1609. /*++
  1610. Routine Description:
  1611. This routine changes the current root directory. The working directory is
  1612. not changed. The caller must have sufficient privileges to change root
  1613. directories.
  1614. Arguments:
  1615. Path - Supplies a pointer to the null terminated string containing the
  1616. path of the new root directory.
  1617. Return Value:
  1618. 0 on success.
  1619. -1 on failure, and errno will be set to provide more details. On failure,
  1620. the current root directory will not be changed. Errno may be set to the
  1621. following values, among others:
  1622. EACCES if search permission is denied on a component of the path prefix.
  1623. EPERM if the caller has insufficient privileges.
  1624. --*/
  1625. LIBC_API
  1626. int
  1627. fchroot (
  1628. int FileDescriptor
  1629. );
  1630. /*++
  1631. Routine Description:
  1632. This routine changes the current root directory using an already open file
  1633. descriptor to that directory. The caller must have sufficient privileges
  1634. to change root directories.
  1635. Arguments:
  1636. FileDescriptor - Supplies the open file handle to the directory to change
  1637. to.
  1638. Return Value:
  1639. 0 on success.
  1640. -1 on failure, and errno will be set to provide more details. On failure,
  1641. the current root directory will not be changed.
  1642. --*/
  1643. LIBC_API
  1644. int
  1645. fchown (
  1646. int FileDescriptor,
  1647. uid_t Owner,
  1648. gid_t Group
  1649. );
  1650. /*++
  1651. Routine Description:
  1652. This routine sets the file owner and group of the file opened with the
  1653. given file descriptor.
  1654. Arguments:
  1655. FileDescriptor - Supplies the file descriptor whose owner and group should
  1656. be modified.
  1657. Owner - Supplies the new owner of the file.
  1658. Group - Supplies the new group of the file.
  1659. Return Value:
  1660. 0 on success.
  1661. -1 on failure. The errno variable will be set to indicate the error.
  1662. --*/
  1663. LIBC_API
  1664. int
  1665. chown (
  1666. const char *Path,
  1667. uid_t Owner,
  1668. gid_t Group
  1669. );
  1670. /*++
  1671. Routine Description:
  1672. This routine sets the file owner of the given path.
  1673. Arguments:
  1674. Path - Supplies a pointer to the path whose owner should be changed.
  1675. Owner - Supplies the new owner of the path.
  1676. Group - Supplies the new owner group of the path.
  1677. Return Value:
  1678. 0 on success.
  1679. -1 on failure, and errno will be set to contain more information.
  1680. --*/
  1681. LIBC_API
  1682. int
  1683. lchown (
  1684. const char *Path,
  1685. uid_t Owner,
  1686. gid_t Group
  1687. );
  1688. /*++
  1689. Routine Description:
  1690. This routine sets the file owner of the given path. The only difference
  1691. between this routine and chown is that if the path given to this routine
  1692. refers to a symbolic link, the operation will be done on the link itself
  1693. (as opposed to the destination of the link, which is what chown would
  1694. operate on).
  1695. Arguments:
  1696. Path - Supplies a pointer to the path whose owner should be changed.
  1697. Owner - Supplies the new owner of the path.
  1698. Group - Supplies the new owner group of the path.
  1699. Return Value:
  1700. 0 on success.
  1701. -1 on failure, and errno will be set to contain more information.
  1702. --*/
  1703. LIBC_API
  1704. int
  1705. fchownat (
  1706. int Directory,
  1707. const char *Path,
  1708. uid_t Owner,
  1709. gid_t Group,
  1710. int Flags
  1711. );
  1712. /*++
  1713. Routine Description:
  1714. This routine sets the file owner of the given path.
  1715. Arguments:
  1716. Directory - Supplies an optional file descriptor. If the given path
  1717. is a relative path, the directory referenced by this descriptor will
  1718. be used as a starting point for path resolution. Supply AT_FDCWD to
  1719. use the working directory for relative paths.
  1720. Path - Supplies a pointer to the path whose owner should be changed.
  1721. Owner - Supplies the new owner of the path.
  1722. Group - Supplies the new owner group of the path.
  1723. Flags - Supplies AT_SYMLINK_NOFOLLOW if the routine should modify
  1724. information for the symbolic link itself, or 0 if the call should
  1725. follow a symbolic link at the destination.
  1726. Return Value:
  1727. 0 on success.
  1728. -1 on failure, and errno will be set to contain more information.
  1729. --*/
  1730. LIBC_API
  1731. pid_t
  1732. getpid (
  1733. void
  1734. );
  1735. /*++
  1736. Routine Description:
  1737. This routine returns the current process identifier.
  1738. Arguments:
  1739. None.
  1740. Return Value:
  1741. Returns the process identifier.
  1742. --*/
  1743. LIBC_API
  1744. pid_t
  1745. getppid (
  1746. void
  1747. );
  1748. /*++
  1749. Routine Description:
  1750. This routine returns the current process' parent process identifier.
  1751. Arguments:
  1752. None.
  1753. Return Value:
  1754. Returns the parent process identifier.
  1755. --*/
  1756. LIBC_API
  1757. pid_t
  1758. getpgid (
  1759. pid_t ProcessId
  1760. );
  1761. /*++
  1762. Routine Description:
  1763. This routine returns the process group identifier of the process with
  1764. the given ID, or the calling process.
  1765. Arguments:
  1766. ProcessId - Supplies the process ID to return the process group for. Supply
  1767. 0 to return the process group ID of the calling process.
  1768. Return Value:
  1769. Returns the process group ID of the given process (or the current process).
  1770. (pid_t)-1 and errno will be set to EPERM if the desired process is out of
  1771. this session and the implementation doesn't allow cross session requests,
  1772. ESRCH if no such process exists, or EINVAL if the pid argument is invalid.
  1773. --*/
  1774. LIBC_API
  1775. pid_t
  1776. getpgrp (
  1777. void
  1778. );
  1779. /*++
  1780. Routine Description:
  1781. This routine returns the process group identifier of the calling process.
  1782. Arguments:
  1783. None.
  1784. Return Value:
  1785. Returns the process group ID of the calling process.
  1786. --*/
  1787. LIBC_API
  1788. int
  1789. setpgid (
  1790. pid_t ProcessId,
  1791. pid_t ProcessGroupId
  1792. );
  1793. /*++
  1794. Routine Description:
  1795. This routine joins an existing process group or creates a new process group
  1796. within the session of the calling process. The process group ID of a
  1797. session leader will not change.
  1798. Arguments:
  1799. ProcessId - Supplies the process ID of the process to put in a new process
  1800. group. Supply 0 to use the current process.
  1801. ProcessGroupId - Supplies the new process group to put the process in.
  1802. Supply zero to set the process group ID to the same numerical value as
  1803. the specified process ID.
  1804. Return Value:
  1805. 0 on success.
  1806. -1 on failure and errno will be set to contain more information.
  1807. --*/
  1808. LIBC_API
  1809. pid_t
  1810. setpgrp (
  1811. void
  1812. );
  1813. /*++
  1814. Routine Description:
  1815. This routine sets the process group ID of the calling process to the
  1816. process ID of the calling process. This routine has no effect if the
  1817. calling process is a session leader.
  1818. Arguments:
  1819. None.
  1820. Return Value:
  1821. Returns the process group ID of the calling process.
  1822. --*/
  1823. LIBC_API
  1824. pid_t
  1825. getsid (
  1826. pid_t ProcessId
  1827. );
  1828. /*++
  1829. Routine Description:
  1830. This routine returns the process group ID of the process that is the
  1831. session leader of the given process. If the given parameter is 0, then
  1832. the current process ID is used as the parameter.
  1833. Arguments:
  1834. ProcessId - Supplies a process ID of the process whose session leader
  1835. should be returned.
  1836. Return Value:
  1837. Returns the process group ID of the session leader of the specified process.
  1838. -1 on failure, and errno will be set to contain more information.
  1839. --*/
  1840. LIBC_API
  1841. pid_t
  1842. setsid (
  1843. void
  1844. );
  1845. /*++
  1846. Routine Description:
  1847. This routine creates a new session if the calling process is not a
  1848. process group leader. The calling process will be the session leader of
  1849. the new session, and will be the process group leader of a new process
  1850. group, and will have no controlling terminal. The process group ID of the
  1851. calling process will be set equal to the process ID of the calling process.
  1852. The calling process will be the only process in the new process group and
  1853. the only process in the new session.
  1854. Arguments:
  1855. None.
  1856. Return Value:
  1857. Returns the value of the new process group ID of the calling process.
  1858. -1 on failure, and errno will be set to contain more information.
  1859. --*/
  1860. LIBC_API
  1861. pid_t
  1862. fork (
  1863. void
  1864. );
  1865. /*++
  1866. Routine Description:
  1867. This routine creates a new process by copying the existing process.
  1868. Arguments:
  1869. None.
  1870. Return Value:
  1871. Returns 0 to the child process.
  1872. Returns the process ID of the child process to the parent process.
  1873. Returns -1 to the parent process on error, and the errno variable will be
  1874. set to provide more information about the error.
  1875. --*/
  1876. LIBC_API
  1877. uid_t
  1878. getuid (
  1879. void
  1880. );
  1881. /*++
  1882. Routine Description:
  1883. This routine returns the current real user ID.
  1884. Arguments:
  1885. None.
  1886. Return Value:
  1887. Returns the real user ID.
  1888. --*/
  1889. LIBC_API
  1890. gid_t
  1891. getgid (
  1892. void
  1893. );
  1894. /*++
  1895. Routine Description:
  1896. This routine returns the current real group ID.
  1897. Arguments:
  1898. None.
  1899. Return Value:
  1900. Returns the real group ID.
  1901. --*/
  1902. LIBC_API
  1903. uid_t
  1904. geteuid (
  1905. void
  1906. );
  1907. /*++
  1908. Routine Description:
  1909. This routine returns the current effective user ID, which represents the
  1910. privilege level with which this process can perform operations. Normally
  1911. this is the same as the real user ID, but binaries with the setuid
  1912. permission bit set the effective user ID to their own when they're run.
  1913. Arguments:
  1914. None.
  1915. Return Value:
  1916. Returns the effective user ID.
  1917. --*/
  1918. LIBC_API
  1919. gid_t
  1920. getegid (
  1921. void
  1922. );
  1923. /*++
  1924. Routine Description:
  1925. This routine returns the current effective group ID, which represents the
  1926. privilege level with which this process can perform operations. Normally
  1927. this is the same as the real group ID, but binaries with the setgid
  1928. permission bit set the effective group ID to their own when they're run.
  1929. Arguments:
  1930. None.
  1931. Return Value:
  1932. Returns the effective group ID.
  1933. --*/
  1934. LIBC_API
  1935. int
  1936. setuid (
  1937. uid_t UserId
  1938. );
  1939. /*++
  1940. Routine Description:
  1941. This routine sets the real user ID, effective user ID, and saved
  1942. set-user-ID of the calling process to the given user ID. This only occurs
  1943. if the process has the appropriate privileges to do this. If the process
  1944. does not have appropriate privileges but the given user ID is equal to the
  1945. real user ID or the saved set-user-ID, then this routine sets the effective
  1946. user ID to the given user ID; the real user ID and saved set-user-ID remain
  1947. unchanged.
  1948. Arguments:
  1949. UserId - Supplies the user ID to change to.
  1950. Return Value:
  1951. 0 on success.
  1952. -1 on failure, and errno will be set to contain more information. Common
  1953. errors include EINVAL if the user ID is not valid, and EPERM if the
  1954. process does not have appropriate privileges and the given ID does not
  1955. match the real user ID or saved set-user-ID.
  1956. --*/
  1957. LIBC_API
  1958. int
  1959. setgid (
  1960. gid_t GroupId
  1961. );
  1962. /*++
  1963. Routine Description:
  1964. This routine sets the real group ID, effective group ID, and saved
  1965. set-group-ID of the calling process to the given group ID. This only occurs
  1966. if the process has the appropriate privileges to do this. If the process
  1967. does not have appropriate privileges but the given group ID is equal to the
  1968. real group ID or the saved set-group-ID, then this routine sets the
  1969. effective group ID to the given group ID; the real group ID and saved
  1970. set-group-ID remain unchanged.
  1971. Arguments:
  1972. GroupId - Supplies the group ID to change to.
  1973. Return Value:
  1974. 0 on success.
  1975. -1 on failure, and errno will be set to contain more information. Common
  1976. errors include EINVAL if the group ID is not valid, and EPERM if the
  1977. process does not have appropriate privileges and the given ID does not
  1978. match the real group ID or saved set-group-ID.
  1979. --*/
  1980. LIBC_API
  1981. int
  1982. seteuid (
  1983. uid_t UserId
  1984. );
  1985. /*++
  1986. Routine Description:
  1987. This routine sets the effective user ID of the calling process to the given
  1988. user ID. The real user ID and saved set-user-ID remain unchanged. This only
  1989. occurs if the process has appropriate privileges, or if the real user ID
  1990. is equal to the saved set-user-ID.
  1991. Arguments:
  1992. UserId - Supplies the effective user ID to change to.
  1993. Return Value:
  1994. 0 on success.
  1995. -1 on failure, and errno will be set to contain more information. Common
  1996. errors include EINVAL if the user ID is not valid, and EPERM if the
  1997. process does not have appropriate privileges and the given ID does not
  1998. match the real user ID or saved set-user-ID.
  1999. --*/
  2000. LIBC_API
  2001. int
  2002. setegid (
  2003. gid_t GroupId
  2004. );
  2005. /*++
  2006. Routine Description:
  2007. This routine sets the effective group ID of the calling process to the
  2008. given group ID. The real group ID and saved set-group-ID remain unchanged.
  2009. This only occurs if the process has appropriate privileges, or if the real
  2010. group ID is equal to the saved set-group-ID.
  2011. Arguments:
  2012. GroupId - Supplies the effective group ID to change to.
  2013. Return Value:
  2014. 0 on success.
  2015. -1 on failure, and errno will be set to contain more information. Common
  2016. errors include EINVAL if the group ID is not valid, and EPERM if the
  2017. process does not have appropriate privileges and the given ID does not
  2018. match the real group ID or saved set-group-ID.
  2019. --*/
  2020. LIBC_API
  2021. int
  2022. setreuid (
  2023. uid_t RealUserId,
  2024. uid_t EffectiveUserId
  2025. );
  2026. /*++
  2027. Routine Description:
  2028. This routine sets the real and/or effective user IDs of the current process
  2029. to the given values. This only occurs if the process has appropriate
  2030. privileges. Unprivileged processes may only set the effective user ID to
  2031. the real or saved user IDs. Unprivileged users may only set the real
  2032. group ID to the saved or effective user IDs. If the real user ID is being
  2033. set, or the effective user ID is being set to something other than the
  2034. previous real user ID, then the saved user ID is also set to the new
  2035. effective user ID.
  2036. Arguments:
  2037. RealUserId - Supplies the real user ID to change to. If -1 is supplied, the
  2038. real user ID will not be changed.
  2039. EffectiveUserId - Supplies the effective user ID to change to. If -1 is
  2040. supplied, the effective user ID will not be changed.
  2041. Return Value:
  2042. 0 on success.
  2043. -1 on failure, and errno will be set to contain more information. Common
  2044. errors include EINVAL if a user ID is not valid, and EPERM if the
  2045. process does not have appropriate privileges and the given effective ID
  2046. does not match the real user ID or saved set-user-ID.
  2047. --*/
  2048. LIBC_API
  2049. int
  2050. setregid (
  2051. gid_t RealGroupId,
  2052. gid_t EffectiveGroupId
  2053. );
  2054. /*++
  2055. Routine Description:
  2056. This routine sets the real and/or effective group IDs of the current process
  2057. to the given values. This only occurs if the process has appropriate
  2058. privileges. Unprivileged processes may only set the effective group ID to
  2059. the real or saved group IDs. Unprivileged users may only set the real
  2060. group ID to the saved or effective group IDs. If the real group ID is being
  2061. set, or the effective group ID is being set to something other than the
  2062. previous real group ID, then the saved group ID is also set to the new
  2063. effective group ID.
  2064. Arguments:
  2065. RealGroupId - Supplies the real group ID to change to. If -1 is supplied,
  2066. the real group ID will not be changed.
  2067. EffectiveGroupId - Supplies the effective group ID to change to. If -1 is
  2068. supplied, the effective group ID will not be changed.
  2069. Return Value:
  2070. 0 on success.
  2071. -1 on failure, and errno will be set to contain more information. Common
  2072. errors include EINVAL if a group ID is not valid, and EPERM if the
  2073. process does not have appropriate privileges and the given effective ID
  2074. does not match the real group ID or saved set-group-ID.
  2075. --*/
  2076. LIBC_API
  2077. int
  2078. setresuid (
  2079. uid_t RealUserId,
  2080. uid_t EffectiveUserId,
  2081. uid_t SavedUserId
  2082. );
  2083. /*++
  2084. Routine Description:
  2085. This routine sets the real, effective, and saved user IDs of the calling
  2086. thread. A unprivileged process may set each one of these to one of the
  2087. current real, effective, or saved user ID. A process with the setuid
  2088. permission may set these to any values.
  2089. Arguments:
  2090. RealUserId - Supplies the real user ID to set, or -1 to leave the value
  2091. unchanged.
  2092. EffectiveUserId - Supplies the effective user ID to set, or -1 to leave the
  2093. value unchanged.
  2094. SavedUserId - Supplies the saved user ID to set, or -1 to leave the value
  2095. unchanged.
  2096. Return Value:
  2097. 0 on success.
  2098. -1 on failure, and errno will be set to contain more information. This may
  2099. fail even for root, so the return value must always be checked.
  2100. --*/
  2101. LIBC_API
  2102. int
  2103. setresgid (
  2104. gid_t RealGroupId,
  2105. gid_t EffectiveGroupId,
  2106. gid_t SavedGroupId
  2107. );
  2108. /*++
  2109. Routine Description:
  2110. This routine sets the real, effective, and saved group IDs of the calling
  2111. thread. A unprivileged process may set each one of these to one of the
  2112. current real, effective, or saved group ID. A process with the setuid
  2113. permission may set these to any values.
  2114. Arguments:
  2115. RealGroupId - Supplies the real group ID to set, or -1 to leave the value
  2116. unchanged.
  2117. EffectiveGroupId - Supplies the effective group ID to set, or -1 to leave
  2118. the value unchanged.
  2119. SavedGroupId - Supplies the saved group ID to set, or -1 to leave the value
  2120. unchanged.
  2121. Return Value:
  2122. 0 on success.
  2123. -1 on failure, and errno will be set to contain more information. This may
  2124. fail even for root, so the return value must always be checked.
  2125. --*/
  2126. LIBC_API
  2127. int
  2128. getgroups (
  2129. int ElementCount,
  2130. gid_t GroupList[]
  2131. );
  2132. /*++
  2133. Routine Description:
  2134. This routine returns the array of supplementary groups that the current
  2135. user belongs to.
  2136. Arguments:
  2137. ElementCount - Supplies the size (in elements) of the supplied group list
  2138. buffer.
  2139. GroupList - Supplies a buffer where the user's supplementary groups will
  2140. be returned.
  2141. Return Value:
  2142. Returns the number of supplementary groups that the current user belongs to.
  2143. The full count is returned even if the element count is less than that so
  2144. that the caller can regroup (get it) and try again if the buffer allocated
  2145. was too small.
  2146. -1 on failure, and errno will be set to contain more information.
  2147. --*/
  2148. LIBC_API
  2149. char *
  2150. getlogin (
  2151. void
  2152. );
  2153. /*++
  2154. Routine Description:
  2155. This routine returns a pointer to a string containing the user name
  2156. associated by the login activity with the controlling terminal of the
  2157. current process. This routine is neither reentrant nor thread safe.
  2158. Arguments:
  2159. None.
  2160. Return Value:
  2161. Returns a pointer to a buffer containing the name of the logged in user.
  2162. This data may be overwritten by a subsequent call to this function.
  2163. NULL on failure, and errno will be set to contain more information.
  2164. --*/
  2165. LIBC_API
  2166. int
  2167. getlogin_r (
  2168. char *Buffer,
  2169. size_t BufferSize
  2170. );
  2171. /*++
  2172. Routine Description:
  2173. This routine returns a pointer to a string containing the user name
  2174. associated by the login activity with the controlling terminal of the
  2175. current process. This routine is thread safe and reentrant.
  2176. Arguments:
  2177. Buffer - Supplies a pointer to the buffer where the login name will be
  2178. returned.
  2179. BufferSize - Supplies the size of the supplied buffer in bytes.
  2180. Return Value:
  2181. 0 on success.
  2182. Returns an error number on failure.
  2183. --*/
  2184. LIBC_API
  2185. int
  2186. pause (
  2187. void
  2188. );
  2189. /*++
  2190. Routine Description:
  2191. This routine suspends execution until a signal is caught and handled by the
  2192. application. This routine is known to be frought with timing problems, as
  2193. the most common use for it involves checking if a signal has occurred, and
  2194. calling pause if not. Unfortunately that doesn't work as a signal can come
  2195. in after the check but before the call to pause. Pause is really only
  2196. useful if the entirety of the application functionality is implemented
  2197. inside signal handlers.
  2198. Arguments:
  2199. None.
  2200. Return Value:
  2201. -1 always. A return rather negatively is thought of as a failure of the
  2202. function. The errno variable will be set to indicate the "error".
  2203. --*/
  2204. LIBC_API
  2205. long
  2206. sysconf (
  2207. int Variable
  2208. );
  2209. /*++
  2210. Routine Description:
  2211. This routine gets the system value for the given variable index. These
  2212. variables are not expected to change within a single invocation of a
  2213. process, and therefore need only be queried once per process.
  2214. Arguments:
  2215. Variable - Supplies the variable to get. See _SC_* definitions.
  2216. Return Value:
  2217. Returns the value for that variable.
  2218. -1 if the variable has no limit. The errno variable will be left unchanged.
  2219. -1 if the variable was invalid, and errno will be set to EINVAL.
  2220. --*/
  2221. LIBC_API
  2222. long
  2223. fpathconf (
  2224. int FileDescriptor,
  2225. int Variable
  2226. );
  2227. /*++
  2228. Routine Description:
  2229. This routine gets the current value of a configurable limit or option
  2230. that is associated with the given open file descriptor.
  2231. Arguments:
  2232. FileDescriptor - Supplies the file descriptor to query the value for.
  2233. Variable - Supplies the variable to get. See _PC_* definitions.
  2234. Return Value:
  2235. Returns the value for that variable.
  2236. -1 if the variable has no limit. The errno variable will be left unchanged.
  2237. -1 if the variable was invalid, and errno will be set to EINVAL.
  2238. --*/
  2239. LIBC_API
  2240. long
  2241. pathconf (
  2242. const char *Path,
  2243. int Variable
  2244. );
  2245. /*++
  2246. Routine Description:
  2247. This routine gets the current value of a configurable limit or option
  2248. that is associated with the given file or directory path.
  2249. Arguments:
  2250. Path - Supplies a pointer to a null terminated string containing the file
  2251. or directory path to get the configuration limit for.
  2252. Variable - Supplies the variable to get. See _PC_* definitions.
  2253. Return Value:
  2254. Returns the value for that variable.
  2255. -1 if the variable has no limit. The errno variable will be left unchanged.
  2256. -1 if the variable was invalid, and errno will be set to EINVAL.
  2257. --*/
  2258. LIBC_API
  2259. int
  2260. getdtablesize (
  2261. void
  2262. );
  2263. /*++
  2264. Routine Description:
  2265. This routine returns the maximum number of file descriptors that are
  2266. supported.
  2267. Arguments:
  2268. None.
  2269. Return Value:
  2270. Returns the maximum number of file descriptors that one process can have
  2271. open.
  2272. --*/
  2273. LIBC_API
  2274. int
  2275. getpagesize (
  2276. void
  2277. );
  2278. /*++
  2279. Routine Description:
  2280. This routine returns the number of bytes in the basic unit of memory
  2281. allocation on the current machine, the page. This routine is provided for
  2282. historical reasons, new applications should use sysconf(_SC_PAGESIZE)
  2283. (which is in fact exactly what this routine turns around and does).
  2284. Arguments:
  2285. None.
  2286. Return Value:
  2287. Returns the number of bytes in a memory page.
  2288. --*/
  2289. LIBC_API
  2290. unsigned int
  2291. alarm (
  2292. unsigned int Seconds
  2293. );
  2294. /*++
  2295. Routine Description:
  2296. This routine converts causes the system to generate a SIGALRM signal for
  2297. the process after the number of realtime seconds specified by the given
  2298. parameter have elapsed. Processor scheduling delays may prevent the process
  2299. from handling the signal as soon as it is generated. Alarm requests are not
  2300. stacked; only one SIGALRM generation can be scheduled in this manner. If
  2301. the SIGALRM signal has not yet been generated, the call shall result in
  2302. rescheduling the time at which the SIGALRM signal is generated.
  2303. Arguments:
  2304. Seconds - Supplies the number of seconds from now that the alarm should
  2305. fire in. If this value is 0, then a pending alarm request, if any, is
  2306. canceled.
  2307. Return Value:
  2308. If there is a previous alarm request with time remaining, then the
  2309. (non-zero) number of seconds until the alarm would have signaled is
  2310. returned.
  2311. 0 otherwise. The specification for this function says that it cannot fail.
  2312. In reality, it might, and errno should be checked if 0 is returned.
  2313. --*/
  2314. LIBC_API
  2315. unsigned
  2316. sleep (
  2317. unsigned Seconds
  2318. );
  2319. /*++
  2320. Routine Description:
  2321. This routine suspends execution of the calling thread until either the
  2322. given number of realtime seconds has elapsed or a signal was delivered.
  2323. Arguments:
  2324. Seconds - Supplies the number of seconds to sleep for.
  2325. Return Value:
  2326. None.
  2327. --*/
  2328. LIBC_API
  2329. int
  2330. usleep (
  2331. useconds_t Microseconds
  2332. );
  2333. /*++
  2334. Routine Description:
  2335. This routine suspends execution of the calling thread until either the
  2336. given number of realtime microseconds has elapsed or a signal was delivered.
  2337. Arguments:
  2338. Microseconds - Supplies the number of microseconds to sleep for.
  2339. Return Value:
  2340. 0 on success.
  2341. -1 on failure, and errno will be set to contain more information.
  2342. --*/
  2343. LIBC_API
  2344. int
  2345. access (
  2346. const char *Path,
  2347. int Mode
  2348. );
  2349. /*++
  2350. Routine Description:
  2351. This routine checks the given path for accessibility using the real user
  2352. ID.
  2353. Arguments:
  2354. Path - Supplies the path string of the file to get the accessibility
  2355. information for.
  2356. Mode - Supplies the mode bits the caller is interested in. Valid values are
  2357. F_OK to check if the file exists, R_OK to check if the file is readable,
  2358. W_OK to check if the file is writable, and X_OK to check if the file is
  2359. executable.
  2360. Return Value:
  2361. 0 on success.
  2362. -1 on failure and the errno variable will be set to provide more
  2363. information.
  2364. --*/
  2365. LIBC_API
  2366. int
  2367. faccessat (
  2368. int Directory,
  2369. const char *Path,
  2370. int Mode,
  2371. int Flags
  2372. );
  2373. /*++
  2374. Routine Description:
  2375. This routine checks the given path for accessibility using the real user
  2376. ID and real group ID rather than the effective user and group IDs.
  2377. Arguments:
  2378. Directory - Supplies an optional file descriptor. If the given path
  2379. is a relative path, the directory referenced by this descriptor will
  2380. be used as a starting point for path resolution. Supply AT_FDCWD to
  2381. use the working directory for relative paths.
  2382. Path - Supplies the path string of the file to get the accessibility
  2383. information for.
  2384. Mode - Supplies the mode bits the caller is interested in. Valid values are
  2385. F_OK to check if the file exists, R_OK to check if the file is readable,
  2386. W_OK to check if the file is writable, and X_OK to check if the file is
  2387. executable.
  2388. Flags - Supplies a bitfield of flags. Supply AT_EACCESS if the checks for
  2389. accessibility should be performed using the effective user and group
  2390. ID rather than the real user and group ID.
  2391. Return Value:
  2392. 0 on success.
  2393. -1 on failure and the errno variable will be set to provide more
  2394. information.
  2395. --*/
  2396. LIBC_API
  2397. char *
  2398. ttyname (
  2399. int FileDescriptor
  2400. );
  2401. /*++
  2402. Routine Description:
  2403. This routine returns the null-terminated pathname of the terminal
  2404. associated with the given file descriptor. This function is neither
  2405. reentrant nor thread safe.
  2406. Arguments:
  2407. FileDescriptor - Supplies the file descriptor to query.
  2408. Return Value:
  2409. Returns a pointer to the supplied buffer on success. This buffer may be
  2410. overwritten by subsequent calls to this routine.
  2411. NULL on failure and errno will be set to contain more information. Common
  2412. error values are:
  2413. EBADF if the file descriptor is not valid.
  2414. ENOTTY if the file descriptor is not a terminal.
  2415. ENOMEM if not enough memory was available.
  2416. --*/
  2417. LIBC_API
  2418. char *
  2419. ttyname_r (
  2420. int FileDescriptor,
  2421. char *Name,
  2422. size_t NameSize
  2423. );
  2424. /*++
  2425. Routine Description:
  2426. This routine returns the null-terminated pathname of the terminal
  2427. associated with the given file descriptor.
  2428. Arguments:
  2429. FileDescriptor - Supplies the file descriptor to query.
  2430. Name - Supplies a pointer to the buffer where the name will be returned
  2431. on success.
  2432. NameSize - Supplies the size of the name buffer in bytes.
  2433. Return Value:
  2434. Returns a pointer to the supplied buffer on success.
  2435. NULL on failure and errno will be set to contain more information. Common
  2436. error values are:
  2437. EBADF if the file descriptor is not valid.
  2438. ENOTTY if the file descriptor is not a terminal.
  2439. ERANGE if the supplied buffer was not large enough.
  2440. --*/
  2441. LIBC_API
  2442. int
  2443. tcsetpgrp (
  2444. int FileDescriptor,
  2445. pid_t ProcessGroupId
  2446. );
  2447. /*++
  2448. Routine Description:
  2449. This routine sets the foreground process group ID associated with the
  2450. given terminal file descriptor. The application shall ensure that the file
  2451. associated with the given descriptor is the controlling terminal of the
  2452. calling process and the controlling terminal is currently associated with
  2453. the session of the calling process. The application shall ensure that the
  2454. given process group ID is led by a process in the same session as the
  2455. calling process.
  2456. Arguments:
  2457. FileDescriptor - Supplies the file descriptor of the terminal.
  2458. ProcessGroupId - Supplies the process group ID to set for the terminal.
  2459. Return Value:
  2460. 0 on success.
  2461. -1 on failure, and the errno will be set to contain more information.
  2462. --*/
  2463. LIBC_API
  2464. pid_t
  2465. tcgetpgrp (
  2466. int FileDescriptor
  2467. );
  2468. /*++
  2469. Routine Description:
  2470. This routine returns the value of the process group ID of the foreground
  2471. process associated with the given terminal. If ther is no foreground
  2472. process group, this routine returns a value greater than 1 that does not
  2473. match the process group ID of any existing process group.
  2474. Arguments:
  2475. FileDescriptor - Supplies the file descriptor of the terminal.
  2476. Return Value:
  2477. Returns the process group ID of the foreground process associated with the
  2478. terminal on success.
  2479. -1 on failure, and errno will be set to contain more information. Possible
  2480. values of errno are:
  2481. EBADF if the file descriptor is invalid.
  2482. ENOTTY if the calling process does not having a controlling terminal, or
  2483. the file is not the controlling terminal.
  2484. --*/
  2485. LIBC_API
  2486. int
  2487. gethostname (
  2488. char *Name,
  2489. size_t NameLength
  2490. );
  2491. /*++
  2492. Routine Description:
  2493. This routine returns the network host name for the current machine.
  2494. Arguments:
  2495. Name - Supplies a pointer where the null-terminated name will be returned
  2496. on success.
  2497. NameLength - Supplies the length of the name buffer in bytes.
  2498. Return Value:
  2499. 0 on success.
  2500. -1 on failure, and errno will be set to indicate the error.
  2501. --*/
  2502. LIBC_API
  2503. int
  2504. getdomainname (
  2505. char *Name,
  2506. size_t NameLength
  2507. );
  2508. /*++
  2509. Routine Description:
  2510. This routine returns the network domain name for the current machine.
  2511. Arguments:
  2512. Name - Supplies a pointer where the null-terminated name will be returned
  2513. on success.
  2514. NameLength - Supplies the length of the name buffer in bytes.
  2515. Return Value:
  2516. 0 on success.
  2517. -1 on failure, and errno will be set to indicate the error.
  2518. --*/
  2519. LIBC_API
  2520. int
  2521. sethostname (
  2522. const char *Name,
  2523. size_t Size
  2524. );
  2525. /*++
  2526. Routine Description:
  2527. This routine sets the network host name for the current machine.
  2528. Arguments:
  2529. Name - Supplies a pointer to the new name to set.
  2530. Size - Supplies the size of the name, not including a null terminator.
  2531. Return Value:
  2532. 0 on success.
  2533. -1 on failure, and errno will be set to indicate the error.
  2534. --*/
  2535. LIBC_API
  2536. int
  2537. setdomainname (
  2538. const char *Name,
  2539. size_t Size
  2540. );
  2541. /*++
  2542. Routine Description:
  2543. This routine sets the network domain name for the current machine.
  2544. Arguments:
  2545. Name - Supplies a pointer to the new name to set.
  2546. Size - Supplies the size of the name, not including a null terminator.
  2547. Return Value:
  2548. 0 on success.
  2549. -1 on failure, and errno will be set to indicate the error.
  2550. --*/
  2551. LIBC_API
  2552. void
  2553. swab (
  2554. const void *Source,
  2555. void *Destination,
  2556. ssize_t ByteCount
  2557. );
  2558. /*++
  2559. Routine Description:
  2560. This routine copies bytes from a source buffer to a destination, exchanging
  2561. adjacent bytes. The source and destination buffers should not overlap.
  2562. Arguments:
  2563. Source - Supplies the source buffer.
  2564. Destination - Supplies the destination buffer (which should not overlap
  2565. with the source buffer).
  2566. ByteCount - Supplies the number of bytes to copy. This should be even. If
  2567. it is odd, the byte count will be truncated down to an even boundary,
  2568. so the last odd byte will not be copied.
  2569. Return Value:
  2570. None.
  2571. --*/
  2572. LIBCRYPT_API
  2573. char *
  2574. crypt (
  2575. const char *Key,
  2576. const char *Salt
  2577. );
  2578. /*++
  2579. Routine Description:
  2580. This routine encrypts a user's password using various encryption/hashing
  2581. standards. The default is DES, which is fairly weak and subject to
  2582. dictionary attacks.
  2583. Arguments:
  2584. Key - Supplies the key, a user's plaintext password.
  2585. Salt - Supplies a two character salt to use to perterb the results. If this
  2586. string starts with a $ and a number, alternate hashing algorithms are
  2587. selected. The format is $id$salt$encrypted. ID can be 1 for MD5, 5 for
  2588. SHA-256, or 6 for SHA-512.
  2589. Return Value:
  2590. Returns a pointer to the encrypted password (plus ID and salt information
  2591. in cases where an alternate mechanism is used). This is a static buffer,
  2592. which may be overwritten by subsequent calls to crypt.
  2593. --*/
  2594. LIBC_API
  2595. char *
  2596. getpass (
  2597. const char *Prompt
  2598. );
  2599. /*++
  2600. Routine Description:
  2601. This routine reads outputs the given prompt, and reads in a line of input
  2602. without echoing it. This routine attempts to use the process' controlling
  2603. terminal, or stdin/stderr otherwise.
  2604. Arguments:
  2605. Prompt - Supplies a pointer to the prompt to print.
  2606. Return Value:
  2607. Returns a pointer to the entered input on success. If this is a password,
  2608. the caller should be sure to clear this buffer out as soon as possible.
  2609. NULL on failure.
  2610. --*/
  2611. LIBC_API
  2612. char *
  2613. getusershell (
  2614. void
  2615. );
  2616. /*++
  2617. Routine Description:
  2618. This routine returns the next permitted user shell in the database of
  2619. valid shells. This opens the file if necessary. This routine is neither
  2620. thread-safe nor reentrant.
  2621. Arguments:
  2622. None.
  2623. Return Value:
  2624. Returns a pointer to a string containing the next shell on success. This
  2625. buffer may be overwritten by subsequent calls to getusershell.
  2626. NULL on failure or end-of-database.
  2627. --*/
  2628. LIBC_API
  2629. void
  2630. setusershell (
  2631. void
  2632. );
  2633. /*++
  2634. Routine Description:
  2635. This routine rewinds the user shells database back to the beginning.
  2636. Arguments:
  2637. None.
  2638. Return Value:
  2639. None.
  2640. --*/
  2641. LIBC_API
  2642. void
  2643. endusershell (
  2644. void
  2645. );
  2646. /*++
  2647. Routine Description:
  2648. This routine closes the permitted user shells database.
  2649. Arguments:
  2650. None.
  2651. Return Value:
  2652. None.
  2653. --*/
  2654. LIBC_API
  2655. int
  2656. getopt (
  2657. int ArgumentCount,
  2658. char *const Arguments[],
  2659. const char *Options
  2660. );
  2661. /*++
  2662. Routine Description:
  2663. This routine parses command line arguments, successively returning each
  2664. passed in argument. This routine is neither reentrant nor thread safe.
  2665. Arguments:
  2666. ArgumentCount - Supplies the argument count from main.
  2667. Arguments - Supplies the argument array from main.
  2668. Options - Supplies a pointer to a null terminated string containing the set
  2669. of accepted options. Each character represents an allowed option. If
  2670. a character is followed by a colon ':', then that option takes an
  2671. argument. If an option with an argument is found and there are more
  2672. characters in the current string, then the remainder of that string
  2673. will be returned. Otherwise, the next argument will be returned. If
  2674. there is no next argument, that's considered an error.
  2675. Return Value:
  2676. Returns the next option character on success. The global variable optind
  2677. will be updated to reflect the index of the next argument to be processed.
  2678. It will be initialied by the system to 1. If the option takes an argument,
  2679. the global variable optarg will be set to point at that argument.
  2680. Returns '?' if the option found is not in the recognized option string. The
  2681. optopt global variable will be set to the unrecognized option that resulted
  2682. in this condition. The '?' character is also returned if the options string
  2683. does not begin with a colon ':' and a required argument is not found. If the
  2684. opterr global variable has not been set to 0 by the user, then an error
  2685. will be printed to standard error.
  2686. Returns ':' if the options string begins with a colon and a required
  2687. argument is missing. If the opterr global variable has not been set to 0 by
  2688. the user, then an error will be printed to standard error.
  2689. -1 if a non-option was encountered. In this case the optind global variable
  2690. will be set to the first non-option argument.
  2691. --*/
  2692. LIBC_API
  2693. int
  2694. nice (
  2695. int Increment
  2696. );
  2697. /*++
  2698. Routine Description:
  2699. This routine adds the given value to the current process' nice value. A
  2700. process' nice value is a non-negative number for which a more positive
  2701. value results in less favorable scheduling. Valid nice values are between
  2702. 0 and 2 * NZERO - 1.
  2703. Arguments:
  2704. Increment - Supplies the increment to add to the current nice value.
  2705. Return Value:
  2706. Returns the new nice value minus NZERO. Note that this can result in a
  2707. successful return value of -1. Callers checking for errors should set
  2708. errno to 0 before calling this function, then check errno after.
  2709. -1 on failure, and errno will be set to indicate more information. This may
  2710. fail with EPERM if the increment is negative and the caller does not have
  2711. appropriate privileges.
  2712. --*/
  2713. #ifdef __cplusplus
  2714. }
  2715. #endif
  2716. #endif