libc.info-6 289 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167
  1. This is libc.info, produced by makeinfo version 6.5 from libc.texinfo.
  2. This is ‘The GNU C Library Reference Manual’, for version 2.33 (GNU).
  3. Copyright © 1993–2021 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being “Free Software Needs Free Documentation” and
  8. “GNU Lesser General Public License”, the Front-Cover texts being “A GNU
  9. Manual”, and with the Back-Cover Texts as in (a) below. A copy of the
  10. license is included in the section entitled "GNU Free Documentation
  11. License".
  12. (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
  13. modify this GNU manual. Buying copies from the FSF supports it in
  14. developing GNU and promoting software freedom.”
  15. INFO-DIR-SECTION Software libraries
  16. START-INFO-DIR-ENTRY
  17. * Libc: (libc). C library.
  18. END-INFO-DIR-ENTRY
  19. INFO-DIR-SECTION GNU C library functions and macros
  20. START-INFO-DIR-ENTRY
  21. * ALTWERASE: (libc)Local Modes.
  22. * ARGP_ERR_UNKNOWN: (libc)Argp Parser Functions.
  23. * ARG_MAX: (libc)General Limits.
  24. * BC_BASE_MAX: (libc)Utility Limits.
  25. * BC_DIM_MAX: (libc)Utility Limits.
  26. * BC_SCALE_MAX: (libc)Utility Limits.
  27. * BC_STRING_MAX: (libc)Utility Limits.
  28. * BRKINT: (libc)Input Modes.
  29. * BUFSIZ: (libc)Controlling Buffering.
  30. * CCTS_OFLOW: (libc)Control Modes.
  31. * CHAR_BIT: (libc)Width of Type.
  32. * CHILD_MAX: (libc)General Limits.
  33. * CIGNORE: (libc)Control Modes.
  34. * CLK_TCK: (libc)Processor Time.
  35. * CLOCAL: (libc)Control Modes.
  36. * CLOCKS_PER_SEC: (libc)CPU Time.
  37. * CLOCK_MONOTONIC: (libc)Getting the Time.
  38. * CLOCK_REALTIME: (libc)Getting the Time.
  39. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  40. * CPU_CLR: (libc)CPU Affinity.
  41. * CPU_FEATURE_USABLE: (libc)X86.
  42. * CPU_ISSET: (libc)CPU Affinity.
  43. * CPU_SET: (libc)CPU Affinity.
  44. * CPU_SETSIZE: (libc)CPU Affinity.
  45. * CPU_ZERO: (libc)CPU Affinity.
  46. * CREAD: (libc)Control Modes.
  47. * CRTS_IFLOW: (libc)Control Modes.
  48. * CS5: (libc)Control Modes.
  49. * CS6: (libc)Control Modes.
  50. * CS7: (libc)Control Modes.
  51. * CS8: (libc)Control Modes.
  52. * CSIZE: (libc)Control Modes.
  53. * CSTOPB: (libc)Control Modes.
  54. * DTTOIF: (libc)Directory Entries.
  55. * E2BIG: (libc)Error Codes.
  56. * EACCES: (libc)Error Codes.
  57. * EADDRINUSE: (libc)Error Codes.
  58. * EADDRNOTAVAIL: (libc)Error Codes.
  59. * EADV: (libc)Error Codes.
  60. * EAFNOSUPPORT: (libc)Error Codes.
  61. * EAGAIN: (libc)Error Codes.
  62. * EALREADY: (libc)Error Codes.
  63. * EAUTH: (libc)Error Codes.
  64. * EBACKGROUND: (libc)Error Codes.
  65. * EBADE: (libc)Error Codes.
  66. * EBADF: (libc)Error Codes.
  67. * EBADFD: (libc)Error Codes.
  68. * EBADMSG: (libc)Error Codes.
  69. * EBADR: (libc)Error Codes.
  70. * EBADRPC: (libc)Error Codes.
  71. * EBADRQC: (libc)Error Codes.
  72. * EBADSLT: (libc)Error Codes.
  73. * EBFONT: (libc)Error Codes.
  74. * EBUSY: (libc)Error Codes.
  75. * ECANCELED: (libc)Error Codes.
  76. * ECHILD: (libc)Error Codes.
  77. * ECHO: (libc)Local Modes.
  78. * ECHOCTL: (libc)Local Modes.
  79. * ECHOE: (libc)Local Modes.
  80. * ECHOK: (libc)Local Modes.
  81. * ECHOKE: (libc)Local Modes.
  82. * ECHONL: (libc)Local Modes.
  83. * ECHOPRT: (libc)Local Modes.
  84. * ECHRNG: (libc)Error Codes.
  85. * ECOMM: (libc)Error Codes.
  86. * ECONNABORTED: (libc)Error Codes.
  87. * ECONNREFUSED: (libc)Error Codes.
  88. * ECONNRESET: (libc)Error Codes.
  89. * ED: (libc)Error Codes.
  90. * EDEADLK: (libc)Error Codes.
  91. * EDEADLOCK: (libc)Error Codes.
  92. * EDESTADDRREQ: (libc)Error Codes.
  93. * EDIED: (libc)Error Codes.
  94. * EDOM: (libc)Error Codes.
  95. * EDOTDOT: (libc)Error Codes.
  96. * EDQUOT: (libc)Error Codes.
  97. * EEXIST: (libc)Error Codes.
  98. * EFAULT: (libc)Error Codes.
  99. * EFBIG: (libc)Error Codes.
  100. * EFTYPE: (libc)Error Codes.
  101. * EGRATUITOUS: (libc)Error Codes.
  102. * EGREGIOUS: (libc)Error Codes.
  103. * EHOSTDOWN: (libc)Error Codes.
  104. * EHOSTUNREACH: (libc)Error Codes.
  105. * EHWPOISON: (libc)Error Codes.
  106. * EIDRM: (libc)Error Codes.
  107. * EIEIO: (libc)Error Codes.
  108. * EILSEQ: (libc)Error Codes.
  109. * EINPROGRESS: (libc)Error Codes.
  110. * EINTR: (libc)Error Codes.
  111. * EINVAL: (libc)Error Codes.
  112. * EIO: (libc)Error Codes.
  113. * EISCONN: (libc)Error Codes.
  114. * EISDIR: (libc)Error Codes.
  115. * EISNAM: (libc)Error Codes.
  116. * EKEYEXPIRED: (libc)Error Codes.
  117. * EKEYREJECTED: (libc)Error Codes.
  118. * EKEYREVOKED: (libc)Error Codes.
  119. * EL2HLT: (libc)Error Codes.
  120. * EL2NSYNC: (libc)Error Codes.
  121. * EL3HLT: (libc)Error Codes.
  122. * EL3RST: (libc)Error Codes.
  123. * ELIBACC: (libc)Error Codes.
  124. * ELIBBAD: (libc)Error Codes.
  125. * ELIBEXEC: (libc)Error Codes.
  126. * ELIBMAX: (libc)Error Codes.
  127. * ELIBSCN: (libc)Error Codes.
  128. * ELNRNG: (libc)Error Codes.
  129. * ELOOP: (libc)Error Codes.
  130. * EMEDIUMTYPE: (libc)Error Codes.
  131. * EMFILE: (libc)Error Codes.
  132. * EMLINK: (libc)Error Codes.
  133. * EMSGSIZE: (libc)Error Codes.
  134. * EMULTIHOP: (libc)Error Codes.
  135. * ENAMETOOLONG: (libc)Error Codes.
  136. * ENAVAIL: (libc)Error Codes.
  137. * ENEEDAUTH: (libc)Error Codes.
  138. * ENETDOWN: (libc)Error Codes.
  139. * ENETRESET: (libc)Error Codes.
  140. * ENETUNREACH: (libc)Error Codes.
  141. * ENFILE: (libc)Error Codes.
  142. * ENOANO: (libc)Error Codes.
  143. * ENOBUFS: (libc)Error Codes.
  144. * ENOCSI: (libc)Error Codes.
  145. * ENODATA: (libc)Error Codes.
  146. * ENODEV: (libc)Error Codes.
  147. * ENOENT: (libc)Error Codes.
  148. * ENOEXEC: (libc)Error Codes.
  149. * ENOKEY: (libc)Error Codes.
  150. * ENOLCK: (libc)Error Codes.
  151. * ENOLINK: (libc)Error Codes.
  152. * ENOMEDIUM: (libc)Error Codes.
  153. * ENOMEM: (libc)Error Codes.
  154. * ENOMSG: (libc)Error Codes.
  155. * ENONET: (libc)Error Codes.
  156. * ENOPKG: (libc)Error Codes.
  157. * ENOPROTOOPT: (libc)Error Codes.
  158. * ENOSPC: (libc)Error Codes.
  159. * ENOSR: (libc)Error Codes.
  160. * ENOSTR: (libc)Error Codes.
  161. * ENOSYS: (libc)Error Codes.
  162. * ENOTBLK: (libc)Error Codes.
  163. * ENOTCONN: (libc)Error Codes.
  164. * ENOTDIR: (libc)Error Codes.
  165. * ENOTEMPTY: (libc)Error Codes.
  166. * ENOTNAM: (libc)Error Codes.
  167. * ENOTRECOVERABLE: (libc)Error Codes.
  168. * ENOTSOCK: (libc)Error Codes.
  169. * ENOTSUP: (libc)Error Codes.
  170. * ENOTTY: (libc)Error Codes.
  171. * ENOTUNIQ: (libc)Error Codes.
  172. * ENXIO: (libc)Error Codes.
  173. * EOF: (libc)EOF and Errors.
  174. * EOPNOTSUPP: (libc)Error Codes.
  175. * EOVERFLOW: (libc)Error Codes.
  176. * EOWNERDEAD: (libc)Error Codes.
  177. * EPERM: (libc)Error Codes.
  178. * EPFNOSUPPORT: (libc)Error Codes.
  179. * EPIPE: (libc)Error Codes.
  180. * EPROCLIM: (libc)Error Codes.
  181. * EPROCUNAVAIL: (libc)Error Codes.
  182. * EPROGMISMATCH: (libc)Error Codes.
  183. * EPROGUNAVAIL: (libc)Error Codes.
  184. * EPROTO: (libc)Error Codes.
  185. * EPROTONOSUPPORT: (libc)Error Codes.
  186. * EPROTOTYPE: (libc)Error Codes.
  187. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  188. * ERANGE: (libc)Error Codes.
  189. * EREMCHG: (libc)Error Codes.
  190. * EREMOTE: (libc)Error Codes.
  191. * EREMOTEIO: (libc)Error Codes.
  192. * ERESTART: (libc)Error Codes.
  193. * ERFKILL: (libc)Error Codes.
  194. * EROFS: (libc)Error Codes.
  195. * ERPCMISMATCH: (libc)Error Codes.
  196. * ESHUTDOWN: (libc)Error Codes.
  197. * ESOCKTNOSUPPORT: (libc)Error Codes.
  198. * ESPIPE: (libc)Error Codes.
  199. * ESRCH: (libc)Error Codes.
  200. * ESRMNT: (libc)Error Codes.
  201. * ESTALE: (libc)Error Codes.
  202. * ESTRPIPE: (libc)Error Codes.
  203. * ETIME: (libc)Error Codes.
  204. * ETIMEDOUT: (libc)Error Codes.
  205. * ETOOMANYREFS: (libc)Error Codes.
  206. * ETXTBSY: (libc)Error Codes.
  207. * EUCLEAN: (libc)Error Codes.
  208. * EUNATCH: (libc)Error Codes.
  209. * EUSERS: (libc)Error Codes.
  210. * EWOULDBLOCK: (libc)Error Codes.
  211. * EXDEV: (libc)Error Codes.
  212. * EXFULL: (libc)Error Codes.
  213. * EXIT_FAILURE: (libc)Exit Status.
  214. * EXIT_SUCCESS: (libc)Exit Status.
  215. * EXPR_NEST_MAX: (libc)Utility Limits.
  216. * FD_CLOEXEC: (libc)Descriptor Flags.
  217. * FD_CLR: (libc)Waiting for I/O.
  218. * FD_ISSET: (libc)Waiting for I/O.
  219. * FD_SET: (libc)Waiting for I/O.
  220. * FD_SETSIZE: (libc)Waiting for I/O.
  221. * FD_ZERO: (libc)Waiting for I/O.
  222. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  223. * FILENAME_MAX: (libc)Limits for Files.
  224. * FLUSHO: (libc)Local Modes.
  225. * FOPEN_MAX: (libc)Opening Streams.
  226. * FP_ILOGB0: (libc)Exponents and Logarithms.
  227. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  228. * FP_LLOGB0: (libc)Exponents and Logarithms.
  229. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  230. * F_DUPFD: (libc)Duplicating Descriptors.
  231. * F_GETFD: (libc)Descriptor Flags.
  232. * F_GETFL: (libc)Getting File Status Flags.
  233. * F_GETLK: (libc)File Locks.
  234. * F_GETOWN: (libc)Interrupt Input.
  235. * F_OFD_GETLK: (libc)Open File Description Locks.
  236. * F_OFD_SETLK: (libc)Open File Description Locks.
  237. * F_OFD_SETLKW: (libc)Open File Description Locks.
  238. * F_OK: (libc)Testing File Access.
  239. * F_SETFD: (libc)Descriptor Flags.
  240. * F_SETFL: (libc)Getting File Status Flags.
  241. * F_SETLK: (libc)File Locks.
  242. * F_SETLKW: (libc)File Locks.
  243. * F_SETOWN: (libc)Interrupt Input.
  244. * HAS_CPU_FEATURE: (libc)X86.
  245. * HUGE_VAL: (libc)Math Error Reporting.
  246. * HUGE_VALF: (libc)Math Error Reporting.
  247. * HUGE_VALL: (libc)Math Error Reporting.
  248. * HUGE_VAL_FN: (libc)Math Error Reporting.
  249. * HUGE_VAL_FNx: (libc)Math Error Reporting.
  250. * HUPCL: (libc)Control Modes.
  251. * I: (libc)Complex Numbers.
  252. * ICANON: (libc)Local Modes.
  253. * ICRNL: (libc)Input Modes.
  254. * IEXTEN: (libc)Local Modes.
  255. * IFNAMSIZ: (libc)Interface Naming.
  256. * IFTODT: (libc)Directory Entries.
  257. * IGNBRK: (libc)Input Modes.
  258. * IGNCR: (libc)Input Modes.
  259. * IGNPAR: (libc)Input Modes.
  260. * IMAXBEL: (libc)Input Modes.
  261. * INADDR_ANY: (libc)Host Address Data Type.
  262. * INADDR_BROADCAST: (libc)Host Address Data Type.
  263. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  264. * INADDR_NONE: (libc)Host Address Data Type.
  265. * INFINITY: (libc)Infinity and NaN.
  266. * INLCR: (libc)Input Modes.
  267. * INPCK: (libc)Input Modes.
  268. * IPPORT_RESERVED: (libc)Ports.
  269. * IPPORT_USERRESERVED: (libc)Ports.
  270. * ISIG: (libc)Local Modes.
  271. * ISTRIP: (libc)Input Modes.
  272. * IXANY: (libc)Input Modes.
  273. * IXOFF: (libc)Input Modes.
  274. * IXON: (libc)Input Modes.
  275. * LINE_MAX: (libc)Utility Limits.
  276. * LINK_MAX: (libc)Limits for Files.
  277. * L_ctermid: (libc)Identifying the Terminal.
  278. * L_cuserid: (libc)Who Logged In.
  279. * L_tmpnam: (libc)Temporary Files.
  280. * MAXNAMLEN: (libc)Limits for Files.
  281. * MAXSYMLINKS: (libc)Symbolic Links.
  282. * MAX_CANON: (libc)Limits for Files.
  283. * MAX_INPUT: (libc)Limits for Files.
  284. * MB_CUR_MAX: (libc)Selecting the Conversion.
  285. * MB_LEN_MAX: (libc)Selecting the Conversion.
  286. * MDMBUF: (libc)Control Modes.
  287. * MSG_DONTROUTE: (libc)Socket Data Options.
  288. * MSG_OOB: (libc)Socket Data Options.
  289. * MSG_PEEK: (libc)Socket Data Options.
  290. * NAME_MAX: (libc)Limits for Files.
  291. * NAN: (libc)Infinity and NaN.
  292. * NCCS: (libc)Mode Data Types.
  293. * NGROUPS_MAX: (libc)General Limits.
  294. * NOFLSH: (libc)Local Modes.
  295. * NOKERNINFO: (libc)Local Modes.
  296. * NSIG: (libc)Standard Signals.
  297. * NULL: (libc)Null Pointer Constant.
  298. * ONLCR: (libc)Output Modes.
  299. * ONOEOT: (libc)Output Modes.
  300. * OPEN_MAX: (libc)General Limits.
  301. * OPOST: (libc)Output Modes.
  302. * OXTABS: (libc)Output Modes.
  303. * O_ACCMODE: (libc)Access Modes.
  304. * O_APPEND: (libc)Operating Modes.
  305. * O_ASYNC: (libc)Operating Modes.
  306. * O_CREAT: (libc)Open-time Flags.
  307. * O_DIRECTORY: (libc)Open-time Flags.
  308. * O_EXCL: (libc)Open-time Flags.
  309. * O_EXEC: (libc)Access Modes.
  310. * O_EXLOCK: (libc)Open-time Flags.
  311. * O_FSYNC: (libc)Operating Modes.
  312. * O_IGNORE_CTTY: (libc)Open-time Flags.
  313. * O_NDELAY: (libc)Operating Modes.
  314. * O_NOATIME: (libc)Operating Modes.
  315. * O_NOCTTY: (libc)Open-time Flags.
  316. * O_NOFOLLOW: (libc)Open-time Flags.
  317. * O_NOLINK: (libc)Open-time Flags.
  318. * O_NONBLOCK: (libc)Open-time Flags.
  319. * O_NONBLOCK: (libc)Operating Modes.
  320. * O_NOTRANS: (libc)Open-time Flags.
  321. * O_PATH: (libc)Access Modes.
  322. * O_RDONLY: (libc)Access Modes.
  323. * O_RDWR: (libc)Access Modes.
  324. * O_READ: (libc)Access Modes.
  325. * O_SHLOCK: (libc)Open-time Flags.
  326. * O_SYNC: (libc)Operating Modes.
  327. * O_TMPFILE: (libc)Open-time Flags.
  328. * O_TRUNC: (libc)Open-time Flags.
  329. * O_WRITE: (libc)Access Modes.
  330. * O_WRONLY: (libc)Access Modes.
  331. * PARENB: (libc)Control Modes.
  332. * PARMRK: (libc)Input Modes.
  333. * PARODD: (libc)Control Modes.
  334. * PATH_MAX: (libc)Limits for Files.
  335. * PA_FLAG_MASK: (libc)Parsing a Template String.
  336. * PENDIN: (libc)Local Modes.
  337. * PF_FILE: (libc)Local Namespace Details.
  338. * PF_INET6: (libc)Internet Namespace.
  339. * PF_INET: (libc)Internet Namespace.
  340. * PF_LOCAL: (libc)Local Namespace Details.
  341. * PF_UNIX: (libc)Local Namespace Details.
  342. * PIPE_BUF: (libc)Limits for Files.
  343. * PTHREAD_ATTR_NO_SIGMASK_NP: (libc)Initial Thread Signal Mask.
  344. * P_tmpdir: (libc)Temporary Files.
  345. * RAND_MAX: (libc)ISO Random.
  346. * RE_DUP_MAX: (libc)General Limits.
  347. * RLIM_INFINITY: (libc)Limits on Resources.
  348. * R_OK: (libc)Testing File Access.
  349. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  350. * SA_ONSTACK: (libc)Flags for Sigaction.
  351. * SA_RESTART: (libc)Flags for Sigaction.
  352. * SEEK_CUR: (libc)File Positioning.
  353. * SEEK_END: (libc)File Positioning.
  354. * SEEK_SET: (libc)File Positioning.
  355. * SIGABRT: (libc)Program Error Signals.
  356. * SIGALRM: (libc)Alarm Signals.
  357. * SIGBUS: (libc)Program Error Signals.
  358. * SIGCHLD: (libc)Job Control Signals.
  359. * SIGCLD: (libc)Job Control Signals.
  360. * SIGCONT: (libc)Job Control Signals.
  361. * SIGEMT: (libc)Program Error Signals.
  362. * SIGFPE: (libc)Program Error Signals.
  363. * SIGHUP: (libc)Termination Signals.
  364. * SIGILL: (libc)Program Error Signals.
  365. * SIGINFO: (libc)Miscellaneous Signals.
  366. * SIGINT: (libc)Termination Signals.
  367. * SIGIO: (libc)Asynchronous I/O Signals.
  368. * SIGIOT: (libc)Program Error Signals.
  369. * SIGKILL: (libc)Termination Signals.
  370. * SIGLOST: (libc)Operation Error Signals.
  371. * SIGPIPE: (libc)Operation Error Signals.
  372. * SIGPOLL: (libc)Asynchronous I/O Signals.
  373. * SIGPROF: (libc)Alarm Signals.
  374. * SIGQUIT: (libc)Termination Signals.
  375. * SIGSEGV: (libc)Program Error Signals.
  376. * SIGSTOP: (libc)Job Control Signals.
  377. * SIGSYS: (libc)Program Error Signals.
  378. * SIGTERM: (libc)Termination Signals.
  379. * SIGTRAP: (libc)Program Error Signals.
  380. * SIGTSTP: (libc)Job Control Signals.
  381. * SIGTTIN: (libc)Job Control Signals.
  382. * SIGTTOU: (libc)Job Control Signals.
  383. * SIGURG: (libc)Asynchronous I/O Signals.
  384. * SIGUSR1: (libc)Miscellaneous Signals.
  385. * SIGUSR2: (libc)Miscellaneous Signals.
  386. * SIGVTALRM: (libc)Alarm Signals.
  387. * SIGWINCH: (libc)Miscellaneous Signals.
  388. * SIGXCPU: (libc)Operation Error Signals.
  389. * SIGXFSZ: (libc)Operation Error Signals.
  390. * SIG_ERR: (libc)Basic Signal Handling.
  391. * SNAN: (libc)Infinity and NaN.
  392. * SNANF: (libc)Infinity and NaN.
  393. * SNANFN: (libc)Infinity and NaN.
  394. * SNANFNx: (libc)Infinity and NaN.
  395. * SNANL: (libc)Infinity and NaN.
  396. * SOCK_DGRAM: (libc)Communication Styles.
  397. * SOCK_RAW: (libc)Communication Styles.
  398. * SOCK_RDM: (libc)Communication Styles.
  399. * SOCK_SEQPACKET: (libc)Communication Styles.
  400. * SOCK_STREAM: (libc)Communication Styles.
  401. * SOL_SOCKET: (libc)Socket-Level Options.
  402. * SSIZE_MAX: (libc)General Limits.
  403. * STREAM_MAX: (libc)General Limits.
  404. * SUN_LEN: (libc)Local Namespace Details.
  405. * S_IFMT: (libc)Testing File Type.
  406. * S_ISBLK: (libc)Testing File Type.
  407. * S_ISCHR: (libc)Testing File Type.
  408. * S_ISDIR: (libc)Testing File Type.
  409. * S_ISFIFO: (libc)Testing File Type.
  410. * S_ISLNK: (libc)Testing File Type.
  411. * S_ISREG: (libc)Testing File Type.
  412. * S_ISSOCK: (libc)Testing File Type.
  413. * S_TYPEISMQ: (libc)Testing File Type.
  414. * S_TYPEISSEM: (libc)Testing File Type.
  415. * S_TYPEISSHM: (libc)Testing File Type.
  416. * TMP_MAX: (libc)Temporary Files.
  417. * TOSTOP: (libc)Local Modes.
  418. * TZNAME_MAX: (libc)General Limits.
  419. * VDISCARD: (libc)Other Special.
  420. * VDSUSP: (libc)Signal Characters.
  421. * VEOF: (libc)Editing Characters.
  422. * VEOL2: (libc)Editing Characters.
  423. * VEOL: (libc)Editing Characters.
  424. * VERASE: (libc)Editing Characters.
  425. * VINTR: (libc)Signal Characters.
  426. * VKILL: (libc)Editing Characters.
  427. * VLNEXT: (libc)Other Special.
  428. * VMIN: (libc)Noncanonical Input.
  429. * VQUIT: (libc)Signal Characters.
  430. * VREPRINT: (libc)Editing Characters.
  431. * VSTART: (libc)Start/Stop Characters.
  432. * VSTATUS: (libc)Other Special.
  433. * VSTOP: (libc)Start/Stop Characters.
  434. * VSUSP: (libc)Signal Characters.
  435. * VTIME: (libc)Noncanonical Input.
  436. * VWERASE: (libc)Editing Characters.
  437. * WCHAR_MAX: (libc)Extended Char Intro.
  438. * WCHAR_MIN: (libc)Extended Char Intro.
  439. * WCOREDUMP: (libc)Process Completion Status.
  440. * WEOF: (libc)EOF and Errors.
  441. * WEOF: (libc)Extended Char Intro.
  442. * WEXITSTATUS: (libc)Process Completion Status.
  443. * WIFEXITED: (libc)Process Completion Status.
  444. * WIFSIGNALED: (libc)Process Completion Status.
  445. * WIFSTOPPED: (libc)Process Completion Status.
  446. * WSTOPSIG: (libc)Process Completion Status.
  447. * WTERMSIG: (libc)Process Completion Status.
  448. * W_OK: (libc)Testing File Access.
  449. * X_OK: (libc)Testing File Access.
  450. * _Complex_I: (libc)Complex Numbers.
  451. * _Exit: (libc)Termination Internals.
  452. * _IOFBF: (libc)Controlling Buffering.
  453. * _IOLBF: (libc)Controlling Buffering.
  454. * _IONBF: (libc)Controlling Buffering.
  455. * _Imaginary_I: (libc)Complex Numbers.
  456. * _PATH_UTMP: (libc)Manipulating the Database.
  457. * _PATH_WTMP: (libc)Manipulating the Database.
  458. * _POSIX2_C_DEV: (libc)System Options.
  459. * _POSIX2_C_VERSION: (libc)Version Supported.
  460. * _POSIX2_FORT_DEV: (libc)System Options.
  461. * _POSIX2_FORT_RUN: (libc)System Options.
  462. * _POSIX2_LOCALEDEF: (libc)System Options.
  463. * _POSIX2_SW_DEV: (libc)System Options.
  464. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  465. * _POSIX_JOB_CONTROL: (libc)System Options.
  466. * _POSIX_NO_TRUNC: (libc)Options for Files.
  467. * _POSIX_SAVED_IDS: (libc)System Options.
  468. * _POSIX_VDISABLE: (libc)Options for Files.
  469. * _POSIX_VERSION: (libc)Version Supported.
  470. * __fbufsize: (libc)Controlling Buffering.
  471. * __flbf: (libc)Controlling Buffering.
  472. * __fpending: (libc)Controlling Buffering.
  473. * __fpurge: (libc)Flushing Buffers.
  474. * __freadable: (libc)Opening Streams.
  475. * __freading: (libc)Opening Streams.
  476. * __fsetlocking: (libc)Streams and Threads.
  477. * __fwritable: (libc)Opening Streams.
  478. * __fwriting: (libc)Opening Streams.
  479. * __gconv_end_fct: (libc)glibc iconv Implementation.
  480. * __gconv_fct: (libc)glibc iconv Implementation.
  481. * __gconv_init_fct: (libc)glibc iconv Implementation.
  482. * __ppc_get_timebase: (libc)PowerPC.
  483. * __ppc_get_timebase_freq: (libc)PowerPC.
  484. * __ppc_mdoio: (libc)PowerPC.
  485. * __ppc_mdoom: (libc)PowerPC.
  486. * __ppc_set_ppr_low: (libc)PowerPC.
  487. * __ppc_set_ppr_med: (libc)PowerPC.
  488. * __ppc_set_ppr_med_high: (libc)PowerPC.
  489. * __ppc_set_ppr_med_low: (libc)PowerPC.
  490. * __ppc_set_ppr_very_low: (libc)PowerPC.
  491. * __ppc_yield: (libc)PowerPC.
  492. * __riscv_flush_icache: (libc)RISC-V.
  493. * __va_copy: (libc)Argument Macros.
  494. * __x86_get_cpuid_feature_leaf: (libc)X86.
  495. * _exit: (libc)Termination Internals.
  496. * _flushlbf: (libc)Flushing Buffers.
  497. * _tolower: (libc)Case Conversion.
  498. * _toupper: (libc)Case Conversion.
  499. * a64l: (libc)Encode Binary Data.
  500. * abort: (libc)Aborting a Program.
  501. * abs: (libc)Absolute Value.
  502. * accept: (libc)Accepting Connections.
  503. * access: (libc)Testing File Access.
  504. * acos: (libc)Inverse Trig Functions.
  505. * acosf: (libc)Inverse Trig Functions.
  506. * acosfN: (libc)Inverse Trig Functions.
  507. * acosfNx: (libc)Inverse Trig Functions.
  508. * acosh: (libc)Hyperbolic Functions.
  509. * acoshf: (libc)Hyperbolic Functions.
  510. * acoshfN: (libc)Hyperbolic Functions.
  511. * acoshfNx: (libc)Hyperbolic Functions.
  512. * acoshl: (libc)Hyperbolic Functions.
  513. * acosl: (libc)Inverse Trig Functions.
  514. * addmntent: (libc)mtab.
  515. * addseverity: (libc)Adding Severity Classes.
  516. * adjtime: (libc)Setting and Adjusting the Time.
  517. * adjtimex: (libc)Setting and Adjusting the Time.
  518. * aio_cancel64: (libc)Cancel AIO Operations.
  519. * aio_cancel: (libc)Cancel AIO Operations.
  520. * aio_error64: (libc)Status of AIO Operations.
  521. * aio_error: (libc)Status of AIO Operations.
  522. * aio_fsync64: (libc)Synchronizing AIO Operations.
  523. * aio_fsync: (libc)Synchronizing AIO Operations.
  524. * aio_init: (libc)Configuration of AIO.
  525. * aio_read64: (libc)Asynchronous Reads/Writes.
  526. * aio_read: (libc)Asynchronous Reads/Writes.
  527. * aio_return64: (libc)Status of AIO Operations.
  528. * aio_return: (libc)Status of AIO Operations.
  529. * aio_suspend64: (libc)Synchronizing AIO Operations.
  530. * aio_suspend: (libc)Synchronizing AIO Operations.
  531. * aio_write64: (libc)Asynchronous Reads/Writes.
  532. * aio_write: (libc)Asynchronous Reads/Writes.
  533. * alarm: (libc)Setting an Alarm.
  534. * aligned_alloc: (libc)Aligned Memory Blocks.
  535. * alloca: (libc)Variable Size Automatic.
  536. * alphasort64: (libc)Scanning Directory Content.
  537. * alphasort: (libc)Scanning Directory Content.
  538. * argp_error: (libc)Argp Helper Functions.
  539. * argp_failure: (libc)Argp Helper Functions.
  540. * argp_help: (libc)Argp Help.
  541. * argp_parse: (libc)Argp.
  542. * argp_state_help: (libc)Argp Helper Functions.
  543. * argp_usage: (libc)Argp Helper Functions.
  544. * argz_add: (libc)Argz Functions.
  545. * argz_add_sep: (libc)Argz Functions.
  546. * argz_append: (libc)Argz Functions.
  547. * argz_count: (libc)Argz Functions.
  548. * argz_create: (libc)Argz Functions.
  549. * argz_create_sep: (libc)Argz Functions.
  550. * argz_delete: (libc)Argz Functions.
  551. * argz_extract: (libc)Argz Functions.
  552. * argz_insert: (libc)Argz Functions.
  553. * argz_next: (libc)Argz Functions.
  554. * argz_replace: (libc)Argz Functions.
  555. * argz_stringify: (libc)Argz Functions.
  556. * asctime: (libc)Formatting Calendar Time.
  557. * asctime_r: (libc)Formatting Calendar Time.
  558. * asin: (libc)Inverse Trig Functions.
  559. * asinf: (libc)Inverse Trig Functions.
  560. * asinfN: (libc)Inverse Trig Functions.
  561. * asinfNx: (libc)Inverse Trig Functions.
  562. * asinh: (libc)Hyperbolic Functions.
  563. * asinhf: (libc)Hyperbolic Functions.
  564. * asinhfN: (libc)Hyperbolic Functions.
  565. * asinhfNx: (libc)Hyperbolic Functions.
  566. * asinhl: (libc)Hyperbolic Functions.
  567. * asinl: (libc)Inverse Trig Functions.
  568. * asprintf: (libc)Dynamic Output.
  569. * assert: (libc)Consistency Checking.
  570. * assert_perror: (libc)Consistency Checking.
  571. * atan2: (libc)Inverse Trig Functions.
  572. * atan2f: (libc)Inverse Trig Functions.
  573. * atan2fN: (libc)Inverse Trig Functions.
  574. * atan2fNx: (libc)Inverse Trig Functions.
  575. * atan2l: (libc)Inverse Trig Functions.
  576. * atan: (libc)Inverse Trig Functions.
  577. * atanf: (libc)Inverse Trig Functions.
  578. * atanfN: (libc)Inverse Trig Functions.
  579. * atanfNx: (libc)Inverse Trig Functions.
  580. * atanh: (libc)Hyperbolic Functions.
  581. * atanhf: (libc)Hyperbolic Functions.
  582. * atanhfN: (libc)Hyperbolic Functions.
  583. * atanhfNx: (libc)Hyperbolic Functions.
  584. * atanhl: (libc)Hyperbolic Functions.
  585. * atanl: (libc)Inverse Trig Functions.
  586. * atexit: (libc)Cleanups on Exit.
  587. * atof: (libc)Parsing of Floats.
  588. * atoi: (libc)Parsing of Integers.
  589. * atol: (libc)Parsing of Integers.
  590. * atoll: (libc)Parsing of Integers.
  591. * backtrace: (libc)Backtraces.
  592. * backtrace_symbols: (libc)Backtraces.
  593. * backtrace_symbols_fd: (libc)Backtraces.
  594. * basename: (libc)Finding Tokens in a String.
  595. * basename: (libc)Finding Tokens in a String.
  596. * bcmp: (libc)String/Array Comparison.
  597. * bcopy: (libc)Copying Strings and Arrays.
  598. * bind: (libc)Setting Address.
  599. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  600. * bindtextdomain: (libc)Locating gettext catalog.
  601. * brk: (libc)Resizing the Data Segment.
  602. * bsearch: (libc)Array Search Function.
  603. * btowc: (libc)Converting a Character.
  604. * bzero: (libc)Copying Strings and Arrays.
  605. * cabs: (libc)Absolute Value.
  606. * cabsf: (libc)Absolute Value.
  607. * cabsfN: (libc)Absolute Value.
  608. * cabsfNx: (libc)Absolute Value.
  609. * cabsl: (libc)Absolute Value.
  610. * cacos: (libc)Inverse Trig Functions.
  611. * cacosf: (libc)Inverse Trig Functions.
  612. * cacosfN: (libc)Inverse Trig Functions.
  613. * cacosfNx: (libc)Inverse Trig Functions.
  614. * cacosh: (libc)Hyperbolic Functions.
  615. * cacoshf: (libc)Hyperbolic Functions.
  616. * cacoshfN: (libc)Hyperbolic Functions.
  617. * cacoshfNx: (libc)Hyperbolic Functions.
  618. * cacoshl: (libc)Hyperbolic Functions.
  619. * cacosl: (libc)Inverse Trig Functions.
  620. * call_once: (libc)Call Once.
  621. * calloc: (libc)Allocating Cleared Space.
  622. * canonicalize: (libc)FP Bit Twiddling.
  623. * canonicalize_file_name: (libc)Symbolic Links.
  624. * canonicalizef: (libc)FP Bit Twiddling.
  625. * canonicalizefN: (libc)FP Bit Twiddling.
  626. * canonicalizefNx: (libc)FP Bit Twiddling.
  627. * canonicalizel: (libc)FP Bit Twiddling.
  628. * carg: (libc)Operations on Complex.
  629. * cargf: (libc)Operations on Complex.
  630. * cargfN: (libc)Operations on Complex.
  631. * cargfNx: (libc)Operations on Complex.
  632. * cargl: (libc)Operations on Complex.
  633. * casin: (libc)Inverse Trig Functions.
  634. * casinf: (libc)Inverse Trig Functions.
  635. * casinfN: (libc)Inverse Trig Functions.
  636. * casinfNx: (libc)Inverse Trig Functions.
  637. * casinh: (libc)Hyperbolic Functions.
  638. * casinhf: (libc)Hyperbolic Functions.
  639. * casinhfN: (libc)Hyperbolic Functions.
  640. * casinhfNx: (libc)Hyperbolic Functions.
  641. * casinhl: (libc)Hyperbolic Functions.
  642. * casinl: (libc)Inverse Trig Functions.
  643. * catan: (libc)Inverse Trig Functions.
  644. * catanf: (libc)Inverse Trig Functions.
  645. * catanfN: (libc)Inverse Trig Functions.
  646. * catanfNx: (libc)Inverse Trig Functions.
  647. * catanh: (libc)Hyperbolic Functions.
  648. * catanhf: (libc)Hyperbolic Functions.
  649. * catanhfN: (libc)Hyperbolic Functions.
  650. * catanhfNx: (libc)Hyperbolic Functions.
  651. * catanhl: (libc)Hyperbolic Functions.
  652. * catanl: (libc)Inverse Trig Functions.
  653. * catclose: (libc)The catgets Functions.
  654. * catgets: (libc)The catgets Functions.
  655. * catopen: (libc)The catgets Functions.
  656. * cbrt: (libc)Exponents and Logarithms.
  657. * cbrtf: (libc)Exponents and Logarithms.
  658. * cbrtfN: (libc)Exponents and Logarithms.
  659. * cbrtfNx: (libc)Exponents and Logarithms.
  660. * cbrtl: (libc)Exponents and Logarithms.
  661. * ccos: (libc)Trig Functions.
  662. * ccosf: (libc)Trig Functions.
  663. * ccosfN: (libc)Trig Functions.
  664. * ccosfNx: (libc)Trig Functions.
  665. * ccosh: (libc)Hyperbolic Functions.
  666. * ccoshf: (libc)Hyperbolic Functions.
  667. * ccoshfN: (libc)Hyperbolic Functions.
  668. * ccoshfNx: (libc)Hyperbolic Functions.
  669. * ccoshl: (libc)Hyperbolic Functions.
  670. * ccosl: (libc)Trig Functions.
  671. * ceil: (libc)Rounding Functions.
  672. * ceilf: (libc)Rounding Functions.
  673. * ceilfN: (libc)Rounding Functions.
  674. * ceilfNx: (libc)Rounding Functions.
  675. * ceill: (libc)Rounding Functions.
  676. * cexp: (libc)Exponents and Logarithms.
  677. * cexpf: (libc)Exponents and Logarithms.
  678. * cexpfN: (libc)Exponents and Logarithms.
  679. * cexpfNx: (libc)Exponents and Logarithms.
  680. * cexpl: (libc)Exponents and Logarithms.
  681. * cfgetispeed: (libc)Line Speed.
  682. * cfgetospeed: (libc)Line Speed.
  683. * cfmakeraw: (libc)Noncanonical Input.
  684. * cfsetispeed: (libc)Line Speed.
  685. * cfsetospeed: (libc)Line Speed.
  686. * cfsetspeed: (libc)Line Speed.
  687. * chdir: (libc)Working Directory.
  688. * chmod: (libc)Setting Permissions.
  689. * chown: (libc)File Owner.
  690. * cimag: (libc)Operations on Complex.
  691. * cimagf: (libc)Operations on Complex.
  692. * cimagfN: (libc)Operations on Complex.
  693. * cimagfNx: (libc)Operations on Complex.
  694. * cimagl: (libc)Operations on Complex.
  695. * clearenv: (libc)Environment Access.
  696. * clearerr: (libc)Error Recovery.
  697. * clearerr_unlocked: (libc)Error Recovery.
  698. * clock: (libc)CPU Time.
  699. * clock_getres: (libc)Getting the Time.
  700. * clock_gettime: (libc)Getting the Time.
  701. * clock_settime: (libc)Setting and Adjusting the Time.
  702. * clog10: (libc)Exponents and Logarithms.
  703. * clog10f: (libc)Exponents and Logarithms.
  704. * clog10fN: (libc)Exponents and Logarithms.
  705. * clog10fNx: (libc)Exponents and Logarithms.
  706. * clog10l: (libc)Exponents and Logarithms.
  707. * clog: (libc)Exponents and Logarithms.
  708. * clogf: (libc)Exponents and Logarithms.
  709. * clogfN: (libc)Exponents and Logarithms.
  710. * clogfNx: (libc)Exponents and Logarithms.
  711. * clogl: (libc)Exponents and Logarithms.
  712. * close: (libc)Opening and Closing Files.
  713. * closedir: (libc)Reading/Closing Directory.
  714. * closelog: (libc)closelog.
  715. * cnd_broadcast: (libc)ISO C Condition Variables.
  716. * cnd_destroy: (libc)ISO C Condition Variables.
  717. * cnd_init: (libc)ISO C Condition Variables.
  718. * cnd_signal: (libc)ISO C Condition Variables.
  719. * cnd_timedwait: (libc)ISO C Condition Variables.
  720. * cnd_wait: (libc)ISO C Condition Variables.
  721. * confstr: (libc)String Parameters.
  722. * conj: (libc)Operations on Complex.
  723. * conjf: (libc)Operations on Complex.
  724. * conjfN: (libc)Operations on Complex.
  725. * conjfNx: (libc)Operations on Complex.
  726. * conjl: (libc)Operations on Complex.
  727. * connect: (libc)Connecting.
  728. * copy_file_range: (libc)Copying File Data.
  729. * copysign: (libc)FP Bit Twiddling.
  730. * copysignf: (libc)FP Bit Twiddling.
  731. * copysignfN: (libc)FP Bit Twiddling.
  732. * copysignfNx: (libc)FP Bit Twiddling.
  733. * copysignl: (libc)FP Bit Twiddling.
  734. * cos: (libc)Trig Functions.
  735. * cosf: (libc)Trig Functions.
  736. * cosfN: (libc)Trig Functions.
  737. * cosfNx: (libc)Trig Functions.
  738. * cosh: (libc)Hyperbolic Functions.
  739. * coshf: (libc)Hyperbolic Functions.
  740. * coshfN: (libc)Hyperbolic Functions.
  741. * coshfNx: (libc)Hyperbolic Functions.
  742. * coshl: (libc)Hyperbolic Functions.
  743. * cosl: (libc)Trig Functions.
  744. * cpow: (libc)Exponents and Logarithms.
  745. * cpowf: (libc)Exponents and Logarithms.
  746. * cpowfN: (libc)Exponents and Logarithms.
  747. * cpowfNx: (libc)Exponents and Logarithms.
  748. * cpowl: (libc)Exponents and Logarithms.
  749. * cproj: (libc)Operations on Complex.
  750. * cprojf: (libc)Operations on Complex.
  751. * cprojfN: (libc)Operations on Complex.
  752. * cprojfNx: (libc)Operations on Complex.
  753. * cprojl: (libc)Operations on Complex.
  754. * creal: (libc)Operations on Complex.
  755. * crealf: (libc)Operations on Complex.
  756. * crealfN: (libc)Operations on Complex.
  757. * crealfNx: (libc)Operations on Complex.
  758. * creall: (libc)Operations on Complex.
  759. * creat64: (libc)Opening and Closing Files.
  760. * creat: (libc)Opening and Closing Files.
  761. * crypt: (libc)Passphrase Storage.
  762. * crypt_r: (libc)Passphrase Storage.
  763. * csin: (libc)Trig Functions.
  764. * csinf: (libc)Trig Functions.
  765. * csinfN: (libc)Trig Functions.
  766. * csinfNx: (libc)Trig Functions.
  767. * csinh: (libc)Hyperbolic Functions.
  768. * csinhf: (libc)Hyperbolic Functions.
  769. * csinhfN: (libc)Hyperbolic Functions.
  770. * csinhfNx: (libc)Hyperbolic Functions.
  771. * csinhl: (libc)Hyperbolic Functions.
  772. * csinl: (libc)Trig Functions.
  773. * csqrt: (libc)Exponents and Logarithms.
  774. * csqrtf: (libc)Exponents and Logarithms.
  775. * csqrtfN: (libc)Exponents and Logarithms.
  776. * csqrtfNx: (libc)Exponents and Logarithms.
  777. * csqrtl: (libc)Exponents and Logarithms.
  778. * ctan: (libc)Trig Functions.
  779. * ctanf: (libc)Trig Functions.
  780. * ctanfN: (libc)Trig Functions.
  781. * ctanfNx: (libc)Trig Functions.
  782. * ctanh: (libc)Hyperbolic Functions.
  783. * ctanhf: (libc)Hyperbolic Functions.
  784. * ctanhfN: (libc)Hyperbolic Functions.
  785. * ctanhfNx: (libc)Hyperbolic Functions.
  786. * ctanhl: (libc)Hyperbolic Functions.
  787. * ctanl: (libc)Trig Functions.
  788. * ctermid: (libc)Identifying the Terminal.
  789. * ctime: (libc)Formatting Calendar Time.
  790. * ctime_r: (libc)Formatting Calendar Time.
  791. * cuserid: (libc)Who Logged In.
  792. * daddl: (libc)Misc FP Arithmetic.
  793. * dcgettext: (libc)Translation with gettext.
  794. * dcngettext: (libc)Advanced gettext functions.
  795. * ddivl: (libc)Misc FP Arithmetic.
  796. * dgettext: (libc)Translation with gettext.
  797. * difftime: (libc)Calculating Elapsed Time.
  798. * dirfd: (libc)Opening a Directory.
  799. * dirname: (libc)Finding Tokens in a String.
  800. * div: (libc)Integer Division.
  801. * dmull: (libc)Misc FP Arithmetic.
  802. * dngettext: (libc)Advanced gettext functions.
  803. * drand48: (libc)SVID Random.
  804. * drand48_r: (libc)SVID Random.
  805. * drem: (libc)Remainder Functions.
  806. * dremf: (libc)Remainder Functions.
  807. * dreml: (libc)Remainder Functions.
  808. * dsubl: (libc)Misc FP Arithmetic.
  809. * dup2: (libc)Duplicating Descriptors.
  810. * dup: (libc)Duplicating Descriptors.
  811. * ecvt: (libc)System V Number Conversion.
  812. * ecvt_r: (libc)System V Number Conversion.
  813. * endfsent: (libc)fstab.
  814. * endgrent: (libc)Scanning All Groups.
  815. * endhostent: (libc)Host Names.
  816. * endmntent: (libc)mtab.
  817. * endnetent: (libc)Networks Database.
  818. * endnetgrent: (libc)Lookup Netgroup.
  819. * endprotoent: (libc)Protocols Database.
  820. * endpwent: (libc)Scanning All Users.
  821. * endservent: (libc)Services Database.
  822. * endutent: (libc)Manipulating the Database.
  823. * endutxent: (libc)XPG Functions.
  824. * envz_add: (libc)Envz Functions.
  825. * envz_entry: (libc)Envz Functions.
  826. * envz_get: (libc)Envz Functions.
  827. * envz_merge: (libc)Envz Functions.
  828. * envz_remove: (libc)Envz Functions.
  829. * envz_strip: (libc)Envz Functions.
  830. * erand48: (libc)SVID Random.
  831. * erand48_r: (libc)SVID Random.
  832. * erf: (libc)Special Functions.
  833. * erfc: (libc)Special Functions.
  834. * erfcf: (libc)Special Functions.
  835. * erfcfN: (libc)Special Functions.
  836. * erfcfNx: (libc)Special Functions.
  837. * erfcl: (libc)Special Functions.
  838. * erff: (libc)Special Functions.
  839. * erffN: (libc)Special Functions.
  840. * erffNx: (libc)Special Functions.
  841. * erfl: (libc)Special Functions.
  842. * err: (libc)Error Messages.
  843. * errno: (libc)Checking for Errors.
  844. * error: (libc)Error Messages.
  845. * error_at_line: (libc)Error Messages.
  846. * errx: (libc)Error Messages.
  847. * execl: (libc)Executing a File.
  848. * execle: (libc)Executing a File.
  849. * execlp: (libc)Executing a File.
  850. * execv: (libc)Executing a File.
  851. * execve: (libc)Executing a File.
  852. * execvp: (libc)Executing a File.
  853. * exit: (libc)Normal Termination.
  854. * exp10: (libc)Exponents and Logarithms.
  855. * exp10f: (libc)Exponents and Logarithms.
  856. * exp10fN: (libc)Exponents and Logarithms.
  857. * exp10fNx: (libc)Exponents and Logarithms.
  858. * exp10l: (libc)Exponents and Logarithms.
  859. * exp2: (libc)Exponents and Logarithms.
  860. * exp2f: (libc)Exponents and Logarithms.
  861. * exp2fN: (libc)Exponents and Logarithms.
  862. * exp2fNx: (libc)Exponents and Logarithms.
  863. * exp2l: (libc)Exponents and Logarithms.
  864. * exp: (libc)Exponents and Logarithms.
  865. * expf: (libc)Exponents and Logarithms.
  866. * expfN: (libc)Exponents and Logarithms.
  867. * expfNx: (libc)Exponents and Logarithms.
  868. * expl: (libc)Exponents and Logarithms.
  869. * explicit_bzero: (libc)Erasing Sensitive Data.
  870. * expm1: (libc)Exponents and Logarithms.
  871. * expm1f: (libc)Exponents and Logarithms.
  872. * expm1fN: (libc)Exponents and Logarithms.
  873. * expm1fNx: (libc)Exponents and Logarithms.
  874. * expm1l: (libc)Exponents and Logarithms.
  875. * fMaddfN: (libc)Misc FP Arithmetic.
  876. * fMaddfNx: (libc)Misc FP Arithmetic.
  877. * fMdivfN: (libc)Misc FP Arithmetic.
  878. * fMdivfNx: (libc)Misc FP Arithmetic.
  879. * fMmulfN: (libc)Misc FP Arithmetic.
  880. * fMmulfNx: (libc)Misc FP Arithmetic.
  881. * fMsubfN: (libc)Misc FP Arithmetic.
  882. * fMsubfNx: (libc)Misc FP Arithmetic.
  883. * fMxaddfN: (libc)Misc FP Arithmetic.
  884. * fMxaddfNx: (libc)Misc FP Arithmetic.
  885. * fMxdivfN: (libc)Misc FP Arithmetic.
  886. * fMxdivfNx: (libc)Misc FP Arithmetic.
  887. * fMxmulfN: (libc)Misc FP Arithmetic.
  888. * fMxmulfNx: (libc)Misc FP Arithmetic.
  889. * fMxsubfN: (libc)Misc FP Arithmetic.
  890. * fMxsubfNx: (libc)Misc FP Arithmetic.
  891. * fabs: (libc)Absolute Value.
  892. * fabsf: (libc)Absolute Value.
  893. * fabsfN: (libc)Absolute Value.
  894. * fabsfNx: (libc)Absolute Value.
  895. * fabsl: (libc)Absolute Value.
  896. * fadd: (libc)Misc FP Arithmetic.
  897. * faddl: (libc)Misc FP Arithmetic.
  898. * fchdir: (libc)Working Directory.
  899. * fchmod: (libc)Setting Permissions.
  900. * fchown: (libc)File Owner.
  901. * fclose: (libc)Closing Streams.
  902. * fcloseall: (libc)Closing Streams.
  903. * fcntl: (libc)Control Operations.
  904. * fcvt: (libc)System V Number Conversion.
  905. * fcvt_r: (libc)System V Number Conversion.
  906. * fdatasync: (libc)Synchronizing I/O.
  907. * fdim: (libc)Misc FP Arithmetic.
  908. * fdimf: (libc)Misc FP Arithmetic.
  909. * fdimfN: (libc)Misc FP Arithmetic.
  910. * fdimfNx: (libc)Misc FP Arithmetic.
  911. * fdiml: (libc)Misc FP Arithmetic.
  912. * fdiv: (libc)Misc FP Arithmetic.
  913. * fdivl: (libc)Misc FP Arithmetic.
  914. * fdopen: (libc)Descriptors and Streams.
  915. * fdopendir: (libc)Opening a Directory.
  916. * feclearexcept: (libc)Status bit operations.
  917. * fedisableexcept: (libc)Control Functions.
  918. * feenableexcept: (libc)Control Functions.
  919. * fegetenv: (libc)Control Functions.
  920. * fegetexcept: (libc)Control Functions.
  921. * fegetexceptflag: (libc)Status bit operations.
  922. * fegetmode: (libc)Control Functions.
  923. * fegetround: (libc)Rounding.
  924. * feholdexcept: (libc)Control Functions.
  925. * feof: (libc)EOF and Errors.
  926. * feof_unlocked: (libc)EOF and Errors.
  927. * feraiseexcept: (libc)Status bit operations.
  928. * ferror: (libc)EOF and Errors.
  929. * ferror_unlocked: (libc)EOF and Errors.
  930. * fesetenv: (libc)Control Functions.
  931. * fesetexcept: (libc)Status bit operations.
  932. * fesetexceptflag: (libc)Status bit operations.
  933. * fesetmode: (libc)Control Functions.
  934. * fesetround: (libc)Rounding.
  935. * fetestexcept: (libc)Status bit operations.
  936. * fetestexceptflag: (libc)Status bit operations.
  937. * feupdateenv: (libc)Control Functions.
  938. * fexecve: (libc)Executing a File.
  939. * fflush: (libc)Flushing Buffers.
  940. * fflush_unlocked: (libc)Flushing Buffers.
  941. * fgetc: (libc)Character Input.
  942. * fgetc_unlocked: (libc)Character Input.
  943. * fgetgrent: (libc)Scanning All Groups.
  944. * fgetgrent_r: (libc)Scanning All Groups.
  945. * fgetpos64: (libc)Portable Positioning.
  946. * fgetpos: (libc)Portable Positioning.
  947. * fgetpwent: (libc)Scanning All Users.
  948. * fgetpwent_r: (libc)Scanning All Users.
  949. * fgets: (libc)Line Input.
  950. * fgets_unlocked: (libc)Line Input.
  951. * fgetwc: (libc)Character Input.
  952. * fgetwc_unlocked: (libc)Character Input.
  953. * fgetws: (libc)Line Input.
  954. * fgetws_unlocked: (libc)Line Input.
  955. * fileno: (libc)Descriptors and Streams.
  956. * fileno_unlocked: (libc)Descriptors and Streams.
  957. * finite: (libc)Floating Point Classes.
  958. * finitef: (libc)Floating Point Classes.
  959. * finitel: (libc)Floating Point Classes.
  960. * flockfile: (libc)Streams and Threads.
  961. * floor: (libc)Rounding Functions.
  962. * floorf: (libc)Rounding Functions.
  963. * floorfN: (libc)Rounding Functions.
  964. * floorfNx: (libc)Rounding Functions.
  965. * floorl: (libc)Rounding Functions.
  966. * fma: (libc)Misc FP Arithmetic.
  967. * fmaf: (libc)Misc FP Arithmetic.
  968. * fmafN: (libc)Misc FP Arithmetic.
  969. * fmafNx: (libc)Misc FP Arithmetic.
  970. * fmal: (libc)Misc FP Arithmetic.
  971. * fmax: (libc)Misc FP Arithmetic.
  972. * fmaxf: (libc)Misc FP Arithmetic.
  973. * fmaxfN: (libc)Misc FP Arithmetic.
  974. * fmaxfNx: (libc)Misc FP Arithmetic.
  975. * fmaxl: (libc)Misc FP Arithmetic.
  976. * fmaxmag: (libc)Misc FP Arithmetic.
  977. * fmaxmagf: (libc)Misc FP Arithmetic.
  978. * fmaxmagfN: (libc)Misc FP Arithmetic.
  979. * fmaxmagfNx: (libc)Misc FP Arithmetic.
  980. * fmaxmagl: (libc)Misc FP Arithmetic.
  981. * fmemopen: (libc)String Streams.
  982. * fmin: (libc)Misc FP Arithmetic.
  983. * fminf: (libc)Misc FP Arithmetic.
  984. * fminfN: (libc)Misc FP Arithmetic.
  985. * fminfNx: (libc)Misc FP Arithmetic.
  986. * fminl: (libc)Misc FP Arithmetic.
  987. * fminmag: (libc)Misc FP Arithmetic.
  988. * fminmagf: (libc)Misc FP Arithmetic.
  989. * fminmagfN: (libc)Misc FP Arithmetic.
  990. * fminmagfNx: (libc)Misc FP Arithmetic.
  991. * fminmagl: (libc)Misc FP Arithmetic.
  992. * fmod: (libc)Remainder Functions.
  993. * fmodf: (libc)Remainder Functions.
  994. * fmodfN: (libc)Remainder Functions.
  995. * fmodfNx: (libc)Remainder Functions.
  996. * fmodl: (libc)Remainder Functions.
  997. * fmtmsg: (libc)Printing Formatted Messages.
  998. * fmul: (libc)Misc FP Arithmetic.
  999. * fmull: (libc)Misc FP Arithmetic.
  1000. * fnmatch: (libc)Wildcard Matching.
  1001. * fopen64: (libc)Opening Streams.
  1002. * fopen: (libc)Opening Streams.
  1003. * fopencookie: (libc)Streams and Cookies.
  1004. * fork: (libc)Creating a Process.
  1005. * forkpty: (libc)Pseudo-Terminal Pairs.
  1006. * fpathconf: (libc)Pathconf.
  1007. * fpclassify: (libc)Floating Point Classes.
  1008. * fprintf: (libc)Formatted Output Functions.
  1009. * fputc: (libc)Simple Output.
  1010. * fputc_unlocked: (libc)Simple Output.
  1011. * fputs: (libc)Simple Output.
  1012. * fputs_unlocked: (libc)Simple Output.
  1013. * fputwc: (libc)Simple Output.
  1014. * fputwc_unlocked: (libc)Simple Output.
  1015. * fputws: (libc)Simple Output.
  1016. * fputws_unlocked: (libc)Simple Output.
  1017. * fread: (libc)Block Input/Output.
  1018. * fread_unlocked: (libc)Block Input/Output.
  1019. * free: (libc)Freeing after Malloc.
  1020. * freopen64: (libc)Opening Streams.
  1021. * freopen: (libc)Opening Streams.
  1022. * frexp: (libc)Normalization Functions.
  1023. * frexpf: (libc)Normalization Functions.
  1024. * frexpfN: (libc)Normalization Functions.
  1025. * frexpfNx: (libc)Normalization Functions.
  1026. * frexpl: (libc)Normalization Functions.
  1027. * fromfp: (libc)Rounding Functions.
  1028. * fromfpf: (libc)Rounding Functions.
  1029. * fromfpfN: (libc)Rounding Functions.
  1030. * fromfpfNx: (libc)Rounding Functions.
  1031. * fromfpl: (libc)Rounding Functions.
  1032. * fromfpx: (libc)Rounding Functions.
  1033. * fromfpxf: (libc)Rounding Functions.
  1034. * fromfpxfN: (libc)Rounding Functions.
  1035. * fromfpxfNx: (libc)Rounding Functions.
  1036. * fromfpxl: (libc)Rounding Functions.
  1037. * fscanf: (libc)Formatted Input Functions.
  1038. * fseek: (libc)File Positioning.
  1039. * fseeko64: (libc)File Positioning.
  1040. * fseeko: (libc)File Positioning.
  1041. * fsetpos64: (libc)Portable Positioning.
  1042. * fsetpos: (libc)Portable Positioning.
  1043. * fstat64: (libc)Reading Attributes.
  1044. * fstat: (libc)Reading Attributes.
  1045. * fsub: (libc)Misc FP Arithmetic.
  1046. * fsubl: (libc)Misc FP Arithmetic.
  1047. * fsync: (libc)Synchronizing I/O.
  1048. * ftell: (libc)File Positioning.
  1049. * ftello64: (libc)File Positioning.
  1050. * ftello: (libc)File Positioning.
  1051. * ftruncate64: (libc)File Size.
  1052. * ftruncate: (libc)File Size.
  1053. * ftrylockfile: (libc)Streams and Threads.
  1054. * ftw64: (libc)Working with Directory Trees.
  1055. * ftw: (libc)Working with Directory Trees.
  1056. * funlockfile: (libc)Streams and Threads.
  1057. * futimes: (libc)File Times.
  1058. * fwide: (libc)Streams and I18N.
  1059. * fwprintf: (libc)Formatted Output Functions.
  1060. * fwrite: (libc)Block Input/Output.
  1061. * fwrite_unlocked: (libc)Block Input/Output.
  1062. * fwscanf: (libc)Formatted Input Functions.
  1063. * gamma: (libc)Special Functions.
  1064. * gammaf: (libc)Special Functions.
  1065. * gammal: (libc)Special Functions.
  1066. * gcvt: (libc)System V Number Conversion.
  1067. * get_avphys_pages: (libc)Query Memory Parameters.
  1068. * get_current_dir_name: (libc)Working Directory.
  1069. * get_nprocs: (libc)Processor Resources.
  1070. * get_nprocs_conf: (libc)Processor Resources.
  1071. * get_phys_pages: (libc)Query Memory Parameters.
  1072. * getauxval: (libc)Auxiliary Vector.
  1073. * getc: (libc)Character Input.
  1074. * getc_unlocked: (libc)Character Input.
  1075. * getchar: (libc)Character Input.
  1076. * getchar_unlocked: (libc)Character Input.
  1077. * getcontext: (libc)System V contexts.
  1078. * getcpu: (libc)CPU Affinity.
  1079. * getcwd: (libc)Working Directory.
  1080. * getdate: (libc)General Time String Parsing.
  1081. * getdate_r: (libc)General Time String Parsing.
  1082. * getdelim: (libc)Line Input.
  1083. * getdents64: (libc)Low-level Directory Access.
  1084. * getdomainnname: (libc)Host Identification.
  1085. * getegid: (libc)Reading Persona.
  1086. * getentropy: (libc)Unpredictable Bytes.
  1087. * getenv: (libc)Environment Access.
  1088. * geteuid: (libc)Reading Persona.
  1089. * getfsent: (libc)fstab.
  1090. * getfsfile: (libc)fstab.
  1091. * getfsspec: (libc)fstab.
  1092. * getgid: (libc)Reading Persona.
  1093. * getgrent: (libc)Scanning All Groups.
  1094. * getgrent_r: (libc)Scanning All Groups.
  1095. * getgrgid: (libc)Lookup Group.
  1096. * getgrgid_r: (libc)Lookup Group.
  1097. * getgrnam: (libc)Lookup Group.
  1098. * getgrnam_r: (libc)Lookup Group.
  1099. * getgrouplist: (libc)Setting Groups.
  1100. * getgroups: (libc)Reading Persona.
  1101. * gethostbyaddr: (libc)Host Names.
  1102. * gethostbyaddr_r: (libc)Host Names.
  1103. * gethostbyname2: (libc)Host Names.
  1104. * gethostbyname2_r: (libc)Host Names.
  1105. * gethostbyname: (libc)Host Names.
  1106. * gethostbyname_r: (libc)Host Names.
  1107. * gethostent: (libc)Host Names.
  1108. * gethostid: (libc)Host Identification.
  1109. * gethostname: (libc)Host Identification.
  1110. * getitimer: (libc)Setting an Alarm.
  1111. * getline: (libc)Line Input.
  1112. * getloadavg: (libc)Processor Resources.
  1113. * getlogin: (libc)Who Logged In.
  1114. * getmntent: (libc)mtab.
  1115. * getmntent_r: (libc)mtab.
  1116. * getnetbyaddr: (libc)Networks Database.
  1117. * getnetbyname: (libc)Networks Database.
  1118. * getnetent: (libc)Networks Database.
  1119. * getnetgrent: (libc)Lookup Netgroup.
  1120. * getnetgrent_r: (libc)Lookup Netgroup.
  1121. * getopt: (libc)Using Getopt.
  1122. * getopt_long: (libc)Getopt Long Options.
  1123. * getopt_long_only: (libc)Getopt Long Options.
  1124. * getpagesize: (libc)Query Memory Parameters.
  1125. * getpass: (libc)getpass.
  1126. * getpayload: (libc)FP Bit Twiddling.
  1127. * getpayloadf: (libc)FP Bit Twiddling.
  1128. * getpayloadfN: (libc)FP Bit Twiddling.
  1129. * getpayloadfNx: (libc)FP Bit Twiddling.
  1130. * getpayloadl: (libc)FP Bit Twiddling.
  1131. * getpeername: (libc)Who is Connected.
  1132. * getpgid: (libc)Process Group Functions.
  1133. * getpgrp: (libc)Process Group Functions.
  1134. * getpid: (libc)Process Identification.
  1135. * getppid: (libc)Process Identification.
  1136. * getpriority: (libc)Traditional Scheduling Functions.
  1137. * getprotobyname: (libc)Protocols Database.
  1138. * getprotobynumber: (libc)Protocols Database.
  1139. * getprotoent: (libc)Protocols Database.
  1140. * getpt: (libc)Allocation.
  1141. * getpwent: (libc)Scanning All Users.
  1142. * getpwent_r: (libc)Scanning All Users.
  1143. * getpwnam: (libc)Lookup User.
  1144. * getpwnam_r: (libc)Lookup User.
  1145. * getpwuid: (libc)Lookup User.
  1146. * getpwuid_r: (libc)Lookup User.
  1147. * getrandom: (libc)Unpredictable Bytes.
  1148. * getrlimit64: (libc)Limits on Resources.
  1149. * getrlimit: (libc)Limits on Resources.
  1150. * getrusage: (libc)Resource Usage.
  1151. * gets: (libc)Line Input.
  1152. * getservbyname: (libc)Services Database.
  1153. * getservbyport: (libc)Services Database.
  1154. * getservent: (libc)Services Database.
  1155. * getsid: (libc)Process Group Functions.
  1156. * getsockname: (libc)Reading Address.
  1157. * getsockopt: (libc)Socket Option Functions.
  1158. * getsubopt: (libc)Suboptions.
  1159. * gettext: (libc)Translation with gettext.
  1160. * gettid: (libc)Process Identification.
  1161. * gettimeofday: (libc)Getting the Time.
  1162. * getuid: (libc)Reading Persona.
  1163. * getumask: (libc)Setting Permissions.
  1164. * getutent: (libc)Manipulating the Database.
  1165. * getutent_r: (libc)Manipulating the Database.
  1166. * getutid: (libc)Manipulating the Database.
  1167. * getutid_r: (libc)Manipulating the Database.
  1168. * getutline: (libc)Manipulating the Database.
  1169. * getutline_r: (libc)Manipulating the Database.
  1170. * getutmp: (libc)XPG Functions.
  1171. * getutmpx: (libc)XPG Functions.
  1172. * getutxent: (libc)XPG Functions.
  1173. * getutxid: (libc)XPG Functions.
  1174. * getutxline: (libc)XPG Functions.
  1175. * getw: (libc)Character Input.
  1176. * getwc: (libc)Character Input.
  1177. * getwc_unlocked: (libc)Character Input.
  1178. * getwchar: (libc)Character Input.
  1179. * getwchar_unlocked: (libc)Character Input.
  1180. * getwd: (libc)Working Directory.
  1181. * glob64: (libc)Calling Glob.
  1182. * glob: (libc)Calling Glob.
  1183. * globfree64: (libc)More Flags for Globbing.
  1184. * globfree: (libc)More Flags for Globbing.
  1185. * gmtime: (libc)Broken-down Time.
  1186. * gmtime_r: (libc)Broken-down Time.
  1187. * grantpt: (libc)Allocation.
  1188. * gsignal: (libc)Signaling Yourself.
  1189. * gtty: (libc)BSD Terminal Modes.
  1190. * hasmntopt: (libc)mtab.
  1191. * hcreate: (libc)Hash Search Function.
  1192. * hcreate_r: (libc)Hash Search Function.
  1193. * hdestroy: (libc)Hash Search Function.
  1194. * hdestroy_r: (libc)Hash Search Function.
  1195. * hsearch: (libc)Hash Search Function.
  1196. * hsearch_r: (libc)Hash Search Function.
  1197. * htonl: (libc)Byte Order.
  1198. * htons: (libc)Byte Order.
  1199. * hypot: (libc)Exponents and Logarithms.
  1200. * hypotf: (libc)Exponents and Logarithms.
  1201. * hypotfN: (libc)Exponents and Logarithms.
  1202. * hypotfNx: (libc)Exponents and Logarithms.
  1203. * hypotl: (libc)Exponents and Logarithms.
  1204. * iconv: (libc)Generic Conversion Interface.
  1205. * iconv_close: (libc)Generic Conversion Interface.
  1206. * iconv_open: (libc)Generic Conversion Interface.
  1207. * if_freenameindex: (libc)Interface Naming.
  1208. * if_indextoname: (libc)Interface Naming.
  1209. * if_nameindex: (libc)Interface Naming.
  1210. * if_nametoindex: (libc)Interface Naming.
  1211. * ilogb: (libc)Exponents and Logarithms.
  1212. * ilogbf: (libc)Exponents and Logarithms.
  1213. * ilogbfN: (libc)Exponents and Logarithms.
  1214. * ilogbfNx: (libc)Exponents and Logarithms.
  1215. * ilogbl: (libc)Exponents and Logarithms.
  1216. * imaxabs: (libc)Absolute Value.
  1217. * imaxdiv: (libc)Integer Division.
  1218. * in6addr_any: (libc)Host Address Data Type.
  1219. * in6addr_loopback: (libc)Host Address Data Type.
  1220. * index: (libc)Search Functions.
  1221. * inet_addr: (libc)Host Address Functions.
  1222. * inet_aton: (libc)Host Address Functions.
  1223. * inet_lnaof: (libc)Host Address Functions.
  1224. * inet_makeaddr: (libc)Host Address Functions.
  1225. * inet_netof: (libc)Host Address Functions.
  1226. * inet_network: (libc)Host Address Functions.
  1227. * inet_ntoa: (libc)Host Address Functions.
  1228. * inet_ntop: (libc)Host Address Functions.
  1229. * inet_pton: (libc)Host Address Functions.
  1230. * initgroups: (libc)Setting Groups.
  1231. * initstate: (libc)BSD Random.
  1232. * initstate_r: (libc)BSD Random.
  1233. * innetgr: (libc)Netgroup Membership.
  1234. * ioctl: (libc)IOCTLs.
  1235. * isalnum: (libc)Classification of Characters.
  1236. * isalpha: (libc)Classification of Characters.
  1237. * isascii: (libc)Classification of Characters.
  1238. * isatty: (libc)Is It a Terminal.
  1239. * isblank: (libc)Classification of Characters.
  1240. * iscanonical: (libc)Floating Point Classes.
  1241. * iscntrl: (libc)Classification of Characters.
  1242. * isdigit: (libc)Classification of Characters.
  1243. * iseqsig: (libc)FP Comparison Functions.
  1244. * isfinite: (libc)Floating Point Classes.
  1245. * isgraph: (libc)Classification of Characters.
  1246. * isgreater: (libc)FP Comparison Functions.
  1247. * isgreaterequal: (libc)FP Comparison Functions.
  1248. * isinf: (libc)Floating Point Classes.
  1249. * isinff: (libc)Floating Point Classes.
  1250. * isinfl: (libc)Floating Point Classes.
  1251. * isless: (libc)FP Comparison Functions.
  1252. * islessequal: (libc)FP Comparison Functions.
  1253. * islessgreater: (libc)FP Comparison Functions.
  1254. * islower: (libc)Classification of Characters.
  1255. * isnan: (libc)Floating Point Classes.
  1256. * isnan: (libc)Floating Point Classes.
  1257. * isnanf: (libc)Floating Point Classes.
  1258. * isnanl: (libc)Floating Point Classes.
  1259. * isnormal: (libc)Floating Point Classes.
  1260. * isprint: (libc)Classification of Characters.
  1261. * ispunct: (libc)Classification of Characters.
  1262. * issignaling: (libc)Floating Point Classes.
  1263. * isspace: (libc)Classification of Characters.
  1264. * issubnormal: (libc)Floating Point Classes.
  1265. * isunordered: (libc)FP Comparison Functions.
  1266. * isupper: (libc)Classification of Characters.
  1267. * iswalnum: (libc)Classification of Wide Characters.
  1268. * iswalpha: (libc)Classification of Wide Characters.
  1269. * iswblank: (libc)Classification of Wide Characters.
  1270. * iswcntrl: (libc)Classification of Wide Characters.
  1271. * iswctype: (libc)Classification of Wide Characters.
  1272. * iswdigit: (libc)Classification of Wide Characters.
  1273. * iswgraph: (libc)Classification of Wide Characters.
  1274. * iswlower: (libc)Classification of Wide Characters.
  1275. * iswprint: (libc)Classification of Wide Characters.
  1276. * iswpunct: (libc)Classification of Wide Characters.
  1277. * iswspace: (libc)Classification of Wide Characters.
  1278. * iswupper: (libc)Classification of Wide Characters.
  1279. * iswxdigit: (libc)Classification of Wide Characters.
  1280. * isxdigit: (libc)Classification of Characters.
  1281. * iszero: (libc)Floating Point Classes.
  1282. * j0: (libc)Special Functions.
  1283. * j0f: (libc)Special Functions.
  1284. * j0fN: (libc)Special Functions.
  1285. * j0fNx: (libc)Special Functions.
  1286. * j0l: (libc)Special Functions.
  1287. * j1: (libc)Special Functions.
  1288. * j1f: (libc)Special Functions.
  1289. * j1fN: (libc)Special Functions.
  1290. * j1fNx: (libc)Special Functions.
  1291. * j1l: (libc)Special Functions.
  1292. * jn: (libc)Special Functions.
  1293. * jnf: (libc)Special Functions.
  1294. * jnfN: (libc)Special Functions.
  1295. * jnfNx: (libc)Special Functions.
  1296. * jnl: (libc)Special Functions.
  1297. * jrand48: (libc)SVID Random.
  1298. * jrand48_r: (libc)SVID Random.
  1299. * kill: (libc)Signaling Another Process.
  1300. * killpg: (libc)Signaling Another Process.
  1301. * l64a: (libc)Encode Binary Data.
  1302. * labs: (libc)Absolute Value.
  1303. * lcong48: (libc)SVID Random.
  1304. * lcong48_r: (libc)SVID Random.
  1305. * ldexp: (libc)Normalization Functions.
  1306. * ldexpf: (libc)Normalization Functions.
  1307. * ldexpfN: (libc)Normalization Functions.
  1308. * ldexpfNx: (libc)Normalization Functions.
  1309. * ldexpl: (libc)Normalization Functions.
  1310. * ldiv: (libc)Integer Division.
  1311. * lfind: (libc)Array Search Function.
  1312. * lgamma: (libc)Special Functions.
  1313. * lgamma_r: (libc)Special Functions.
  1314. * lgammaf: (libc)Special Functions.
  1315. * lgammafN: (libc)Special Functions.
  1316. * lgammafN_r: (libc)Special Functions.
  1317. * lgammafNx: (libc)Special Functions.
  1318. * lgammafNx_r: (libc)Special Functions.
  1319. * lgammaf_r: (libc)Special Functions.
  1320. * lgammal: (libc)Special Functions.
  1321. * lgammal_r: (libc)Special Functions.
  1322. * link: (libc)Hard Links.
  1323. * linkat: (libc)Hard Links.
  1324. * lio_listio64: (libc)Asynchronous Reads/Writes.
  1325. * lio_listio: (libc)Asynchronous Reads/Writes.
  1326. * listen: (libc)Listening.
  1327. * llabs: (libc)Absolute Value.
  1328. * lldiv: (libc)Integer Division.
  1329. * llogb: (libc)Exponents and Logarithms.
  1330. * llogbf: (libc)Exponents and Logarithms.
  1331. * llogbfN: (libc)Exponents and Logarithms.
  1332. * llogbfNx: (libc)Exponents and Logarithms.
  1333. * llogbl: (libc)Exponents and Logarithms.
  1334. * llrint: (libc)Rounding Functions.
  1335. * llrintf: (libc)Rounding Functions.
  1336. * llrintfN: (libc)Rounding Functions.
  1337. * llrintfNx: (libc)Rounding Functions.
  1338. * llrintl: (libc)Rounding Functions.
  1339. * llround: (libc)Rounding Functions.
  1340. * llroundf: (libc)Rounding Functions.
  1341. * llroundfN: (libc)Rounding Functions.
  1342. * llroundfNx: (libc)Rounding Functions.
  1343. * llroundl: (libc)Rounding Functions.
  1344. * localeconv: (libc)The Lame Way to Locale Data.
  1345. * localtime: (libc)Broken-down Time.
  1346. * localtime_r: (libc)Broken-down Time.
  1347. * log10: (libc)Exponents and Logarithms.
  1348. * log10f: (libc)Exponents and Logarithms.
  1349. * log10fN: (libc)Exponents and Logarithms.
  1350. * log10fNx: (libc)Exponents and Logarithms.
  1351. * log10l: (libc)Exponents and Logarithms.
  1352. * log1p: (libc)Exponents and Logarithms.
  1353. * log1pf: (libc)Exponents and Logarithms.
  1354. * log1pfN: (libc)Exponents and Logarithms.
  1355. * log1pfNx: (libc)Exponents and Logarithms.
  1356. * log1pl: (libc)Exponents and Logarithms.
  1357. * log2: (libc)Exponents and Logarithms.
  1358. * log2f: (libc)Exponents and Logarithms.
  1359. * log2fN: (libc)Exponents and Logarithms.
  1360. * log2fNx: (libc)Exponents and Logarithms.
  1361. * log2l: (libc)Exponents and Logarithms.
  1362. * log: (libc)Exponents and Logarithms.
  1363. * logb: (libc)Exponents and Logarithms.
  1364. * logbf: (libc)Exponents and Logarithms.
  1365. * logbfN: (libc)Exponents and Logarithms.
  1366. * logbfNx: (libc)Exponents and Logarithms.
  1367. * logbl: (libc)Exponents and Logarithms.
  1368. * logf: (libc)Exponents and Logarithms.
  1369. * logfN: (libc)Exponents and Logarithms.
  1370. * logfNx: (libc)Exponents and Logarithms.
  1371. * login: (libc)Logging In and Out.
  1372. * login_tty: (libc)Logging In and Out.
  1373. * logl: (libc)Exponents and Logarithms.
  1374. * logout: (libc)Logging In and Out.
  1375. * logwtmp: (libc)Logging In and Out.
  1376. * longjmp: (libc)Non-Local Details.
  1377. * lrand48: (libc)SVID Random.
  1378. * lrand48_r: (libc)SVID Random.
  1379. * lrint: (libc)Rounding Functions.
  1380. * lrintf: (libc)Rounding Functions.
  1381. * lrintfN: (libc)Rounding Functions.
  1382. * lrintfNx: (libc)Rounding Functions.
  1383. * lrintl: (libc)Rounding Functions.
  1384. * lround: (libc)Rounding Functions.
  1385. * lroundf: (libc)Rounding Functions.
  1386. * lroundfN: (libc)Rounding Functions.
  1387. * lroundfNx: (libc)Rounding Functions.
  1388. * lroundl: (libc)Rounding Functions.
  1389. * lsearch: (libc)Array Search Function.
  1390. * lseek64: (libc)File Position Primitive.
  1391. * lseek: (libc)File Position Primitive.
  1392. * lstat64: (libc)Reading Attributes.
  1393. * lstat: (libc)Reading Attributes.
  1394. * lutimes: (libc)File Times.
  1395. * madvise: (libc)Memory-mapped I/O.
  1396. * makecontext: (libc)System V contexts.
  1397. * mallinfo2: (libc)Statistics of Malloc.
  1398. * malloc: (libc)Basic Allocation.
  1399. * mallopt: (libc)Malloc Tunable Parameters.
  1400. * mblen: (libc)Non-reentrant Character Conversion.
  1401. * mbrlen: (libc)Converting a Character.
  1402. * mbrtowc: (libc)Converting a Character.
  1403. * mbsinit: (libc)Keeping the state.
  1404. * mbsnrtowcs: (libc)Converting Strings.
  1405. * mbsrtowcs: (libc)Converting Strings.
  1406. * mbstowcs: (libc)Non-reentrant String Conversion.
  1407. * mbtowc: (libc)Non-reentrant Character Conversion.
  1408. * mcheck: (libc)Heap Consistency Checking.
  1409. * memalign: (libc)Aligned Memory Blocks.
  1410. * memccpy: (libc)Copying Strings and Arrays.
  1411. * memchr: (libc)Search Functions.
  1412. * memcmp: (libc)String/Array Comparison.
  1413. * memcpy: (libc)Copying Strings and Arrays.
  1414. * memfd_create: (libc)Memory-mapped I/O.
  1415. * memfrob: (libc)Obfuscating Data.
  1416. * memmem: (libc)Search Functions.
  1417. * memmove: (libc)Copying Strings and Arrays.
  1418. * mempcpy: (libc)Copying Strings and Arrays.
  1419. * memrchr: (libc)Search Functions.
  1420. * memset: (libc)Copying Strings and Arrays.
  1421. * mkdir: (libc)Creating Directories.
  1422. * mkdtemp: (libc)Temporary Files.
  1423. * mkfifo: (libc)FIFO Special Files.
  1424. * mknod: (libc)Making Special Files.
  1425. * mkstemp: (libc)Temporary Files.
  1426. * mktemp: (libc)Temporary Files.
  1427. * mktime: (libc)Broken-down Time.
  1428. * mlock2: (libc)Page Lock Functions.
  1429. * mlock: (libc)Page Lock Functions.
  1430. * mlockall: (libc)Page Lock Functions.
  1431. * mmap64: (libc)Memory-mapped I/O.
  1432. * mmap: (libc)Memory-mapped I/O.
  1433. * modf: (libc)Rounding Functions.
  1434. * modff: (libc)Rounding Functions.
  1435. * modffN: (libc)Rounding Functions.
  1436. * modffNx: (libc)Rounding Functions.
  1437. * modfl: (libc)Rounding Functions.
  1438. * mount: (libc)Mount-Unmount-Remount.
  1439. * mprobe: (libc)Heap Consistency Checking.
  1440. * mprotect: (libc)Memory Protection.
  1441. * mrand48: (libc)SVID Random.
  1442. * mrand48_r: (libc)SVID Random.
  1443. * mremap: (libc)Memory-mapped I/O.
  1444. * msync: (libc)Memory-mapped I/O.
  1445. * mtrace: (libc)Tracing malloc.
  1446. * mtx_destroy: (libc)ISO C Mutexes.
  1447. * mtx_init: (libc)ISO C Mutexes.
  1448. * mtx_lock: (libc)ISO C Mutexes.
  1449. * mtx_timedlock: (libc)ISO C Mutexes.
  1450. * mtx_trylock: (libc)ISO C Mutexes.
  1451. * mtx_unlock: (libc)ISO C Mutexes.
  1452. * munlock: (libc)Page Lock Functions.
  1453. * munlockall: (libc)Page Lock Functions.
  1454. * munmap: (libc)Memory-mapped I/O.
  1455. * muntrace: (libc)Tracing malloc.
  1456. * nan: (libc)FP Bit Twiddling.
  1457. * nanf: (libc)FP Bit Twiddling.
  1458. * nanfN: (libc)FP Bit Twiddling.
  1459. * nanfNx: (libc)FP Bit Twiddling.
  1460. * nanl: (libc)FP Bit Twiddling.
  1461. * nanosleep: (libc)Sleeping.
  1462. * nearbyint: (libc)Rounding Functions.
  1463. * nearbyintf: (libc)Rounding Functions.
  1464. * nearbyintfN: (libc)Rounding Functions.
  1465. * nearbyintfNx: (libc)Rounding Functions.
  1466. * nearbyintl: (libc)Rounding Functions.
  1467. * nextafter: (libc)FP Bit Twiddling.
  1468. * nextafterf: (libc)FP Bit Twiddling.
  1469. * nextafterfN: (libc)FP Bit Twiddling.
  1470. * nextafterfNx: (libc)FP Bit Twiddling.
  1471. * nextafterl: (libc)FP Bit Twiddling.
  1472. * nextdown: (libc)FP Bit Twiddling.
  1473. * nextdownf: (libc)FP Bit Twiddling.
  1474. * nextdownfN: (libc)FP Bit Twiddling.
  1475. * nextdownfNx: (libc)FP Bit Twiddling.
  1476. * nextdownl: (libc)FP Bit Twiddling.
  1477. * nexttoward: (libc)FP Bit Twiddling.
  1478. * nexttowardf: (libc)FP Bit Twiddling.
  1479. * nexttowardl: (libc)FP Bit Twiddling.
  1480. * nextup: (libc)FP Bit Twiddling.
  1481. * nextupf: (libc)FP Bit Twiddling.
  1482. * nextupfN: (libc)FP Bit Twiddling.
  1483. * nextupfNx: (libc)FP Bit Twiddling.
  1484. * nextupl: (libc)FP Bit Twiddling.
  1485. * nftw64: (libc)Working with Directory Trees.
  1486. * nftw: (libc)Working with Directory Trees.
  1487. * ngettext: (libc)Advanced gettext functions.
  1488. * nice: (libc)Traditional Scheduling Functions.
  1489. * nl_langinfo: (libc)The Elegant and Fast Way.
  1490. * nrand48: (libc)SVID Random.
  1491. * nrand48_r: (libc)SVID Random.
  1492. * ntohl: (libc)Byte Order.
  1493. * ntohs: (libc)Byte Order.
  1494. * ntp_adjtime: (libc)Setting and Adjusting the Time.
  1495. * ntp_gettime: (libc)Setting and Adjusting the Time.
  1496. * obstack_1grow: (libc)Growing Objects.
  1497. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1498. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1499. * obstack_alloc: (libc)Allocation in an Obstack.
  1500. * obstack_base: (libc)Status of an Obstack.
  1501. * obstack_blank: (libc)Growing Objects.
  1502. * obstack_blank_fast: (libc)Extra Fast Growing.
  1503. * obstack_chunk_size: (libc)Obstack Chunks.
  1504. * obstack_copy0: (libc)Allocation in an Obstack.
  1505. * obstack_copy: (libc)Allocation in an Obstack.
  1506. * obstack_finish: (libc)Growing Objects.
  1507. * obstack_free: (libc)Freeing Obstack Objects.
  1508. * obstack_grow0: (libc)Growing Objects.
  1509. * obstack_grow: (libc)Growing Objects.
  1510. * obstack_init: (libc)Preparing for Obstacks.
  1511. * obstack_int_grow: (libc)Growing Objects.
  1512. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1513. * obstack_next_free: (libc)Status of an Obstack.
  1514. * obstack_object_size: (libc)Growing Objects.
  1515. * obstack_object_size: (libc)Status of an Obstack.
  1516. * obstack_printf: (libc)Dynamic Output.
  1517. * obstack_ptr_grow: (libc)Growing Objects.
  1518. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1519. * obstack_room: (libc)Extra Fast Growing.
  1520. * obstack_vprintf: (libc)Variable Arguments Output.
  1521. * offsetof: (libc)Structure Measurement.
  1522. * on_exit: (libc)Cleanups on Exit.
  1523. * open64: (libc)Opening and Closing Files.
  1524. * open: (libc)Opening and Closing Files.
  1525. * open_memstream: (libc)String Streams.
  1526. * opendir: (libc)Opening a Directory.
  1527. * openlog: (libc)openlog.
  1528. * openpty: (libc)Pseudo-Terminal Pairs.
  1529. * parse_printf_format: (libc)Parsing a Template String.
  1530. * pathconf: (libc)Pathconf.
  1531. * pause: (libc)Using Pause.
  1532. * pclose: (libc)Pipe to a Subprocess.
  1533. * perror: (libc)Error Messages.
  1534. * pipe: (libc)Creating a Pipe.
  1535. * pkey_alloc: (libc)Memory Protection.
  1536. * pkey_free: (libc)Memory Protection.
  1537. * pkey_get: (libc)Memory Protection.
  1538. * pkey_mprotect: (libc)Memory Protection.
  1539. * pkey_set: (libc)Memory Protection.
  1540. * popen: (libc)Pipe to a Subprocess.
  1541. * posix_fallocate64: (libc)Storage Allocation.
  1542. * posix_fallocate: (libc)Storage Allocation.
  1543. * posix_memalign: (libc)Aligned Memory Blocks.
  1544. * pow: (libc)Exponents and Logarithms.
  1545. * powf: (libc)Exponents and Logarithms.
  1546. * powfN: (libc)Exponents and Logarithms.
  1547. * powfNx: (libc)Exponents and Logarithms.
  1548. * powl: (libc)Exponents and Logarithms.
  1549. * pread64: (libc)I/O Primitives.
  1550. * pread: (libc)I/O Primitives.
  1551. * preadv2: (libc)Scatter-Gather.
  1552. * preadv64: (libc)Scatter-Gather.
  1553. * preadv64v2: (libc)Scatter-Gather.
  1554. * preadv: (libc)Scatter-Gather.
  1555. * printf: (libc)Formatted Output Functions.
  1556. * printf_size: (libc)Predefined Printf Handlers.
  1557. * printf_size_info: (libc)Predefined Printf Handlers.
  1558. * psignal: (libc)Signal Messages.
  1559. * pthread_attr_getsigmask_np: (libc)Initial Thread Signal Mask.
  1560. * pthread_attr_setsigmask_np: (libc)Initial Thread Signal Mask.
  1561. * pthread_clockjoin_np: (libc)Waiting with Explicit Clocks.
  1562. * pthread_cond_clockwait: (libc)Waiting with Explicit Clocks.
  1563. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1564. * pthread_getspecific: (libc)Thread-specific Data.
  1565. * pthread_key_create: (libc)Thread-specific Data.
  1566. * pthread_key_delete: (libc)Thread-specific Data.
  1567. * pthread_rwlock_clockrdlock: (libc)Waiting with Explicit Clocks.
  1568. * pthread_rwlock_clockwrlock: (libc)Waiting with Explicit Clocks.
  1569. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1570. * pthread_setspecific: (libc)Thread-specific Data.
  1571. * pthread_timedjoin_np: (libc)Waiting with Explicit Clocks.
  1572. * pthread_tryjoin_np: (libc)Waiting with Explicit Clocks.
  1573. * ptsname: (libc)Allocation.
  1574. * ptsname_r: (libc)Allocation.
  1575. * putc: (libc)Simple Output.
  1576. * putc_unlocked: (libc)Simple Output.
  1577. * putchar: (libc)Simple Output.
  1578. * putchar_unlocked: (libc)Simple Output.
  1579. * putenv: (libc)Environment Access.
  1580. * putpwent: (libc)Writing a User Entry.
  1581. * puts: (libc)Simple Output.
  1582. * pututline: (libc)Manipulating the Database.
  1583. * pututxline: (libc)XPG Functions.
  1584. * putw: (libc)Simple Output.
  1585. * putwc: (libc)Simple Output.
  1586. * putwc_unlocked: (libc)Simple Output.
  1587. * putwchar: (libc)Simple Output.
  1588. * putwchar_unlocked: (libc)Simple Output.
  1589. * pwrite64: (libc)I/O Primitives.
  1590. * pwrite: (libc)I/O Primitives.
  1591. * pwritev2: (libc)Scatter-Gather.
  1592. * pwritev64: (libc)Scatter-Gather.
  1593. * pwritev64v2: (libc)Scatter-Gather.
  1594. * pwritev: (libc)Scatter-Gather.
  1595. * qecvt: (libc)System V Number Conversion.
  1596. * qecvt_r: (libc)System V Number Conversion.
  1597. * qfcvt: (libc)System V Number Conversion.
  1598. * qfcvt_r: (libc)System V Number Conversion.
  1599. * qgcvt: (libc)System V Number Conversion.
  1600. * qsort: (libc)Array Sort Function.
  1601. * raise: (libc)Signaling Yourself.
  1602. * rand: (libc)ISO Random.
  1603. * rand_r: (libc)ISO Random.
  1604. * random: (libc)BSD Random.
  1605. * random_r: (libc)BSD Random.
  1606. * rawmemchr: (libc)Search Functions.
  1607. * read: (libc)I/O Primitives.
  1608. * readdir64: (libc)Reading/Closing Directory.
  1609. * readdir64_r: (libc)Reading/Closing Directory.
  1610. * readdir: (libc)Reading/Closing Directory.
  1611. * readdir_r: (libc)Reading/Closing Directory.
  1612. * readlink: (libc)Symbolic Links.
  1613. * readv: (libc)Scatter-Gather.
  1614. * realloc: (libc)Changing Block Size.
  1615. * reallocarray: (libc)Changing Block Size.
  1616. * realpath: (libc)Symbolic Links.
  1617. * recv: (libc)Receiving Data.
  1618. * recvfrom: (libc)Receiving Datagrams.
  1619. * recvmsg: (libc)Receiving Datagrams.
  1620. * regcomp: (libc)POSIX Regexp Compilation.
  1621. * regerror: (libc)Regexp Cleanup.
  1622. * regexec: (libc)Matching POSIX Regexps.
  1623. * regfree: (libc)Regexp Cleanup.
  1624. * register_printf_function: (libc)Registering New Conversions.
  1625. * remainder: (libc)Remainder Functions.
  1626. * remainderf: (libc)Remainder Functions.
  1627. * remainderfN: (libc)Remainder Functions.
  1628. * remainderfNx: (libc)Remainder Functions.
  1629. * remainderl: (libc)Remainder Functions.
  1630. * remove: (libc)Deleting Files.
  1631. * rename: (libc)Renaming Files.
  1632. * rewind: (libc)File Positioning.
  1633. * rewinddir: (libc)Random Access Directory.
  1634. * rindex: (libc)Search Functions.
  1635. * rint: (libc)Rounding Functions.
  1636. * rintf: (libc)Rounding Functions.
  1637. * rintfN: (libc)Rounding Functions.
  1638. * rintfNx: (libc)Rounding Functions.
  1639. * rintl: (libc)Rounding Functions.
  1640. * rmdir: (libc)Deleting Files.
  1641. * round: (libc)Rounding Functions.
  1642. * roundeven: (libc)Rounding Functions.
  1643. * roundevenf: (libc)Rounding Functions.
  1644. * roundevenfN: (libc)Rounding Functions.
  1645. * roundevenfNx: (libc)Rounding Functions.
  1646. * roundevenl: (libc)Rounding Functions.
  1647. * roundf: (libc)Rounding Functions.
  1648. * roundfN: (libc)Rounding Functions.
  1649. * roundfNx: (libc)Rounding Functions.
  1650. * roundl: (libc)Rounding Functions.
  1651. * rpmatch: (libc)Yes-or-No Questions.
  1652. * sbrk: (libc)Resizing the Data Segment.
  1653. * scalb: (libc)Normalization Functions.
  1654. * scalbf: (libc)Normalization Functions.
  1655. * scalbl: (libc)Normalization Functions.
  1656. * scalbln: (libc)Normalization Functions.
  1657. * scalblnf: (libc)Normalization Functions.
  1658. * scalblnfN: (libc)Normalization Functions.
  1659. * scalblnfNx: (libc)Normalization Functions.
  1660. * scalblnl: (libc)Normalization Functions.
  1661. * scalbn: (libc)Normalization Functions.
  1662. * scalbnf: (libc)Normalization Functions.
  1663. * scalbnfN: (libc)Normalization Functions.
  1664. * scalbnfNx: (libc)Normalization Functions.
  1665. * scalbnl: (libc)Normalization Functions.
  1666. * scandir64: (libc)Scanning Directory Content.
  1667. * scandir: (libc)Scanning Directory Content.
  1668. * scanf: (libc)Formatted Input Functions.
  1669. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1670. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1671. * sched_getaffinity: (libc)CPU Affinity.
  1672. * sched_getparam: (libc)Basic Scheduling Functions.
  1673. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1674. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1675. * sched_setaffinity: (libc)CPU Affinity.
  1676. * sched_setparam: (libc)Basic Scheduling Functions.
  1677. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1678. * sched_yield: (libc)Basic Scheduling Functions.
  1679. * secure_getenv: (libc)Environment Access.
  1680. * seed48: (libc)SVID Random.
  1681. * seed48_r: (libc)SVID Random.
  1682. * seekdir: (libc)Random Access Directory.
  1683. * select: (libc)Waiting for I/O.
  1684. * sem_clockwait: (libc)Waiting with Explicit Clocks.
  1685. * sem_close: (libc)Semaphores.
  1686. * sem_destroy: (libc)Semaphores.
  1687. * sem_getvalue: (libc)Semaphores.
  1688. * sem_init: (libc)Semaphores.
  1689. * sem_open: (libc)Semaphores.
  1690. * sem_post: (libc)Semaphores.
  1691. * sem_timedwait: (libc)Semaphores.
  1692. * sem_trywait: (libc)Semaphores.
  1693. * sem_unlink: (libc)Semaphores.
  1694. * sem_wait: (libc)Semaphores.
  1695. * semctl: (libc)Semaphores.
  1696. * semget: (libc)Semaphores.
  1697. * semop: (libc)Semaphores.
  1698. * semtimedop: (libc)Semaphores.
  1699. * send: (libc)Sending Data.
  1700. * sendmsg: (libc)Receiving Datagrams.
  1701. * sendto: (libc)Sending Datagrams.
  1702. * setbuf: (libc)Controlling Buffering.
  1703. * setbuffer: (libc)Controlling Buffering.
  1704. * setcontext: (libc)System V contexts.
  1705. * setdomainname: (libc)Host Identification.
  1706. * setegid: (libc)Setting Groups.
  1707. * setenv: (libc)Environment Access.
  1708. * seteuid: (libc)Setting User ID.
  1709. * setfsent: (libc)fstab.
  1710. * setgid: (libc)Setting Groups.
  1711. * setgrent: (libc)Scanning All Groups.
  1712. * setgroups: (libc)Setting Groups.
  1713. * sethostent: (libc)Host Names.
  1714. * sethostid: (libc)Host Identification.
  1715. * sethostname: (libc)Host Identification.
  1716. * setitimer: (libc)Setting an Alarm.
  1717. * setjmp: (libc)Non-Local Details.
  1718. * setlinebuf: (libc)Controlling Buffering.
  1719. * setlocale: (libc)Setting the Locale.
  1720. * setlogmask: (libc)setlogmask.
  1721. * setmntent: (libc)mtab.
  1722. * setnetent: (libc)Networks Database.
  1723. * setnetgrent: (libc)Lookup Netgroup.
  1724. * setpayload: (libc)FP Bit Twiddling.
  1725. * setpayloadf: (libc)FP Bit Twiddling.
  1726. * setpayloadfN: (libc)FP Bit Twiddling.
  1727. * setpayloadfNx: (libc)FP Bit Twiddling.
  1728. * setpayloadl: (libc)FP Bit Twiddling.
  1729. * setpayloadsig: (libc)FP Bit Twiddling.
  1730. * setpayloadsigf: (libc)FP Bit Twiddling.
  1731. * setpayloadsigfN: (libc)FP Bit Twiddling.
  1732. * setpayloadsigfNx: (libc)FP Bit Twiddling.
  1733. * setpayloadsigl: (libc)FP Bit Twiddling.
  1734. * setpgid: (libc)Process Group Functions.
  1735. * setpgrp: (libc)Process Group Functions.
  1736. * setpriority: (libc)Traditional Scheduling Functions.
  1737. * setprotoent: (libc)Protocols Database.
  1738. * setpwent: (libc)Scanning All Users.
  1739. * setregid: (libc)Setting Groups.
  1740. * setreuid: (libc)Setting User ID.
  1741. * setrlimit64: (libc)Limits on Resources.
  1742. * setrlimit: (libc)Limits on Resources.
  1743. * setservent: (libc)Services Database.
  1744. * setsid: (libc)Process Group Functions.
  1745. * setsockopt: (libc)Socket Option Functions.
  1746. * setstate: (libc)BSD Random.
  1747. * setstate_r: (libc)BSD Random.
  1748. * settimeofday: (libc)Setting and Adjusting the Time.
  1749. * setuid: (libc)Setting User ID.
  1750. * setutent: (libc)Manipulating the Database.
  1751. * setutxent: (libc)XPG Functions.
  1752. * setvbuf: (libc)Controlling Buffering.
  1753. * shm_open: (libc)Memory-mapped I/O.
  1754. * shm_unlink: (libc)Memory-mapped I/O.
  1755. * shutdown: (libc)Closing a Socket.
  1756. * sigabbrev_np: (libc)Signal Messages.
  1757. * sigaction: (libc)Advanced Signal Handling.
  1758. * sigaddset: (libc)Signal Sets.
  1759. * sigaltstack: (libc)Signal Stack.
  1760. * sigblock: (libc)BSD Signal Handling.
  1761. * sigdelset: (libc)Signal Sets.
  1762. * sigdescr_np: (libc)Signal Messages.
  1763. * sigemptyset: (libc)Signal Sets.
  1764. * sigfillset: (libc)Signal Sets.
  1765. * siginterrupt: (libc)BSD Signal Handling.
  1766. * sigismember: (libc)Signal Sets.
  1767. * siglongjmp: (libc)Non-Local Exits and Signals.
  1768. * sigmask: (libc)BSD Signal Handling.
  1769. * signal: (libc)Basic Signal Handling.
  1770. * signbit: (libc)FP Bit Twiddling.
  1771. * significand: (libc)Normalization Functions.
  1772. * significandf: (libc)Normalization Functions.
  1773. * significandl: (libc)Normalization Functions.
  1774. * sigpause: (libc)BSD Signal Handling.
  1775. * sigpending: (libc)Checking for Pending Signals.
  1776. * sigprocmask: (libc)Process Signal Mask.
  1777. * sigsetjmp: (libc)Non-Local Exits and Signals.
  1778. * sigsetmask: (libc)BSD Signal Handling.
  1779. * sigstack: (libc)Signal Stack.
  1780. * sigsuspend: (libc)Sigsuspend.
  1781. * sin: (libc)Trig Functions.
  1782. * sincos: (libc)Trig Functions.
  1783. * sincosf: (libc)Trig Functions.
  1784. * sincosfN: (libc)Trig Functions.
  1785. * sincosfNx: (libc)Trig Functions.
  1786. * sincosl: (libc)Trig Functions.
  1787. * sinf: (libc)Trig Functions.
  1788. * sinfN: (libc)Trig Functions.
  1789. * sinfNx: (libc)Trig Functions.
  1790. * sinh: (libc)Hyperbolic Functions.
  1791. * sinhf: (libc)Hyperbolic Functions.
  1792. * sinhfN: (libc)Hyperbolic Functions.
  1793. * sinhfNx: (libc)Hyperbolic Functions.
  1794. * sinhl: (libc)Hyperbolic Functions.
  1795. * sinl: (libc)Trig Functions.
  1796. * sleep: (libc)Sleeping.
  1797. * snprintf: (libc)Formatted Output Functions.
  1798. * socket: (libc)Creating a Socket.
  1799. * socketpair: (libc)Socket Pairs.
  1800. * sprintf: (libc)Formatted Output Functions.
  1801. * sqrt: (libc)Exponents and Logarithms.
  1802. * sqrtf: (libc)Exponents and Logarithms.
  1803. * sqrtfN: (libc)Exponents and Logarithms.
  1804. * sqrtfNx: (libc)Exponents and Logarithms.
  1805. * sqrtl: (libc)Exponents and Logarithms.
  1806. * srand48: (libc)SVID Random.
  1807. * srand48_r: (libc)SVID Random.
  1808. * srand: (libc)ISO Random.
  1809. * srandom: (libc)BSD Random.
  1810. * srandom_r: (libc)BSD Random.
  1811. * sscanf: (libc)Formatted Input Functions.
  1812. * ssignal: (libc)Basic Signal Handling.
  1813. * stat64: (libc)Reading Attributes.
  1814. * stat: (libc)Reading Attributes.
  1815. * stime: (libc)Setting and Adjusting the Time.
  1816. * stpcpy: (libc)Copying Strings and Arrays.
  1817. * stpncpy: (libc)Truncating Strings.
  1818. * strcasecmp: (libc)String/Array Comparison.
  1819. * strcasestr: (libc)Search Functions.
  1820. * strcat: (libc)Concatenating Strings.
  1821. * strchr: (libc)Search Functions.
  1822. * strchrnul: (libc)Search Functions.
  1823. * strcmp: (libc)String/Array Comparison.
  1824. * strcoll: (libc)Collation Functions.
  1825. * strcpy: (libc)Copying Strings and Arrays.
  1826. * strcspn: (libc)Search Functions.
  1827. * strdup: (libc)Copying Strings and Arrays.
  1828. * strdupa: (libc)Copying Strings and Arrays.
  1829. * strerror: (libc)Error Messages.
  1830. * strerror_r: (libc)Error Messages.
  1831. * strerrordesc_np: (libc)Error Messages.
  1832. * strerrorname_np: (libc)Error Messages.
  1833. * strfmon: (libc)Formatting Numbers.
  1834. * strfromd: (libc)Printing of Floats.
  1835. * strfromf: (libc)Printing of Floats.
  1836. * strfromfN: (libc)Printing of Floats.
  1837. * strfromfNx: (libc)Printing of Floats.
  1838. * strfroml: (libc)Printing of Floats.
  1839. * strfry: (libc)Shuffling Bytes.
  1840. * strftime: (libc)Formatting Calendar Time.
  1841. * strlen: (libc)String Length.
  1842. * strncasecmp: (libc)String/Array Comparison.
  1843. * strncat: (libc)Truncating Strings.
  1844. * strncmp: (libc)String/Array Comparison.
  1845. * strncpy: (libc)Truncating Strings.
  1846. * strndup: (libc)Truncating Strings.
  1847. * strndupa: (libc)Truncating Strings.
  1848. * strnlen: (libc)String Length.
  1849. * strpbrk: (libc)Search Functions.
  1850. * strptime: (libc)Low-Level Time String Parsing.
  1851. * strrchr: (libc)Search Functions.
  1852. * strsep: (libc)Finding Tokens in a String.
  1853. * strsignal: (libc)Signal Messages.
  1854. * strspn: (libc)Search Functions.
  1855. * strstr: (libc)Search Functions.
  1856. * strtod: (libc)Parsing of Floats.
  1857. * strtof: (libc)Parsing of Floats.
  1858. * strtofN: (libc)Parsing of Floats.
  1859. * strtofNx: (libc)Parsing of Floats.
  1860. * strtoimax: (libc)Parsing of Integers.
  1861. * strtok: (libc)Finding Tokens in a String.
  1862. * strtok_r: (libc)Finding Tokens in a String.
  1863. * strtol: (libc)Parsing of Integers.
  1864. * strtold: (libc)Parsing of Floats.
  1865. * strtoll: (libc)Parsing of Integers.
  1866. * strtoq: (libc)Parsing of Integers.
  1867. * strtoul: (libc)Parsing of Integers.
  1868. * strtoull: (libc)Parsing of Integers.
  1869. * strtoumax: (libc)Parsing of Integers.
  1870. * strtouq: (libc)Parsing of Integers.
  1871. * strverscmp: (libc)String/Array Comparison.
  1872. * strxfrm: (libc)Collation Functions.
  1873. * stty: (libc)BSD Terminal Modes.
  1874. * swapcontext: (libc)System V contexts.
  1875. * swprintf: (libc)Formatted Output Functions.
  1876. * swscanf: (libc)Formatted Input Functions.
  1877. * symlink: (libc)Symbolic Links.
  1878. * sync: (libc)Synchronizing I/O.
  1879. * syscall: (libc)System Calls.
  1880. * sysconf: (libc)Sysconf Definition.
  1881. * syslog: (libc)syslog; vsyslog.
  1882. * system: (libc)Running a Command.
  1883. * sysv_signal: (libc)Basic Signal Handling.
  1884. * tan: (libc)Trig Functions.
  1885. * tanf: (libc)Trig Functions.
  1886. * tanfN: (libc)Trig Functions.
  1887. * tanfNx: (libc)Trig Functions.
  1888. * tanh: (libc)Hyperbolic Functions.
  1889. * tanhf: (libc)Hyperbolic Functions.
  1890. * tanhfN: (libc)Hyperbolic Functions.
  1891. * tanhfNx: (libc)Hyperbolic Functions.
  1892. * tanhl: (libc)Hyperbolic Functions.
  1893. * tanl: (libc)Trig Functions.
  1894. * tcdrain: (libc)Line Control.
  1895. * tcflow: (libc)Line Control.
  1896. * tcflush: (libc)Line Control.
  1897. * tcgetattr: (libc)Mode Functions.
  1898. * tcgetpgrp: (libc)Terminal Access Functions.
  1899. * tcgetsid: (libc)Terminal Access Functions.
  1900. * tcsendbreak: (libc)Line Control.
  1901. * tcsetattr: (libc)Mode Functions.
  1902. * tcsetpgrp: (libc)Terminal Access Functions.
  1903. * tdelete: (libc)Tree Search Function.
  1904. * tdestroy: (libc)Tree Search Function.
  1905. * telldir: (libc)Random Access Directory.
  1906. * tempnam: (libc)Temporary Files.
  1907. * textdomain: (libc)Locating gettext catalog.
  1908. * tfind: (libc)Tree Search Function.
  1909. * tgamma: (libc)Special Functions.
  1910. * tgammaf: (libc)Special Functions.
  1911. * tgammafN: (libc)Special Functions.
  1912. * tgammafNx: (libc)Special Functions.
  1913. * tgammal: (libc)Special Functions.
  1914. * tgkill: (libc)Signaling Another Process.
  1915. * thrd_create: (libc)ISO C Thread Management.
  1916. * thrd_current: (libc)ISO C Thread Management.
  1917. * thrd_detach: (libc)ISO C Thread Management.
  1918. * thrd_equal: (libc)ISO C Thread Management.
  1919. * thrd_exit: (libc)ISO C Thread Management.
  1920. * thrd_join: (libc)ISO C Thread Management.
  1921. * thrd_sleep: (libc)ISO C Thread Management.
  1922. * thrd_yield: (libc)ISO C Thread Management.
  1923. * time: (libc)Getting the Time.
  1924. * timegm: (libc)Broken-down Time.
  1925. * timelocal: (libc)Broken-down Time.
  1926. * times: (libc)Processor Time.
  1927. * tmpfile64: (libc)Temporary Files.
  1928. * tmpfile: (libc)Temporary Files.
  1929. * tmpnam: (libc)Temporary Files.
  1930. * tmpnam_r: (libc)Temporary Files.
  1931. * toascii: (libc)Case Conversion.
  1932. * tolower: (libc)Case Conversion.
  1933. * totalorder: (libc)FP Comparison Functions.
  1934. * totalorderf: (libc)FP Comparison Functions.
  1935. * totalorderfN: (libc)FP Comparison Functions.
  1936. * totalorderfNx: (libc)FP Comparison Functions.
  1937. * totalorderl: (libc)FP Comparison Functions.
  1938. * totalordermag: (libc)FP Comparison Functions.
  1939. * totalordermagf: (libc)FP Comparison Functions.
  1940. * totalordermagfN: (libc)FP Comparison Functions.
  1941. * totalordermagfNx: (libc)FP Comparison Functions.
  1942. * totalordermagl: (libc)FP Comparison Functions.
  1943. * toupper: (libc)Case Conversion.
  1944. * towctrans: (libc)Wide Character Case Conversion.
  1945. * towlower: (libc)Wide Character Case Conversion.
  1946. * towupper: (libc)Wide Character Case Conversion.
  1947. * trunc: (libc)Rounding Functions.
  1948. * truncate64: (libc)File Size.
  1949. * truncate: (libc)File Size.
  1950. * truncf: (libc)Rounding Functions.
  1951. * truncfN: (libc)Rounding Functions.
  1952. * truncfNx: (libc)Rounding Functions.
  1953. * truncl: (libc)Rounding Functions.
  1954. * tsearch: (libc)Tree Search Function.
  1955. * tss_create: (libc)ISO C Thread-local Storage.
  1956. * tss_delete: (libc)ISO C Thread-local Storage.
  1957. * tss_get: (libc)ISO C Thread-local Storage.
  1958. * tss_set: (libc)ISO C Thread-local Storage.
  1959. * ttyname: (libc)Is It a Terminal.
  1960. * ttyname_r: (libc)Is It a Terminal.
  1961. * twalk: (libc)Tree Search Function.
  1962. * twalk_r: (libc)Tree Search Function.
  1963. * tzset: (libc)Time Zone Functions.
  1964. * ufromfp: (libc)Rounding Functions.
  1965. * ufromfpf: (libc)Rounding Functions.
  1966. * ufromfpfN: (libc)Rounding Functions.
  1967. * ufromfpfNx: (libc)Rounding Functions.
  1968. * ufromfpl: (libc)Rounding Functions.
  1969. * ufromfpx: (libc)Rounding Functions.
  1970. * ufromfpxf: (libc)Rounding Functions.
  1971. * ufromfpxfN: (libc)Rounding Functions.
  1972. * ufromfpxfNx: (libc)Rounding Functions.
  1973. * ufromfpxl: (libc)Rounding Functions.
  1974. * ulimit: (libc)Limits on Resources.
  1975. * umask: (libc)Setting Permissions.
  1976. * umount2: (libc)Mount-Unmount-Remount.
  1977. * umount: (libc)Mount-Unmount-Remount.
  1978. * uname: (libc)Platform Type.
  1979. * ungetc: (libc)How Unread.
  1980. * ungetwc: (libc)How Unread.
  1981. * unlink: (libc)Deleting Files.
  1982. * unlockpt: (libc)Allocation.
  1983. * unsetenv: (libc)Environment Access.
  1984. * updwtmp: (libc)Manipulating the Database.
  1985. * utime: (libc)File Times.
  1986. * utimes: (libc)File Times.
  1987. * utmpname: (libc)Manipulating the Database.
  1988. * utmpxname: (libc)XPG Functions.
  1989. * va_arg: (libc)Argument Macros.
  1990. * va_copy: (libc)Argument Macros.
  1991. * va_end: (libc)Argument Macros.
  1992. * va_start: (libc)Argument Macros.
  1993. * valloc: (libc)Aligned Memory Blocks.
  1994. * vasprintf: (libc)Variable Arguments Output.
  1995. * verr: (libc)Error Messages.
  1996. * verrx: (libc)Error Messages.
  1997. * versionsort64: (libc)Scanning Directory Content.
  1998. * versionsort: (libc)Scanning Directory Content.
  1999. * vfork: (libc)Creating a Process.
  2000. * vfprintf: (libc)Variable Arguments Output.
  2001. * vfscanf: (libc)Variable Arguments Input.
  2002. * vfwprintf: (libc)Variable Arguments Output.
  2003. * vfwscanf: (libc)Variable Arguments Input.
  2004. * vlimit: (libc)Limits on Resources.
  2005. * vprintf: (libc)Variable Arguments Output.
  2006. * vscanf: (libc)Variable Arguments Input.
  2007. * vsnprintf: (libc)Variable Arguments Output.
  2008. * vsprintf: (libc)Variable Arguments Output.
  2009. * vsscanf: (libc)Variable Arguments Input.
  2010. * vswprintf: (libc)Variable Arguments Output.
  2011. * vswscanf: (libc)Variable Arguments Input.
  2012. * vsyslog: (libc)syslog; vsyslog.
  2013. * vwarn: (libc)Error Messages.
  2014. * vwarnx: (libc)Error Messages.
  2015. * vwprintf: (libc)Variable Arguments Output.
  2016. * vwscanf: (libc)Variable Arguments Input.
  2017. * wait3: (libc)BSD Wait Functions.
  2018. * wait4: (libc)Process Completion.
  2019. * wait: (libc)Process Completion.
  2020. * waitpid: (libc)Process Completion.
  2021. * warn: (libc)Error Messages.
  2022. * warnx: (libc)Error Messages.
  2023. * wcpcpy: (libc)Copying Strings and Arrays.
  2024. * wcpncpy: (libc)Truncating Strings.
  2025. * wcrtomb: (libc)Converting a Character.
  2026. * wcscasecmp: (libc)String/Array Comparison.
  2027. * wcscat: (libc)Concatenating Strings.
  2028. * wcschr: (libc)Search Functions.
  2029. * wcschrnul: (libc)Search Functions.
  2030. * wcscmp: (libc)String/Array Comparison.
  2031. * wcscoll: (libc)Collation Functions.
  2032. * wcscpy: (libc)Copying Strings and Arrays.
  2033. * wcscspn: (libc)Search Functions.
  2034. * wcsdup: (libc)Copying Strings and Arrays.
  2035. * wcsftime: (libc)Formatting Calendar Time.
  2036. * wcslen: (libc)String Length.
  2037. * wcsncasecmp: (libc)String/Array Comparison.
  2038. * wcsncat: (libc)Truncating Strings.
  2039. * wcsncmp: (libc)String/Array Comparison.
  2040. * wcsncpy: (libc)Truncating Strings.
  2041. * wcsnlen: (libc)String Length.
  2042. * wcsnrtombs: (libc)Converting Strings.
  2043. * wcspbrk: (libc)Search Functions.
  2044. * wcsrchr: (libc)Search Functions.
  2045. * wcsrtombs: (libc)Converting Strings.
  2046. * wcsspn: (libc)Search Functions.
  2047. * wcsstr: (libc)Search Functions.
  2048. * wcstod: (libc)Parsing of Floats.
  2049. * wcstof: (libc)Parsing of Floats.
  2050. * wcstofN: (libc)Parsing of Floats.
  2051. * wcstofNx: (libc)Parsing of Floats.
  2052. * wcstoimax: (libc)Parsing of Integers.
  2053. * wcstok: (libc)Finding Tokens in a String.
  2054. * wcstol: (libc)Parsing of Integers.
  2055. * wcstold: (libc)Parsing of Floats.
  2056. * wcstoll: (libc)Parsing of Integers.
  2057. * wcstombs: (libc)Non-reentrant String Conversion.
  2058. * wcstoq: (libc)Parsing of Integers.
  2059. * wcstoul: (libc)Parsing of Integers.
  2060. * wcstoull: (libc)Parsing of Integers.
  2061. * wcstoumax: (libc)Parsing of Integers.
  2062. * wcstouq: (libc)Parsing of Integers.
  2063. * wcswcs: (libc)Search Functions.
  2064. * wcsxfrm: (libc)Collation Functions.
  2065. * wctob: (libc)Converting a Character.
  2066. * wctomb: (libc)Non-reentrant Character Conversion.
  2067. * wctrans: (libc)Wide Character Case Conversion.
  2068. * wctype: (libc)Classification of Wide Characters.
  2069. * wmemchr: (libc)Search Functions.
  2070. * wmemcmp: (libc)String/Array Comparison.
  2071. * wmemcpy: (libc)Copying Strings and Arrays.
  2072. * wmemmove: (libc)Copying Strings and Arrays.
  2073. * wmempcpy: (libc)Copying Strings and Arrays.
  2074. * wmemset: (libc)Copying Strings and Arrays.
  2075. * wordexp: (libc)Calling Wordexp.
  2076. * wordfree: (libc)Calling Wordexp.
  2077. * wprintf: (libc)Formatted Output Functions.
  2078. * write: (libc)I/O Primitives.
  2079. * writev: (libc)Scatter-Gather.
  2080. * wscanf: (libc)Formatted Input Functions.
  2081. * y0: (libc)Special Functions.
  2082. * y0f: (libc)Special Functions.
  2083. * y0fN: (libc)Special Functions.
  2084. * y0fNx: (libc)Special Functions.
  2085. * y0l: (libc)Special Functions.
  2086. * y1: (libc)Special Functions.
  2087. * y1f: (libc)Special Functions.
  2088. * y1fN: (libc)Special Functions.
  2089. * y1fNx: (libc)Special Functions.
  2090. * y1l: (libc)Special Functions.
  2091. * yn: (libc)Special Functions.
  2092. * ynf: (libc)Special Functions.
  2093. * ynfN: (libc)Special Functions.
  2094. * ynfNx: (libc)Special Functions.
  2095. * ynl: (libc)Special Functions.
  2096. END-INFO-DIR-ENTRY
  2097. 
  2098. File: libc.info, Node: Descriptors and Streams, Next: Stream/Descriptor Precautions, Prev: File Position Primitive, Up: Low-Level I/O
  2099. 13.4 Descriptors and Streams
  2100. ============================
  2101. Given an open file descriptor, you can create a stream for it with the
  2102. ‘fdopen’ function. You can get the underlying file descriptor for an
  2103. existing stream with the ‘fileno’ function. These functions are
  2104. declared in the header file ‘stdio.h’.
  2105. -- Function: FILE * fdopen (int FILEDES, const char *OPENTYPE)
  2106. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem lock |
  2107. *Note POSIX Safety Concepts::.
  2108. The ‘fdopen’ function returns a new stream for the file descriptor
  2109. FILEDES.
  2110. The OPENTYPE argument is interpreted in the same way as for the
  2111. ‘fopen’ function (*note Opening Streams::), except that the ‘b’
  2112. option is not permitted; this is because GNU systems make no
  2113. distinction between text and binary files. Also, ‘"w"’ and ‘"w+"’
  2114. do not cause truncation of the file; these have an effect only when
  2115. opening a file, and in this case the file has already been opened.
  2116. You must make sure that the OPENTYPE argument matches the actual
  2117. mode of the open file descriptor.
  2118. The return value is the new stream. If the stream cannot be
  2119. created (for example, if the modes for the file indicated by the
  2120. file descriptor do not permit the access specified by the OPENTYPE
  2121. argument), a null pointer is returned instead.
  2122. In some other systems, ‘fdopen’ may fail to detect that the modes
  2123. for file descriptors do not permit the access specified by
  2124. ‘opentype’. The GNU C Library always checks for this.
  2125. For an example showing the use of the ‘fdopen’ function, see *note
  2126. Creating a Pipe::.
  2127. -- Function: int fileno (FILE *STREAM)
  2128. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2129. Concepts::.
  2130. This function returns the file descriptor associated with the
  2131. stream STREAM. If an error is detected (for example, if the STREAM
  2132. is not valid) or if STREAM does not do I/O to a file, ‘fileno’
  2133. returns -1.
  2134. -- Function: int fileno_unlocked (FILE *STREAM)
  2135. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2136. Concepts::.
  2137. The ‘fileno_unlocked’ function is equivalent to the ‘fileno’
  2138. function except that it does not implicitly lock the stream if the
  2139. state is ‘FSETLOCKING_INTERNAL’.
  2140. This function is a GNU extension.
  2141. There are also symbolic constants defined in ‘unistd.h’ for the file
  2142. descriptors belonging to the standard streams ‘stdin’, ‘stdout’, and
  2143. ‘stderr’; see *note Standard Streams::.
  2144. ‘STDIN_FILENO’
  2145. This macro has value ‘0’, which is the file descriptor for standard
  2146. input.
  2147. ‘STDOUT_FILENO’
  2148. This macro has value ‘1’, which is the file descriptor for standard
  2149. output.
  2150. ‘STDERR_FILENO’
  2151. This macro has value ‘2’, which is the file descriptor for standard
  2152. error output.
  2153. 
  2154. File: libc.info, Node: Stream/Descriptor Precautions, Next: Scatter-Gather, Prev: Descriptors and Streams, Up: Low-Level I/O
  2155. 13.5 Dangers of Mixing Streams and Descriptors
  2156. ==============================================
  2157. You can have multiple file descriptors and streams (let’s call both
  2158. streams and descriptors “channels” for short) connected to the same
  2159. file, but you must take care to avoid confusion between channels. There
  2160. are two cases to consider: “linked” channels that share a single file
  2161. position value, and “independent” channels that have their own file
  2162. positions.
  2163. It’s best to use just one channel in your program for actual data
  2164. transfer to any given file, except when all the access is for input.
  2165. For example, if you open a pipe (something you can only do at the file
  2166. descriptor level), either do all I/O with the descriptor, or construct a
  2167. stream from the descriptor with ‘fdopen’ and then do all I/O with the
  2168. stream.
  2169. * Menu:
  2170. * Linked Channels:: Dealing with channels sharing a file position.
  2171. * Independent Channels:: Dealing with separately opened, unlinked channels.
  2172. * Cleaning Streams:: Cleaning a stream makes it safe to use
  2173. another channel.
  2174. 
  2175. File: libc.info, Node: Linked Channels, Next: Independent Channels, Up: Stream/Descriptor Precautions
  2176. 13.5.1 Linked Channels
  2177. ----------------------
  2178. Channels that come from a single opening share the same file position;
  2179. we call them “linked” channels. Linked channels result when you make a
  2180. stream from a descriptor using ‘fdopen’, when you get a descriptor from
  2181. a stream with ‘fileno’, when you copy a descriptor with ‘dup’ or ‘dup2’,
  2182. and when descriptors are inherited during ‘fork’. For files that don’t
  2183. support random access, such as terminals and pipes, _all_ channels are
  2184. effectively linked. On random-access files, all append-type output
  2185. streams are effectively linked to each other.
  2186. If you have been using a stream for I/O (or have just opened the
  2187. stream), and you want to do I/O using another channel (either a stream
  2188. or a descriptor) that is linked to it, you must first “clean up” the
  2189. stream that you have been using. *Note Cleaning Streams::.
  2190. Terminating a process, or executing a new program in the process,
  2191. destroys all the streams in the process. If descriptors linked to these
  2192. streams persist in other processes, their file positions become
  2193. undefined as a result. To prevent this, you must clean up the streams
  2194. before destroying them.
  2195. 
  2196. File: libc.info, Node: Independent Channels, Next: Cleaning Streams, Prev: Linked Channels, Up: Stream/Descriptor Precautions
  2197. 13.5.2 Independent Channels
  2198. ---------------------------
  2199. When you open channels (streams or descriptors) separately on a seekable
  2200. file, each channel has its own file position. These are called
  2201. “independent channels”.
  2202. The system handles each channel independently. Most of the time,
  2203. this is quite predictable and natural (especially for input): each
  2204. channel can read or write sequentially at its own place in the file.
  2205. However, if some of the channels are streams, you must take these
  2206. precautions:
  2207. • You should clean an output stream after use, before doing anything
  2208. else that might read or write from the same part of the file.
  2209. • You should clean an input stream before reading data that may have
  2210. been modified using an independent channel. Otherwise, you might
  2211. read obsolete data that had been in the stream’s buffer.
  2212. If you do output to one channel at the end of the file, this will
  2213. certainly leave the other independent channels positioned somewhere
  2214. before the new end. You cannot reliably set their file positions to the
  2215. new end of file before writing, because the file can always be extended
  2216. by another process between when you set the file position and when you
  2217. write the data. Instead, use an append-type descriptor or stream; they
  2218. always output at the current end of the file. In order to make the
  2219. end-of-file position accurate, you must clean the output channel you
  2220. were using, if it is a stream.
  2221. It’s impossible for two channels to have separate file pointers for a
  2222. file that doesn’t support random access. Thus, channels for reading or
  2223. writing such files are always linked, never independent. Append-type
  2224. channels are also always linked. For these channels, follow the rules
  2225. for linked channels; see *note Linked Channels::.
  2226. 
  2227. File: libc.info, Node: Cleaning Streams, Prev: Independent Channels, Up: Stream/Descriptor Precautions
  2228. 13.5.3 Cleaning Streams
  2229. -----------------------
  2230. You can use ‘fflush’ to clean a stream in most cases.
  2231. You can skip the ‘fflush’ if you know the stream is already clean. A
  2232. stream is clean whenever its buffer is empty. For example, an
  2233. unbuffered stream is always clean. An input stream that is at
  2234. end-of-file is clean. A line-buffered stream is clean when the last
  2235. character output was a newline. However, a just-opened input stream
  2236. might not be clean, as its input buffer might not be empty.
  2237. There is one case in which cleaning a stream is impossible on most
  2238. systems. This is when the stream is doing input from a file that is not
  2239. random-access. Such streams typically read ahead, and when the file is
  2240. not random access, there is no way to give back the excess data already
  2241. read. When an input stream reads from a random-access file, ‘fflush’
  2242. does clean the stream, but leaves the file pointer at an unpredictable
  2243. place; you must set the file pointer before doing any further I/O.
  2244. Closing an output-only stream also does ‘fflush’, so this is a valid
  2245. way of cleaning an output stream.
  2246. You need not clean a stream before using its descriptor for control
  2247. operations such as setting terminal modes; these operations don’t affect
  2248. the file position and are not affected by it. You can use any
  2249. descriptor for these operations, and all channels are affected
  2250. simultaneously. However, text already “output” to a stream but still
  2251. buffered by the stream will be subject to the new terminal modes when
  2252. subsequently flushed. To make sure “past” output is covered by the
  2253. terminal settings that were in effect at the time, flush the output
  2254. streams for that terminal before setting the modes. *Note Terminal
  2255. Modes::.
  2256. 
  2257. File: libc.info, Node: Scatter-Gather, Next: Copying File Data, Prev: Stream/Descriptor Precautions, Up: Low-Level I/O
  2258. 13.6 Fast Scatter-Gather I/O
  2259. ============================
  2260. Some applications may need to read or write data to multiple buffers,
  2261. which are separated in memory. Although this can be done easily enough
  2262. with multiple calls to ‘read’ and ‘write’, it is inefficient because
  2263. there is overhead associated with each kernel call.
  2264. Instead, many platforms provide special high-speed primitives to
  2265. perform these “scatter-gather” operations in a single kernel call. The
  2266. GNU C Library will provide an emulation on any system that lacks these
  2267. primitives, so they are not a portability threat. They are defined in
  2268. ‘sys/uio.h’.
  2269. These functions are controlled with arrays of ‘iovec’ structures,
  2270. which describe the location and size of each buffer.
  2271. -- Data Type: struct iovec
  2272. The ‘iovec’ structure describes a buffer. It contains two fields:
  2273. ‘void *iov_base’
  2274. Contains the address of a buffer.
  2275. ‘size_t iov_len’
  2276. Contains the length of the buffer.
  2277. -- Function: ssize_t readv (int FILEDES, const struct iovec *VECTOR,
  2278. int COUNT)
  2279. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  2280. POSIX Safety Concepts::.
  2281. The ‘readv’ function reads data from FILEDES and scatters it into
  2282. the buffers described in VECTOR, which is taken to be COUNT
  2283. structures long. As each buffer is filled, data is sent to the
  2284. next.
  2285. Note that ‘readv’ is not guaranteed to fill all the buffers. It
  2286. may stop at any point, for the same reasons ‘read’ would.
  2287. The return value is a count of bytes (_not_ buffers) read, 0
  2288. indicating end-of-file, or -1 indicating an error. The possible
  2289. errors are the same as in ‘read’.
  2290. -- Function: ssize_t writev (int FILEDES, const struct iovec *VECTOR,
  2291. int COUNT)
  2292. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  2293. POSIX Safety Concepts::.
  2294. The ‘writev’ function gathers data from the buffers described in
  2295. VECTOR, which is taken to be COUNT structures long, and writes them
  2296. to ‘filedes’. As each buffer is written, it moves on to the next.
  2297. Like ‘readv’, ‘writev’ may stop midstream under the same conditions
  2298. ‘write’ would.
  2299. The return value is a count of bytes written, or -1 indicating an
  2300. error. The possible errors are the same as in ‘write’.
  2301. -- Function: ssize_t preadv (int FD, const struct iovec *IOV, int
  2302. IOVCNT, off_t OFFSET)
  2303. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2304. Concepts::.
  2305. This function is similar to the ‘readv’ function, with the
  2306. difference it adds an extra OFFSET parameter of type ‘off_t’
  2307. similar to ‘pread’. The data is written to the file starting at
  2308. position OFFSET. The position of the file descriptor itself is not
  2309. affected by the operation. The value is the same as before the
  2310. call.
  2311. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  2312. ‘preadv’ function is in fact ‘preadv64’ and the type ‘off_t’ has 64
  2313. bits, which makes it possible to handle files up to 2^63 bytes in
  2314. length.
  2315. The return value is a count of bytes (_not_ buffers) read, 0
  2316. indicating end-of-file, or -1 indicating an error. The possible
  2317. errors are the same as in ‘readv’ and ‘pread’.
  2318. -- Function: ssize_t preadv64 (int FD, const struct iovec *IOV, int
  2319. IOVCNT, off64_t OFFSET)
  2320. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2321. Concepts::.
  2322. This function is similar to the ‘preadv’ function with the
  2323. difference is that the OFFSET parameter is of type ‘off64_t’
  2324. instead of ‘off_t’. It makes it possible on 32 bit machines to
  2325. address files larger than 2^31 bytes and up to 2^63 bytes. The
  2326. file descriptor ‘filedes’ must be opened using ‘open64’ since
  2327. otherwise the large offsets possible with ‘off64_t’ will lead to
  2328. errors with a descriptor in small file mode.
  2329. When the source file is compiled using ‘_FILE_OFFSET_BITS == 64’ on
  2330. a 32 bit machine this function is actually available under the name
  2331. ‘preadv’ and so transparently replaces the 32 bit interface.
  2332. -- Function: ssize_t pwritev (int FD, const struct iovec *IOV, int
  2333. IOVCNT, off_t OFFSET)
  2334. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2335. Concepts::.
  2336. This function is similar to the ‘writev’ function, with the
  2337. difference it adds an extra OFFSET parameter of type ‘off_t’
  2338. similar to ‘pwrite’. The data is written to the file starting at
  2339. position OFFSET. The position of the file descriptor itself is not
  2340. affected by the operation. The value is the same as before the
  2341. call.
  2342. However, on Linux, if a file is opened with ‘O_APPEND’, ‘pwrite’
  2343. appends data to the end of the file, regardless of the value of
  2344. ‘offset’.
  2345. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  2346. ‘pwritev’ function is in fact ‘pwritev64’ and the type ‘off_t’ has
  2347. 64 bits, which makes it possible to handle files up to 2^63 bytes
  2348. in length.
  2349. The return value is a count of bytes (_not_ buffers) written, 0
  2350. indicating end-of-file, or -1 indicating an error. The possible
  2351. errors are the same as in ‘writev’ and ‘pwrite’.
  2352. -- Function: ssize_t pwritev64 (int FD, const struct iovec *IOV, int
  2353. IOVCNT, off64_t OFFSET)
  2354. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2355. Concepts::.
  2356. This function is similar to the ‘pwritev’ function with the
  2357. difference is that the OFFSET parameter is of type ‘off64_t’
  2358. instead of ‘off_t’. It makes it possible on 32 bit machines to
  2359. address files larger than 2^31 bytes and up to 2^63 bytes. The
  2360. file descriptor ‘filedes’ must be opened using ‘open64’ since
  2361. otherwise the large offsets possible with ‘off64_t’ will lead to
  2362. errors with a descriptor in small file mode.
  2363. When the source file is compiled using ‘_FILE_OFFSET_BITS == 64’ on
  2364. a 32 bit machine this function is actually available under the name
  2365. ‘pwritev’ and so transparently replaces the 32 bit interface.
  2366. -- Function: ssize_t preadv2 (int FD, const struct iovec *IOV, int
  2367. IOVCNT, off_t OFFSET, int FLAGS)
  2368. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2369. Concepts::.
  2370. This function is similar to the ‘preadv’ function, with the
  2371. difference it adds an extra FLAGS parameter of type ‘int’.
  2372. Additionally, if OFFSET is -1, the current file position is used
  2373. and updated (like the ‘readv’ function).
  2374. The supported FLAGS are dependent of the underlying system. For
  2375. Linux it supports:
  2376. ‘RWF_HIPRI’
  2377. High priority request. This adds a flag that tells the file
  2378. system that this is a high priority request for which it is
  2379. worth to poll the hardware. The flag is purely advisory and
  2380. can be ignored if not supported. The FD must be opened using
  2381. ‘O_DIRECT’.
  2382. ‘RWF_DSYNC’
  2383. Per-IO synchronization as if the file was opened with
  2384. ‘O_DSYNC’ flag.
  2385. ‘RWF_SYNC’
  2386. Per-IO synchronization as if the file was opened with ‘O_SYNC’
  2387. flag.
  2388. ‘RWF_NOWAIT’
  2389. Use nonblocking mode for this operation; that is, this call to
  2390. ‘preadv2’ will fail and set ‘errno’ to ‘EAGAIN’ if the
  2391. operation would block.
  2392. ‘RWF_APPEND’
  2393. Per-IO synchronization as if the file was opened with
  2394. ‘O_APPEND’ flag.
  2395. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  2396. ‘preadv2’ function is in fact ‘preadv64v2’ and the type ‘off_t’ has
  2397. 64 bits, which makes it possible to handle files up to 2^63 bytes
  2398. in length.
  2399. The return value is a count of bytes (_not_ buffers) read, 0
  2400. indicating end-of-file, or -1 indicating an error. The possible
  2401. errors are the same as in ‘preadv’ with the addition of:
  2402. ‘EOPNOTSUPP’
  2403. An unsupported FLAGS was used.
  2404. -- Function: ssize_t preadv64v2 (int FD, const struct iovec *IOV, int
  2405. IOVCNT, off64_t OFFSET, int FLAGS)
  2406. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2407. Concepts::.
  2408. This function is similar to the ‘preadv2’ function with the
  2409. difference is that the OFFSET parameter is of type ‘off64_t’
  2410. instead of ‘off_t’. It makes it possible on 32 bit machines to
  2411. address files larger than 2^31 bytes and up to 2^63 bytes. The
  2412. file descriptor ‘filedes’ must be opened using ‘open64’ since
  2413. otherwise the large offsets possible with ‘off64_t’ will lead to
  2414. errors with a descriptor in small file mode.
  2415. When the source file is compiled using ‘_FILE_OFFSET_BITS == 64’ on
  2416. a 32 bit machine this function is actually available under the name
  2417. ‘preadv2’ and so transparently replaces the 32 bit interface.
  2418. -- Function: ssize_t pwritev2 (int FD, const struct iovec *IOV, int
  2419. IOVCNT, off_t OFFSET, int FLAGS)
  2420. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2421. Concepts::.
  2422. This function is similar to the ‘pwritev’ function, with the
  2423. difference it adds an extra FLAGS parameter of type ‘int’.
  2424. Additionally, if OFFSET is -1, the current file position should is
  2425. used and updated (like the ‘writev’ function).
  2426. The supported FLAGS are dependent of the underlying system. For
  2427. Linux, the supported flags are the same as those for ‘preadv2’.
  2428. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  2429. ‘pwritev2’ function is in fact ‘pwritev64v2’ and the type ‘off_t’
  2430. has 64 bits, which makes it possible to handle files up to 2^63
  2431. bytes in length.
  2432. The return value is a count of bytes (_not_ buffers) write, 0
  2433. indicating end-of-file, or -1 indicating an error. The possible
  2434. errors are the same as in ‘preadv2’.
  2435. -- Function: ssize_t pwritev64v2 (int FD, const struct iovec *IOV, int
  2436. IOVCNT, off64_t OFFSET, int FLAGS)
  2437. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2438. Concepts::.
  2439. This function is similar to the ‘pwritev2’ function with the
  2440. difference is that the OFFSET parameter is of type ‘off64_t’
  2441. instead of ‘off_t’. It makes it possible on 32 bit machines to
  2442. address files larger than 2^31 bytes and up to 2^63 bytes. The
  2443. file descriptor ‘filedes’ must be opened using ‘open64’ since
  2444. otherwise the large offsets possible with ‘off64_t’ will lead to
  2445. errors with a descriptor in small file mode.
  2446. When the source file is compiled using ‘_FILE_OFFSET_BITS == 64’ on
  2447. a 32 bit machine this function is actually available under the name
  2448. ‘pwritev2’ and so transparently replaces the 32 bit interface.
  2449. 
  2450. File: libc.info, Node: Copying File Data, Next: Memory-mapped I/O, Prev: Scatter-Gather, Up: Low-Level I/O
  2451. 13.7 Copying data between two files
  2452. ===================================
  2453. A special function is provided to copy data between two files on the
  2454. same file system. The system can optimize such copy operations. This
  2455. is particularly important on network file systems, where the data would
  2456. otherwise have to be transferred twice over the network.
  2457. Note that this function only copies file data, but not metadata such
  2458. as file permissions or extended attributes.
  2459. -- Function: ssize_t copy_file_range (int INPUTFD, off64_t *INPUTPOS,
  2460. int OUTPUTFD, off64_t *OUTPUTPOS, ssize_t LENGTH, unsigned int
  2461. FLAGS)
  2462. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2463. Concepts::.
  2464. This function copies up to LENGTH bytes from the file descriptor
  2465. INPUTFD to the file descriptor OUTPUTFD.
  2466. The function can operate on both the current file position (like
  2467. ‘read’ and ‘write’) and an explicit offset (like ‘pread’ and
  2468. ‘pwrite’). If the INPUTPOS pointer is null, the file position of
  2469. INPUTFD is used as the starting point of the copy operation, and
  2470. the file position is advanced during it. If INPUTPOS is not null,
  2471. then ‘*INPUTPOS’ is used as the starting point of the copy
  2472. operation, and ‘*INPUTPOS’ is incremented by the number of copied
  2473. bytes, but the file position remains unchanged. Similar rules
  2474. apply to OUTPUTFD and OUTPUTPOS for the output file position.
  2475. The FLAGS argument is currently reserved and must be zero.
  2476. The ‘copy_file_range’ function returns the number of bytes copied.
  2477. This can be less than the specified LENGTH in case the input file
  2478. contains fewer remaining bytes than LENGTH, or if a read or write
  2479. failure occurs. The return value is zero if the end of the input
  2480. file is encountered immediately.
  2481. If no bytes can be copied, to report an error, ‘copy_file_range’
  2482. returns the value -1 and sets ‘errno’. The table below lists some
  2483. of the error conditions for this function.
  2484. ‘ENOSYS’
  2485. The kernel does not implement the required functionality.
  2486. ‘EISDIR’
  2487. At least one of the descriptors INPUTFD or OUTPUTFD refers to
  2488. a directory.
  2489. ‘EINVAL’
  2490. At least one of the descriptors INPUTFD or OUTPUTFD refers to
  2491. a non-regular, non-directory file (such as a socket or a
  2492. FIFO).
  2493. The input or output positions before are after the copy
  2494. operations are outside of an implementation-defined limit.
  2495. The FLAGS argument is not zero.
  2496. ‘EFBIG’
  2497. The new file size would exceed the process file size limit.
  2498. *Note Limits on Resources::.
  2499. The input or output positions before are after the copy
  2500. operations are outside of an implementation-defined limit.
  2501. This can happen if the file was not opened with large file
  2502. support (LFS) on 32-bit machines, and the copy operation would
  2503. create a file which is larger than what ‘off_t’ could
  2504. represent.
  2505. ‘EBADF’
  2506. The argument INPUTFD is not a valid file descriptor open for
  2507. reading.
  2508. The argument OUTPUTFD is not a valid file descriptor open for
  2509. writing, or OUTPUTFD has been opened with ‘O_APPEND’.
  2510. In addition, ‘copy_file_range’ can fail with the error codes which
  2511. are used by ‘read’, ‘pread’, ‘write’, and ‘pwrite’.
  2512. The ‘copy_file_range’ function is a cancellation point. In case of
  2513. cancellation, the input location (the file position or the value at
  2514. ‘*INPUTPOS’) is indeterminate.
  2515. 
  2516. File: libc.info, Node: Memory-mapped I/O, Next: Waiting for I/O, Prev: Copying File Data, Up: Low-Level I/O
  2517. 13.8 Memory-mapped I/O
  2518. ======================
  2519. On modern operating systems, it is possible to “mmap” (pronounced
  2520. “em-map”) a file to a region of memory. When this is done, the file can
  2521. be accessed just like an array in the program.
  2522. This is more efficient than ‘read’ or ‘write’, as only the regions of
  2523. the file that a program actually accesses are loaded. Accesses to
  2524. not-yet-loaded parts of the mmapped region are handled in the same way
  2525. as swapped out pages.
  2526. Since mmapped pages can be stored back to their file when physical
  2527. memory is low, it is possible to mmap files orders of magnitude larger
  2528. than both the physical memory _and_ swap space. The only limit is
  2529. address space. The theoretical limit is 4GB on a 32-bit machine -
  2530. however, the actual limit will be smaller since some areas will be
  2531. reserved for other purposes. If the LFS interface is used the file size
  2532. on 32-bit systems is not limited to 2GB (offsets are signed which
  2533. reduces the addressable area of 4GB by half); the full 64-bit are
  2534. available.
  2535. Memory mapping only works on entire pages of memory. Thus, addresses
  2536. for mapping must be page-aligned, and length values will be rounded up.
  2537. To determine the default size of a page the machine uses one should use:
  2538. size_t page_size = (size_t) sysconf (_SC_PAGESIZE);
  2539. On some systems, mappings can use larger page sizes for certain
  2540. files, and applications can request larger page sizes for anonymous
  2541. mappings as well (see the ‘MAP_HUGETLB’ flag below).
  2542. The following functions are declared in ‘sys/mman.h’:
  2543. -- Function: void * mmap (void *ADDRESS, size_t LENGTH, int PROTECT,
  2544. int FLAGS, int FILEDES, off_t OFFSET)
  2545. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2546. Concepts::.
  2547. The ‘mmap’ function creates a new mapping, connected to bytes
  2548. (OFFSET) to (OFFSET + LENGTH - 1) in the file open on FILEDES. A
  2549. new reference for the file specified by FILEDES is created, which
  2550. is not removed by closing the file.
  2551. ADDRESS gives a preferred starting address for the mapping. ‘NULL’
  2552. expresses no preference. Any previous mapping at that address is
  2553. automatically removed. The address you give may still be changed,
  2554. unless you use the ‘MAP_FIXED’ flag.
  2555. PROTECT contains flags that control what kind of access is
  2556. permitted. They include ‘PROT_READ’, ‘PROT_WRITE’, and
  2557. ‘PROT_EXEC’. The special flag ‘PROT_NONE’ reserves a region of
  2558. address space for future use. The ‘mprotect’ function can be used
  2559. to change the protection flags. *Note Memory Protection::.
  2560. FLAGS contains flags that control the nature of the map. One of
  2561. ‘MAP_SHARED’ or ‘MAP_PRIVATE’ must be specified.
  2562. They include:
  2563. ‘MAP_PRIVATE’
  2564. This specifies that writes to the region should never be
  2565. written back to the attached file. Instead, a copy is made
  2566. for the process, and the region will be swapped normally if
  2567. memory runs low. No other process will see the changes.
  2568. Since private mappings effectively revert to ordinary memory
  2569. when written to, you must have enough virtual memory for a
  2570. copy of the entire mmapped region if you use this mode with
  2571. ‘PROT_WRITE’.
  2572. ‘MAP_SHARED’
  2573. This specifies that writes to the region will be written back
  2574. to the file. Changes made will be shared immediately with
  2575. other processes mmaping the same file.
  2576. Note that actual writing may take place at any time. You need
  2577. to use ‘msync’, described below, if it is important that other
  2578. processes using conventional I/O get a consistent view of the
  2579. file.
  2580. ‘MAP_FIXED’
  2581. This forces the system to use the exact mapping address
  2582. specified in ADDRESS and fail if it can’t.
  2583. ‘MAP_ANONYMOUS’
  2584. ‘MAP_ANON’
  2585. This flag tells the system to create an anonymous mapping, not
  2586. connected to a file. FILEDES and OFFSET are ignored, and the
  2587. region is initialized with zeros.
  2588. Anonymous maps are used as the basic primitive to extend the
  2589. heap on some systems. They are also useful to share data
  2590. between multiple tasks without creating a file.
  2591. On some systems using private anonymous mmaps is more
  2592. efficient than using ‘malloc’ for large blocks. This is not
  2593. an issue with the GNU C Library, as the included ‘malloc’
  2594. automatically uses ‘mmap’ where appropriate.
  2595. ‘MAP_HUGETLB’
  2596. This requests that the system uses an alternative page size
  2597. which is larger than the default page size for the mapping.
  2598. For some workloads, increasing the page size for large
  2599. mappings improves performance because the system needs to
  2600. handle far fewer pages. For other workloads which require
  2601. frequent transfer of pages between storage or different nodes,
  2602. the decreased page granularity may cause performance problems
  2603. due to the increased page size and larger transfers.
  2604. In order to create the mapping, the system needs physically
  2605. contiguous memory of the size of the increased page size. As
  2606. a result, ‘MAP_HUGETLB’ mappings are affected by memory
  2607. fragmentation, and their creation can fail even if plenty of
  2608. memory is available in the system.
  2609. Not all file systems support mappings with an increased page
  2610. size.
  2611. The ‘MAP_HUGETLB’ flag is specific to Linux.
  2612. ‘mmap’ returns the address of the new mapping, or ‘MAP_FAILED’ for
  2613. an error.
  2614. Possible errors include:
  2615. ‘EINVAL’
  2616. Either ADDRESS was unusable (because it is not a multiple of
  2617. the applicable page size), or inconsistent FLAGS were given.
  2618. If ‘MAP_HUGETLB’ was specified, the file or system does not
  2619. support large page sizes.
  2620. ‘EACCES’
  2621. FILEDES was not open for the type of access specified in
  2622. PROTECT.
  2623. ‘ENOMEM’
  2624. Either there is not enough memory for the operation, or the
  2625. process is out of address space.
  2626. ‘ENODEV’
  2627. This file is of a type that doesn’t support mapping.
  2628. ‘ENOEXEC’
  2629. The file is on a filesystem that doesn’t support mapping.
  2630. -- Function: void * mmap64 (void *ADDRESS, size_t LENGTH, int PROTECT,
  2631. int FLAGS, int FILEDES, off64_t OFFSET)
  2632. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2633. Concepts::.
  2634. The ‘mmap64’ function is equivalent to the ‘mmap’ function but the
  2635. OFFSET parameter is of type ‘off64_t’. On 32-bit systems this
  2636. allows the file associated with the FILEDES descriptor to be larger
  2637. than 2GB. FILEDES must be a descriptor returned from a call to
  2638. ‘open64’ or ‘fopen64’ and ‘freopen64’ where the descriptor is
  2639. retrieved with ‘fileno’.
  2640. When the sources are translated with ‘_FILE_OFFSET_BITS == 64’ this
  2641. function is actually available under the name ‘mmap’. I.e., the
  2642. new, extended API using 64 bit file sizes and offsets transparently
  2643. replaces the old API.
  2644. -- Function: int munmap (void *ADDR, size_t LENGTH)
  2645. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2646. Concepts::.
  2647. ‘munmap’ removes any memory maps from (ADDR) to (ADDR + LENGTH).
  2648. LENGTH should be the length of the mapping.
  2649. It is safe to unmap multiple mappings in one command, or include
  2650. unmapped space in the range. It is also possible to unmap only
  2651. part of an existing mapping. However, only entire pages can be
  2652. removed. If LENGTH is not an even number of pages, it will be
  2653. rounded up.
  2654. It returns 0 for success and -1 for an error.
  2655. One error is possible:
  2656. ‘EINVAL’
  2657. The memory range given was outside the user mmap range or
  2658. wasn’t page aligned.
  2659. -- Function: int msync (void *ADDRESS, size_t LENGTH, int FLAGS)
  2660. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2661. Concepts::.
  2662. When using shared mappings, the kernel can write the file at any
  2663. time before the mapping is removed. To be certain data has
  2664. actually been written to the file and will be accessible to
  2665. non-memory-mapped I/O, it is necessary to use this function.
  2666. It operates on the region ADDRESS to (ADDRESS + LENGTH). It may be
  2667. used on part of a mapping or multiple mappings, however the region
  2668. given should not contain any unmapped space.
  2669. FLAGS can contain some options:
  2670. ‘MS_SYNC’
  2671. This flag makes sure the data is actually written _to disk_.
  2672. Normally ‘msync’ only makes sure that accesses to a file with
  2673. conventional I/O reflect the recent changes.
  2674. ‘MS_ASYNC’
  2675. This tells ‘msync’ to begin the synchronization, but not to
  2676. wait for it to complete.
  2677. ‘msync’ returns 0 for success and -1 for error. Errors include:
  2678. ‘EINVAL’
  2679. An invalid region was given, or the FLAGS were invalid.
  2680. ‘EFAULT’
  2681. There is no existing mapping in at least part of the given
  2682. region.
  2683. -- Function: void * mremap (void *ADDRESS, size_t LENGTH, size_t
  2684. NEW_LENGTH, int FLAG)
  2685. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2686. Concepts::.
  2687. This function can be used to change the size of an existing memory
  2688. area. ADDRESS and LENGTH must cover a region entirely mapped in
  2689. the same ‘mmap’ statement. A new mapping with the same
  2690. characteristics will be returned with the length NEW_LENGTH.
  2691. One option is possible, ‘MREMAP_MAYMOVE’. If it is given in FLAGS,
  2692. the system may remove the existing mapping and create a new one of
  2693. the desired length in another location.
  2694. The address of the resulting mapping is returned, or -1. Possible
  2695. error codes include:
  2696. ‘EFAULT’
  2697. There is no existing mapping in at least part of the original
  2698. region, or the region covers two or more distinct mappings.
  2699. ‘EINVAL’
  2700. The address given is misaligned or inappropriate.
  2701. ‘EAGAIN’
  2702. The region has pages locked, and if extended it would exceed
  2703. the process’s resource limit for locked pages. *Note Limits
  2704. on Resources::.
  2705. ‘ENOMEM’
  2706. The region is private writable, and insufficient virtual
  2707. memory is available to extend it. Also, this error will occur
  2708. if ‘MREMAP_MAYMOVE’ is not given and the extension would
  2709. collide with another mapped region.
  2710. This function is only available on a few systems. Except for
  2711. performing optional optimizations one should not rely on this function.
  2712. Not all file descriptors may be mapped. Sockets, pipes, and most
  2713. devices only allow sequential access and do not fit into the mapping
  2714. abstraction. In addition, some regular files may not be mmapable, and
  2715. older kernels may not support mapping at all. Thus, programs using
  2716. ‘mmap’ should have a fallback method to use should it fail. *Note
  2717. (standards)Mmap::.
  2718. -- Function: int madvise (void *ADDR, size_t LENGTH, int ADVICE)
  2719. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2720. Concepts::.
  2721. This function can be used to provide the system with ADVICE about
  2722. the intended usage patterns of the memory region starting at ADDR
  2723. and extending LENGTH bytes.
  2724. The valid BSD values for ADVICE are:
  2725. ‘MADV_NORMAL’
  2726. The region should receive no further special treatment.
  2727. ‘MADV_RANDOM’
  2728. The region will be accessed via random page references. The
  2729. kernel should page-in the minimal number of pages for each
  2730. page fault.
  2731. ‘MADV_SEQUENTIAL’
  2732. The region will be accessed via sequential page references.
  2733. This may cause the kernel to aggressively read-ahead,
  2734. expecting further sequential references after any page fault
  2735. within this region.
  2736. ‘MADV_WILLNEED’
  2737. The region will be needed. The pages within this region may
  2738. be pre-faulted in by the kernel.
  2739. ‘MADV_DONTNEED’
  2740. The region is no longer needed. The kernel may free these
  2741. pages, causing any changes to the pages to be lost, as well as
  2742. swapped out pages to be discarded.
  2743. ‘MADV_HUGEPAGE’
  2744. Indicate that it is beneficial to increase the page size for
  2745. this mapping. This can improve performance for larger
  2746. mappings because the system needs to handle far fewer pages.
  2747. However, if parts of the mapping are frequently transferred
  2748. between storage or different nodes, performance may suffer
  2749. because individual transfers can become substantially larger
  2750. due to the increased page size.
  2751. This flag is specific to Linux.
  2752. ‘MADV_NOHUGEPAGE’
  2753. Undo the effect of a previous ‘MADV_HUGEPAGE’ advice. This
  2754. flag is specific to Linux.
  2755. The POSIX names are slightly different, but with the same meanings:
  2756. ‘POSIX_MADV_NORMAL’
  2757. This corresponds with BSD’s ‘MADV_NORMAL’.
  2758. ‘POSIX_MADV_RANDOM’
  2759. This corresponds with BSD’s ‘MADV_RANDOM’.
  2760. ‘POSIX_MADV_SEQUENTIAL’
  2761. This corresponds with BSD’s ‘MADV_SEQUENTIAL’.
  2762. ‘POSIX_MADV_WILLNEED’
  2763. This corresponds with BSD’s ‘MADV_WILLNEED’.
  2764. ‘POSIX_MADV_DONTNEED’
  2765. This corresponds with BSD’s ‘MADV_DONTNEED’.
  2766. ‘madvise’ returns 0 for success and -1 for error. Errors include:
  2767. ‘EINVAL’
  2768. An invalid region was given, or the ADVICE was invalid.
  2769. ‘EFAULT’
  2770. There is no existing mapping in at least part of the given
  2771. region.
  2772. -- Function: int shm_open (const char *NAME, int OFLAG, mode_t MODE)
  2773. Preliminary: | MT-Safe locale | AS-Unsafe init heap lock |
  2774. AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  2775. This function returns a file descriptor that can be used to
  2776. allocate shared memory via mmap. Unrelated processes can use same
  2777. NAME to create or open existing shared memory objects.
  2778. A NAME argument specifies the shared memory object to be opened.
  2779. In the GNU C Library it must be a string smaller than ‘NAME_MAX’
  2780. bytes starting with an optional slash but containing no other
  2781. slashes.
  2782. The semantics of OFLAG and MODE arguments is same as in ‘open’.
  2783. ‘shm_open’ returns the file descriptor on success or -1 on error.
  2784. On failure ‘errno’ is set.
  2785. -- Function: int shm_unlink (const char *NAME)
  2786. Preliminary: | MT-Safe locale | AS-Unsafe init heap lock |
  2787. AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  2788. This function is the inverse of ‘shm_open’ and removes the object
  2789. with the given NAME previously created by ‘shm_open’.
  2790. ‘shm_unlink’ returns 0 on success or -1 on error. On failure
  2791. ‘errno’ is set.
  2792. -- Function: int memfd_create (const char *NAME, unsigned int FLAGS)
  2793. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  2794. Concepts::.
  2795. The ‘memfd_create’ function returns a file descriptor which can be
  2796. used to create memory mappings using the ‘mmap’ function. It is
  2797. similar to the ‘shm_open’ function in the sense that these mappings
  2798. are not backed by actual files. However, the descriptor returned
  2799. by ‘memfd_create’ does not correspond to a named object; the NAME
  2800. argument is used for debugging purposes only (e.g., will appear in
  2801. ‘/proc’), and separate invocations of ‘memfd_create’ with the same
  2802. NAME will not return descriptors for the same region of memory.
  2803. The descriptor can also be used to create alias mappings within the
  2804. same process.
  2805. The descriptor initially refers to a zero-length file. Before
  2806. mappings can be created which are backed by memory, the file size
  2807. needs to be increased with the ‘ftruncate’ function. *Note File
  2808. Size::.
  2809. The FLAGS argument can be a combination of the following flags:
  2810. ‘MFD_CLOEXEC’
  2811. The descriptor is created with the ‘O_CLOEXEC’ flag.
  2812. ‘MFD_ALLOW_SEALING’
  2813. The descriptor supports the addition of seals using the
  2814. ‘fcntl’ function.
  2815. ‘MFD_HUGETLB’
  2816. This requests that mappings created using the returned file
  2817. descriptor use a larger page size. See ‘MAP_HUGETLB’ above
  2818. for details.
  2819. This flag is incompatible with ‘MFD_ALLOW_SEALING’.
  2820. ‘memfd_create’ returns a file descriptor on success, and -1 on
  2821. failure.
  2822. The following ‘errno’ error conditions are defined for this
  2823. function:
  2824. ‘EINVAL’
  2825. An invalid combination is specified in FLAGS, or NAME is too
  2826. long.
  2827. ‘EFAULT’
  2828. The NAME argument does not point to a string.
  2829. ‘EMFILE’
  2830. The operation would exceed the file descriptor limit for this
  2831. process.
  2832. ‘ENFILE’
  2833. The operation would exceed the system-wide file descriptor
  2834. limit.
  2835. ‘ENOMEM’
  2836. There is not enough memory for the operation.
  2837. 
  2838. File: libc.info, Node: Waiting for I/O, Next: Synchronizing I/O, Prev: Memory-mapped I/O, Up: Low-Level I/O
  2839. 13.9 Waiting for Input or Output
  2840. ================================
  2841. Sometimes a program needs to accept input on multiple input channels
  2842. whenever input arrives. For example, some workstations may have devices
  2843. such as a digitizing tablet, function button box, or dial box that are
  2844. connected via normal asynchronous serial interfaces; good user interface
  2845. style requires responding immediately to input on any device. Another
  2846. example is a program that acts as a server to several other processes
  2847. via pipes or sockets.
  2848. You cannot normally use ‘read’ for this purpose, because this blocks
  2849. the program until input is available on one particular file descriptor;
  2850. input on other channels won’t wake it up. You could set nonblocking
  2851. mode and poll each file descriptor in turn, but this is very
  2852. inefficient.
  2853. A better solution is to use the ‘select’ function. This blocks the
  2854. program until input or output is ready on a specified set of file
  2855. descriptors, or until a timer expires, whichever comes first. This
  2856. facility is declared in the header file ‘sys/types.h’.
  2857. In the case of a server socket (*note Listening::), we say that
  2858. “input” is available when there are pending connections that could be
  2859. accepted (*note Accepting Connections::). ‘accept’ for server sockets
  2860. blocks and interacts with ‘select’ just as ‘read’ does for normal input.
  2861. The file descriptor sets for the ‘select’ function are specified as
  2862. ‘fd_set’ objects. Here is the description of the data type and some
  2863. macros for manipulating these objects.
  2864. -- Data Type: fd_set
  2865. The ‘fd_set’ data type represents file descriptor sets for the
  2866. ‘select’ function. It is actually a bit array.
  2867. -- Macro: int FD_SETSIZE
  2868. The value of this macro is the maximum number of file descriptors
  2869. that a ‘fd_set’ object can hold information about. On systems with
  2870. a fixed maximum number, ‘FD_SETSIZE’ is at least that number. On
  2871. some systems, including GNU, there is no absolute limit on the
  2872. number of descriptors open, but this macro still has a constant
  2873. value which controls the number of bits in an ‘fd_set’; if you get
  2874. a file descriptor with a value as high as ‘FD_SETSIZE’, you cannot
  2875. put that descriptor into an ‘fd_set’.
  2876. -- Macro: void FD_ZERO (fd_set *SET)
  2877. Preliminary: | MT-Safe race:set | AS-Safe | AC-Safe | *Note POSIX
  2878. Safety Concepts::.
  2879. This macro initializes the file descriptor set SET to be the empty
  2880. set.
  2881. -- Macro: void FD_SET (int FILEDES, fd_set *SET)
  2882. Preliminary: | MT-Safe race:set | AS-Safe | AC-Safe | *Note POSIX
  2883. Safety Concepts::.
  2884. This macro adds FILEDES to the file descriptor set SET.
  2885. The FILEDES parameter must not have side effects since it is
  2886. evaluated more than once.
  2887. -- Macro: void FD_CLR (int FILEDES, fd_set *SET)
  2888. Preliminary: | MT-Safe race:set | AS-Safe | AC-Safe | *Note POSIX
  2889. Safety Concepts::.
  2890. This macro removes FILEDES from the file descriptor set SET.
  2891. The FILEDES parameter must not have side effects since it is
  2892. evaluated more than once.
  2893. -- Macro: int FD_ISSET (int FILEDES, const fd_set *SET)
  2894. Preliminary: | MT-Safe race:set | AS-Safe | AC-Safe | *Note POSIX
  2895. Safety Concepts::.
  2896. This macro returns a nonzero value (true) if FILEDES is a member of
  2897. the file descriptor set SET, and zero (false) otherwise.
  2898. The FILEDES parameter must not have side effects since it is
  2899. evaluated more than once.
  2900. Next, here is the description of the ‘select’ function itself.
  2901. -- Function: int select (int NFDS, fd_set *READ-FDS, fd_set *WRITE-FDS,
  2902. fd_set *EXCEPT-FDS, struct timeval *TIMEOUT)
  2903. Preliminary: | MT-Safe race:read-fds race:write-fds race:except-fds
  2904. | AS-Safe | AC-Safe | *Note POSIX Safety Concepts::.
  2905. The ‘select’ function blocks the calling process until there is
  2906. activity on any of the specified sets of file descriptors, or until
  2907. the timeout period has expired.
  2908. The file descriptors specified by the READ-FDS argument are checked
  2909. to see if they are ready for reading; the WRITE-FDS file
  2910. descriptors are checked to see if they are ready for writing; and
  2911. the EXCEPT-FDS file descriptors are checked for exceptional
  2912. conditions. You can pass a null pointer for any of these arguments
  2913. if you are not interested in checking for that kind of condition.
  2914. A file descriptor is considered ready for reading if a ‘read’ call
  2915. will not block. This usually includes the read offset being at the
  2916. end of the file or there is an error to report. A server socket is
  2917. considered ready for reading if there is a pending connection which
  2918. can be accepted with ‘accept’; *note Accepting Connections::. A
  2919. client socket is ready for writing when its connection is fully
  2920. established; *note Connecting::.
  2921. “Exceptional conditions” does not mean errors—errors are reported
  2922. immediately when an erroneous system call is executed, and do not
  2923. constitute a state of the descriptor. Rather, they include
  2924. conditions such as the presence of an urgent message on a socket.
  2925. (*Note Sockets::, for information on urgent messages.)
  2926. The ‘select’ function checks only the first NFDS file descriptors.
  2927. The usual thing is to pass ‘FD_SETSIZE’ as the value of this
  2928. argument.
  2929. The TIMEOUT specifies the maximum time to wait. If you pass a null
  2930. pointer for this argument, it means to block indefinitely until one
  2931. of the file descriptors is ready. Otherwise, you should provide
  2932. the time in ‘struct timeval’ format; see *note Time Types::.
  2933. Specify zero as the time (a ‘struct timeval’ containing all zeros)
  2934. if you want to find out which descriptors are ready without waiting
  2935. if none are ready.
  2936. The normal return value from ‘select’ is the total number of ready
  2937. file descriptors in all of the sets. Each of the argument sets is
  2938. overwritten with information about the descriptors that are ready
  2939. for the corresponding operation. Thus, to see if a particular
  2940. descriptor DESC has input, use ‘FD_ISSET (DESC, READ-FDS)’ after
  2941. ‘select’ returns.
  2942. If ‘select’ returns because the timeout period expires, it returns
  2943. a value of zero.
  2944. Any signal will cause ‘select’ to return immediately. So if your
  2945. program uses signals, you can’t rely on ‘select’ to keep waiting
  2946. for the full time specified. If you want to be sure of waiting for
  2947. a particular amount of time, you must check for ‘EINTR’ and repeat
  2948. the ‘select’ with a newly calculated timeout based on the current
  2949. time. See the example below. See also *note Interrupted
  2950. Primitives::.
  2951. If an error occurs, ‘select’ returns ‘-1’ and does not modify the
  2952. argument file descriptor sets. The following ‘errno’ error
  2953. conditions are defined for this function:
  2954. ‘EBADF’
  2955. One of the file descriptor sets specified an invalid file
  2956. descriptor.
  2957. ‘EINTR’
  2958. The operation was interrupted by a signal. *Note Interrupted
  2959. Primitives::.
  2960. ‘EINVAL’
  2961. The TIMEOUT argument is invalid; one of the components is
  2962. negative or too large.
  2963. *Portability Note:* The ‘select’ function is a BSD Unix feature.
  2964. Here is an example showing how you can use ‘select’ to establish a
  2965. timeout period for reading from a file descriptor. The ‘input_timeout’
  2966. function blocks the calling process until input is available on the file
  2967. descriptor, or until the timeout period expires.
  2968. #include <errno.h>
  2969. #include <stdio.h>
  2970. #include <unistd.h>
  2971. #include <sys/types.h>
  2972. #include <sys/time.h>
  2973. int
  2974. input_timeout (int filedes, unsigned int seconds)
  2975. {
  2976. fd_set set;
  2977. struct timeval timeout;
  2978. /* Initialize the file descriptor set. */
  2979. FD_ZERO (&set);
  2980. FD_SET (filedes, &set);
  2981. /* Initialize the timeout data structure. */
  2982. timeout.tv_sec = seconds;
  2983. timeout.tv_usec = 0;
  2984. /* ‘select’ returns 0 if timeout, 1 if input available, -1 if error. */
  2985. return TEMP_FAILURE_RETRY (select (FD_SETSIZE,
  2986. &set, NULL, NULL,
  2987. &timeout));
  2988. }
  2989. int
  2990. main (void)
  2991. {
  2992. fprintf (stderr, "select returned %d.\n",
  2993. input_timeout (STDIN_FILENO, 5));
  2994. return 0;
  2995. }
  2996. There is another example showing the use of ‘select’ to multiplex
  2997. input from multiple sockets in *note Server Example::.
  2998. 
  2999. File: libc.info, Node: Synchronizing I/O, Next: Asynchronous I/O, Prev: Waiting for I/O, Up: Low-Level I/O
  3000. 13.10 Synchronizing I/O operations
  3001. ==================================
  3002. In most modern operating systems, the normal I/O operations are not
  3003. executed synchronously. I.e., even if a ‘write’ system call returns,
  3004. this does not mean the data is actually written to the media, e.g., the
  3005. disk.
  3006. In situations where synchronization points are necessary, you can use
  3007. special functions which ensure that all operations finish before they
  3008. return.
  3009. -- Function: void sync (void)
  3010. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3011. Concepts::.
  3012. A call to this function will not return as long as there is data
  3013. which has not been written to the device. All dirty buffers in the
  3014. kernel will be written and so an overall consistent system can be
  3015. achieved (if no other process in parallel writes data).
  3016. A prototype for ‘sync’ can be found in ‘unistd.h’.
  3017. Programs more often want to ensure that data written to a given file
  3018. is committed, rather than all data in the system. For this, ‘sync’ is
  3019. overkill.
  3020. -- Function: int fsync (int FILDES)
  3021. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3022. Concepts::.
  3023. The ‘fsync’ function can be used to make sure all data associated
  3024. with the open file FILDES is written to the device associated with
  3025. the descriptor. The function call does not return unless all
  3026. actions have finished.
  3027. A prototype for ‘fsync’ can be found in ‘unistd.h’.
  3028. This function is a cancellation point in multi-threaded programs.
  3029. This is a problem if the thread allocates some resources (like
  3030. memory, file descriptors, semaphores or whatever) at the time
  3031. ‘fsync’ is called. If the thread gets canceled these resources
  3032. stay allocated until the program ends. To avoid this, calls to
  3033. ‘fsync’ should be protected using cancellation handlers.
  3034. The return value of the function is zero if no error occurred.
  3035. Otherwise it is -1 and the global variable ‘errno’ is set to the
  3036. following values:
  3037. ‘EBADF’
  3038. The descriptor FILDES is not valid.
  3039. ‘EINVAL’
  3040. No synchronization is possible since the system does not
  3041. implement this.
  3042. Sometimes it is not even necessary to write all data associated with
  3043. a file descriptor. E.g., in database files which do not change in size
  3044. it is enough to write all the file content data to the device.
  3045. Meta-information, like the modification time etc., are not that
  3046. important and leaving such information uncommitted does not prevent a
  3047. successful recovery of the file in case of a problem.
  3048. -- Function: int fdatasync (int FILDES)
  3049. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3050. Concepts::.
  3051. When a call to the ‘fdatasync’ function returns, it is ensured that
  3052. all of the file data is written to the device. For all pending I/O
  3053. operations, the parts guaranteeing data integrity finished.
  3054. Not all systems implement the ‘fdatasync’ operation. On systems
  3055. missing this functionality ‘fdatasync’ is emulated by a call to
  3056. ‘fsync’ since the performed actions are a superset of those
  3057. required by ‘fdatasync’.
  3058. The prototype for ‘fdatasync’ is in ‘unistd.h’.
  3059. The return value of the function is zero if no error occurred.
  3060. Otherwise it is -1 and the global variable ‘errno’ is set to the
  3061. following values:
  3062. ‘EBADF’
  3063. The descriptor FILDES is not valid.
  3064. ‘EINVAL’
  3065. No synchronization is possible since the system does not
  3066. implement this.
  3067. 
  3068. File: libc.info, Node: Asynchronous I/O, Next: Control Operations, Prev: Synchronizing I/O, Up: Low-Level I/O
  3069. 13.11 Perform I/O Operations in Parallel
  3070. ========================================
  3071. The POSIX.1b standard defines a new set of I/O operations which can
  3072. significantly reduce the time an application spends waiting for I/O. The
  3073. new functions allow a program to initiate one or more I/O operations and
  3074. then immediately resume normal work while the I/O operations are
  3075. executed in parallel. This functionality is available if the ‘unistd.h’
  3076. file defines the symbol ‘_POSIX_ASYNCHRONOUS_IO’.
  3077. These functions are part of the library with realtime functions named
  3078. ‘librt’. They are not actually part of the ‘libc’ binary. The
  3079. implementation of these functions can be done using support in the
  3080. kernel (if available) or using an implementation based on threads at
  3081. userlevel. In the latter case it might be necessary to link
  3082. applications with the thread library ‘libpthread’ in addition to
  3083. ‘librt’.
  3084. All AIO operations operate on files which were opened previously.
  3085. There might be arbitrarily many operations running for one file. The
  3086. asynchronous I/O operations are controlled using a data structure named
  3087. ‘struct aiocb’ (“AIO control block”). It is defined in ‘aio.h’ as
  3088. follows.
  3089. -- Data Type: struct aiocb
  3090. The POSIX.1b standard mandates that the ‘struct aiocb’ structure
  3091. contains at least the members described in the following table.
  3092. There might be more elements which are used by the implementation,
  3093. but depending upon these elements is not portable and is highly
  3094. deprecated.
  3095. ‘int aio_fildes’
  3096. This element specifies the file descriptor to be used for the
  3097. operation. It must be a legal descriptor, otherwise the
  3098. operation will fail.
  3099. The device on which the file is opened must allow the seek
  3100. operation. I.e., it is not possible to use any of the AIO
  3101. operations on devices like terminals where an ‘lseek’ call
  3102. would lead to an error.
  3103. ‘off_t aio_offset’
  3104. This element specifies the offset in the file at which the
  3105. operation (input or output) is performed. Since the
  3106. operations are carried out in arbitrary order and more than
  3107. one operation for one file descriptor can be started, one
  3108. cannot expect a current read/write position of the file
  3109. descriptor.
  3110. ‘volatile void *aio_buf’
  3111. This is a pointer to the buffer with the data to be written or
  3112. the place where the read data is stored.
  3113. ‘size_t aio_nbytes’
  3114. This element specifies the length of the buffer pointed to by
  3115. ‘aio_buf’.
  3116. ‘int aio_reqprio’
  3117. If the platform has defined ‘_POSIX_PRIORITIZED_IO’ and
  3118. ‘_POSIX_PRIORITY_SCHEDULING’, the AIO requests are processed
  3119. based on the current scheduling priority. The ‘aio_reqprio’
  3120. element can then be used to lower the priority of the AIO
  3121. operation.
  3122. ‘struct sigevent aio_sigevent’
  3123. This element specifies how the calling process is notified
  3124. once the operation terminates. If the ‘sigev_notify’ element
  3125. is ‘SIGEV_NONE’, no notification is sent. If it is
  3126. ‘SIGEV_SIGNAL’, the signal determined by ‘sigev_signo’ is
  3127. sent. Otherwise, ‘sigev_notify’ must be ‘SIGEV_THREAD’. In
  3128. this case, a thread is created which starts executing the
  3129. function pointed to by ‘sigev_notify_function’.
  3130. ‘int aio_lio_opcode’
  3131. This element is only used by the ‘lio_listio’ and
  3132. ‘lio_listio64’ functions. Since these functions allow an
  3133. arbitrary number of operations to start at once, and each
  3134. operation can be input or output (or nothing), the information
  3135. must be stored in the control block. The possible values are:
  3136. ‘LIO_READ’
  3137. Start a read operation. Read from the file at position
  3138. ‘aio_offset’ and store the next ‘aio_nbytes’ bytes in the
  3139. buffer pointed to by ‘aio_buf’.
  3140. ‘LIO_WRITE’
  3141. Start a write operation. Write ‘aio_nbytes’ bytes
  3142. starting at ‘aio_buf’ into the file starting at position
  3143. ‘aio_offset’.
  3144. ‘LIO_NOP’
  3145. Do nothing for this control block. This value is useful
  3146. sometimes when an array of ‘struct aiocb’ values contains
  3147. holes, i.e., some of the values must not be handled
  3148. although the whole array is presented to the ‘lio_listio’
  3149. function.
  3150. When the sources are compiled using ‘_FILE_OFFSET_BITS == 64’ on a
  3151. 32 bit machine, this type is in fact ‘struct aiocb64’, since the
  3152. LFS interface transparently replaces the ‘struct aiocb’ definition.
  3153. For use with the AIO functions defined in the LFS, there is a similar
  3154. type defined which replaces the types of the appropriate members with
  3155. larger types but otherwise is equivalent to ‘struct aiocb’.
  3156. Particularly, all member names are the same.
  3157. -- Data Type: struct aiocb64
  3158. ‘int aio_fildes’
  3159. This element specifies the file descriptor which is used for
  3160. the operation. It must be a legal descriptor since otherwise
  3161. the operation fails for obvious reasons.
  3162. The device on which the file is opened must allow the seek
  3163. operation. I.e., it is not possible to use any of the AIO
  3164. operations on devices like terminals where an ‘lseek’ call
  3165. would lead to an error.
  3166. ‘off64_t aio_offset’
  3167. This element specifies at which offset in the file the
  3168. operation (input or output) is performed. Since the operation
  3169. are carried in arbitrary order and more than one operation for
  3170. one file descriptor can be started, one cannot expect a
  3171. current read/write position of the file descriptor.
  3172. ‘volatile void *aio_buf’
  3173. This is a pointer to the buffer with the data to be written or
  3174. the place where the read data is stored.
  3175. ‘size_t aio_nbytes’
  3176. This element specifies the length of the buffer pointed to by
  3177. ‘aio_buf’.
  3178. ‘int aio_reqprio’
  3179. If for the platform ‘_POSIX_PRIORITIZED_IO’ and
  3180. ‘_POSIX_PRIORITY_SCHEDULING’ are defined the AIO requests are
  3181. processed based on the current scheduling priority. The
  3182. ‘aio_reqprio’ element can then be used to lower the priority
  3183. of the AIO operation.
  3184. ‘struct sigevent aio_sigevent’
  3185. This element specifies how the calling process is notified
  3186. once the operation terminates. If the ‘sigev_notify’ element
  3187. is ‘SIGEV_NONE’ no notification is sent. If it is
  3188. ‘SIGEV_SIGNAL’, the signal determined by ‘sigev_signo’ is
  3189. sent. Otherwise, ‘sigev_notify’ must be ‘SIGEV_THREAD’ in
  3190. which case a thread is created which starts executing the
  3191. function pointed to by ‘sigev_notify_function’.
  3192. ‘int aio_lio_opcode’
  3193. This element is only used by the ‘lio_listio’ and
  3194. ‘lio_listio64’ functions. Since these functions allow an
  3195. arbitrary number of operations to start at once, and since
  3196. each operation can be input or output (or nothing), the
  3197. information must be stored in the control block. See the
  3198. description of ‘struct aiocb’ for a description of the
  3199. possible values.
  3200. When the sources are compiled using ‘_FILE_OFFSET_BITS == 64’ on a
  3201. 32 bit machine, this type is available under the name ‘struct
  3202. aiocb64’, since the LFS transparently replaces the old interface.
  3203. * Menu:
  3204. * Asynchronous Reads/Writes:: Asynchronous Read and Write Operations.
  3205. * Status of AIO Operations:: Getting the Status of AIO Operations.
  3206. * Synchronizing AIO Operations:: Getting into a consistent state.
  3207. * Cancel AIO Operations:: Cancellation of AIO Operations.
  3208. * Configuration of AIO:: How to optimize the AIO implementation.
  3209. 
  3210. File: libc.info, Node: Asynchronous Reads/Writes, Next: Status of AIO Operations, Up: Asynchronous I/O
  3211. 13.11.1 Asynchronous Read and Write Operations
  3212. ----------------------------------------------
  3213. -- Function: int aio_read (struct aiocb *AIOCBP)
  3214. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3215. *Note POSIX Safety Concepts::.
  3216. This function initiates an asynchronous read operation. It
  3217. immediately returns after the operation was enqueued or when an
  3218. error was encountered.
  3219. The first ‘aiocbp->aio_nbytes’ bytes of the file for which
  3220. ‘aiocbp->aio_fildes’ is a descriptor are written to the buffer
  3221. starting at ‘aiocbp->aio_buf’. Reading starts at the absolute
  3222. position ‘aiocbp->aio_offset’ in the file.
  3223. If prioritized I/O is supported by the platform the
  3224. ‘aiocbp->aio_reqprio’ value is used to adjust the priority before
  3225. the request is actually enqueued.
  3226. The calling process is notified about the termination of the read
  3227. request according to the ‘aiocbp->aio_sigevent’ value.
  3228. When ‘aio_read’ returns, the return value is zero if no error
  3229. occurred that can be found before the process is enqueued. If such
  3230. an early error is found, the function returns -1 and sets ‘errno’
  3231. to one of the following values:
  3232. ‘EAGAIN’
  3233. The request was not enqueued due to (temporarily) exceeded
  3234. resource limitations.
  3235. ‘ENOSYS’
  3236. The ‘aio_read’ function is not implemented.
  3237. ‘EBADF’
  3238. The ‘aiocbp->aio_fildes’ descriptor is not valid. This
  3239. condition need not be recognized before enqueueing the request
  3240. and so this error might also be signaled asynchronously.
  3241. ‘EINVAL’
  3242. The ‘aiocbp->aio_offset’ or ‘aiocbp->aio_reqpiro’ value is
  3243. invalid. This condition need not be recognized before
  3244. enqueueing the request and so this error might also be
  3245. signaled asynchronously.
  3246. If ‘aio_read’ returns zero, the current status of the request can
  3247. be queried using ‘aio_error’ and ‘aio_return’ functions. As long
  3248. as the value returned by ‘aio_error’ is ‘EINPROGRESS’ the operation
  3249. has not yet completed. If ‘aio_error’ returns zero, the operation
  3250. successfully terminated, otherwise the value is to be interpreted
  3251. as an error code. If the function terminated, the result of the
  3252. operation can be obtained using a call to ‘aio_return’. The
  3253. returned value is the same as an equivalent call to ‘read’ would
  3254. have returned. Possible error codes returned by ‘aio_error’ are:
  3255. ‘EBADF’
  3256. The ‘aiocbp->aio_fildes’ descriptor is not valid.
  3257. ‘ECANCELED’
  3258. The operation was canceled before the operation was finished
  3259. (*note Cancel AIO Operations::)
  3260. ‘EINVAL’
  3261. The ‘aiocbp->aio_offset’ value is invalid.
  3262. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3263. function is in fact ‘aio_read64’ since the LFS interface
  3264. transparently replaces the normal implementation.
  3265. -- Function: int aio_read64 (struct aiocb64 *AIOCBP)
  3266. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3267. *Note POSIX Safety Concepts::.
  3268. This function is similar to the ‘aio_read’ function. The only
  3269. difference is that on 32 bit machines, the file descriptor should
  3270. be opened in the large file mode. Internally, ‘aio_read64’ uses
  3271. functionality equivalent to ‘lseek64’ (*note File Position
  3272. Primitive::) to position the file descriptor correctly for the
  3273. reading, as opposed to the ‘lseek’ functionality used in
  3274. ‘aio_read’.
  3275. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3276. function is available under the name ‘aio_read’ and so
  3277. transparently replaces the interface for small files on 32 bit
  3278. machines.
  3279. To write data asynchronously to a file, there exists an equivalent
  3280. pair of functions with a very similar interface.
  3281. -- Function: int aio_write (struct aiocb *AIOCBP)
  3282. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3283. *Note POSIX Safety Concepts::.
  3284. This function initiates an asynchronous write operation. The
  3285. function call immediately returns after the operation was enqueued
  3286. or if before this happens an error was encountered.
  3287. The first ‘aiocbp->aio_nbytes’ bytes from the buffer starting at
  3288. ‘aiocbp->aio_buf’ are written to the file for which
  3289. ‘aiocbp->aio_fildes’ is a descriptor, starting at the absolute
  3290. position ‘aiocbp->aio_offset’ in the file.
  3291. If prioritized I/O is supported by the platform, the
  3292. ‘aiocbp->aio_reqprio’ value is used to adjust the priority before
  3293. the request is actually enqueued.
  3294. The calling process is notified about the termination of the read
  3295. request according to the ‘aiocbp->aio_sigevent’ value.
  3296. When ‘aio_write’ returns, the return value is zero if no error
  3297. occurred that can be found before the process is enqueued. If such
  3298. an early error is found the function returns -1 and sets ‘errno’ to
  3299. one of the following values.
  3300. ‘EAGAIN’
  3301. The request was not enqueued due to (temporarily) exceeded
  3302. resource limitations.
  3303. ‘ENOSYS’
  3304. The ‘aio_write’ function is not implemented.
  3305. ‘EBADF’
  3306. The ‘aiocbp->aio_fildes’ descriptor is not valid. This
  3307. condition may not be recognized before enqueueing the request,
  3308. and so this error might also be signaled asynchronously.
  3309. ‘EINVAL’
  3310. The ‘aiocbp->aio_offset’ or ‘aiocbp->aio_reqprio’ value is
  3311. invalid. This condition may not be recognized before
  3312. enqueueing the request and so this error might also be
  3313. signaled asynchronously.
  3314. In the case ‘aio_write’ returns zero, the current status of the
  3315. request can be queried using the ‘aio_error’ and ‘aio_return’
  3316. functions. As long as the value returned by ‘aio_error’ is
  3317. ‘EINPROGRESS’ the operation has not yet completed. If ‘aio_error’
  3318. returns zero, the operation successfully terminated, otherwise the
  3319. value is to be interpreted as an error code. If the function
  3320. terminated, the result of the operation can be obtained using a
  3321. call to ‘aio_return’. The returned value is the same as an
  3322. equivalent call to ‘read’ would have returned. Possible error
  3323. codes returned by ‘aio_error’ are:
  3324. ‘EBADF’
  3325. The ‘aiocbp->aio_fildes’ descriptor is not valid.
  3326. ‘ECANCELED’
  3327. The operation was canceled before the operation was finished.
  3328. (*note Cancel AIO Operations::)
  3329. ‘EINVAL’
  3330. The ‘aiocbp->aio_offset’ value is invalid.
  3331. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3332. function is in fact ‘aio_write64’ since the LFS interface
  3333. transparently replaces the normal implementation.
  3334. -- Function: int aio_write64 (struct aiocb64 *AIOCBP)
  3335. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3336. *Note POSIX Safety Concepts::.
  3337. This function is similar to the ‘aio_write’ function. The only
  3338. difference is that on 32 bit machines the file descriptor should be
  3339. opened in the large file mode. Internally ‘aio_write64’ uses
  3340. functionality equivalent to ‘lseek64’ (*note File Position
  3341. Primitive::) to position the file descriptor correctly for the
  3342. writing, as opposed to the ‘lseek’ functionality used in
  3343. ‘aio_write’.
  3344. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3345. function is available under the name ‘aio_write’ and so
  3346. transparently replaces the interface for small files on 32 bit
  3347. machines.
  3348. Besides these functions with the more or less traditional interface,
  3349. POSIX.1b also defines a function which can initiate more than one
  3350. operation at a time, and which can handle freely mixed read and write
  3351. operations. It is therefore similar to a combination of ‘readv’ and
  3352. ‘writev’.
  3353. -- Function: int lio_listio (int MODE, struct aiocb *const LIST[], int
  3354. NENT, struct sigevent *SIG)
  3355. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3356. *Note POSIX Safety Concepts::.
  3357. The ‘lio_listio’ function can be used to enqueue an arbitrary
  3358. number of read and write requests at one time. The requests can
  3359. all be meant for the same file, all for different files or every
  3360. solution in between.
  3361. ‘lio_listio’ gets the NENT requests from the array pointed to by
  3362. LIST. The operation to be performed is determined by the
  3363. ‘aio_lio_opcode’ member in each element of LIST. If this field is
  3364. ‘LIO_READ’ a read operation is enqueued, similar to a call of
  3365. ‘aio_read’ for this element of the array (except that the way the
  3366. termination is signalled is different, as we will see below). If
  3367. the ‘aio_lio_opcode’ member is ‘LIO_WRITE’ a write operation is
  3368. enqueued. Otherwise the ‘aio_lio_opcode’ must be ‘LIO_NOP’ in
  3369. which case this element of LIST is simply ignored. This
  3370. “operation” is useful in situations where one has a fixed array of
  3371. ‘struct aiocb’ elements from which only a few need to be handled at
  3372. a time. Another situation is where the ‘lio_listio’ call was
  3373. canceled before all requests are processed (*note Cancel AIO
  3374. Operations::) and the remaining requests have to be reissued.
  3375. The other members of each element of the array pointed to by ‘list’
  3376. must have values suitable for the operation as described in the
  3377. documentation for ‘aio_read’ and ‘aio_write’ above.
  3378. The MODE argument determines how ‘lio_listio’ behaves after having
  3379. enqueued all the requests. If MODE is ‘LIO_WAIT’ it waits until
  3380. all requests terminated. Otherwise MODE must be ‘LIO_NOWAIT’ and
  3381. in this case the function returns immediately after having enqueued
  3382. all the requests. In this case the caller gets a notification of
  3383. the termination of all requests according to the SIG parameter. If
  3384. SIG is ‘NULL’ no notification is sent. Otherwise a signal is sent
  3385. or a thread is started, just as described in the description for
  3386. ‘aio_read’ or ‘aio_write’.
  3387. If MODE is ‘LIO_WAIT’, the return value of ‘lio_listio’ is 0 when
  3388. all requests completed successfully. Otherwise the function
  3389. returns -1 and ‘errno’ is set accordingly. To find out which
  3390. request or requests failed one has to use the ‘aio_error’ function
  3391. on all the elements of the array LIST.
  3392. In case MODE is ‘LIO_NOWAIT’, the function returns 0 if all
  3393. requests were enqueued correctly. The current state of the
  3394. requests can be found using ‘aio_error’ and ‘aio_return’ as
  3395. described above. If ‘lio_listio’ returns -1 in this mode, the
  3396. global variable ‘errno’ is set accordingly. If a request did not
  3397. yet terminate, a call to ‘aio_error’ returns ‘EINPROGRESS’. If the
  3398. value is different, the request is finished and the error value (or
  3399. 0) is returned and the result of the operation can be retrieved
  3400. using ‘aio_return’.
  3401. Possible values for ‘errno’ are:
  3402. ‘EAGAIN’
  3403. The resources necessary to queue all the requests are not
  3404. available at the moment. The error status for each element of
  3405. LIST must be checked to determine which request failed.
  3406. Another reason could be that the system wide limit of AIO
  3407. requests is exceeded. This cannot be the case for the
  3408. implementation on GNU systems since no arbitrary limits exist.
  3409. ‘EINVAL’
  3410. The MODE parameter is invalid or NENT is larger than
  3411. ‘AIO_LISTIO_MAX’.
  3412. ‘EIO’
  3413. One or more of the request’s I/O operations failed. The error
  3414. status of each request should be checked to determine which
  3415. one failed.
  3416. ‘ENOSYS’
  3417. The ‘lio_listio’ function is not supported.
  3418. If the MODE parameter is ‘LIO_NOWAIT’ and the caller cancels a
  3419. request, the error status for this request returned by ‘aio_error’
  3420. is ‘ECANCELED’.
  3421. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3422. function is in fact ‘lio_listio64’ since the LFS interface
  3423. transparently replaces the normal implementation.
  3424. -- Function: int lio_listio64 (int MODE, struct aiocb64 *const LIST[],
  3425. int NENT, struct sigevent *SIG)
  3426. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3427. *Note POSIX Safety Concepts::.
  3428. This function is similar to the ‘lio_listio’ function. The only
  3429. difference is that on 32 bit machines, the file descriptor should
  3430. be opened in the large file mode. Internally, ‘lio_listio64’ uses
  3431. functionality equivalent to ‘lseek64’ (*note File Position
  3432. Primitive::) to position the file descriptor correctly for the
  3433. reading or writing, as opposed to the ‘lseek’ functionality used in
  3434. ‘lio_listio’.
  3435. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3436. function is available under the name ‘lio_listio’ and so
  3437. transparently replaces the interface for small files on 32 bit
  3438. machines.
  3439. 
  3440. File: libc.info, Node: Status of AIO Operations, Next: Synchronizing AIO Operations, Prev: Asynchronous Reads/Writes, Up: Asynchronous I/O
  3441. 13.11.2 Getting the Status of AIO Operations
  3442. --------------------------------------------
  3443. As already described in the documentation of the functions in the last
  3444. section, it must be possible to get information about the status of an
  3445. I/O request. When the operation is performed truly asynchronously (as
  3446. with ‘aio_read’ and ‘aio_write’ and with ‘lio_listio’ when the mode is
  3447. ‘LIO_NOWAIT’), one sometimes needs to know whether a specific request
  3448. already terminated and if so, what the result was. The following two
  3449. functions allow you to get this kind of information.
  3450. -- Function: int aio_error (const struct aiocb *AIOCBP)
  3451. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3452. Concepts::.
  3453. This function determines the error state of the request described
  3454. by the ‘struct aiocb’ variable pointed to by AIOCBP. If the
  3455. request has not yet terminated the value returned is always
  3456. ‘EINPROGRESS’. Once the request has terminated the value
  3457. ‘aio_error’ returns is either 0 if the request completed
  3458. successfully or it returns the value which would be stored in the
  3459. ‘errno’ variable if the request would have been done using ‘read’,
  3460. ‘write’, or ‘fsync’.
  3461. The function can return ‘ENOSYS’ if it is not implemented. It
  3462. could also return ‘EINVAL’ if the AIOCBP parameter does not refer
  3463. to an asynchronous operation whose return status is not yet known.
  3464. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3465. function is in fact ‘aio_error64’ since the LFS interface
  3466. transparently replaces the normal implementation.
  3467. -- Function: int aio_error64 (const struct aiocb64 *AIOCBP)
  3468. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3469. Concepts::.
  3470. This function is similar to ‘aio_error’ with the only difference
  3471. that the argument is a reference to a variable of type ‘struct
  3472. aiocb64’.
  3473. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3474. function is available under the name ‘aio_error’ and so
  3475. transparently replaces the interface for small files on 32 bit
  3476. machines.
  3477. -- Function: ssize_t aio_return (struct aiocb *AIOCBP)
  3478. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3479. Concepts::.
  3480. This function can be used to retrieve the return status of the
  3481. operation carried out by the request described in the variable
  3482. pointed to by AIOCBP. As long as the error status of this request
  3483. as returned by ‘aio_error’ is ‘EINPROGRESS’ the return value of
  3484. this function is undefined.
  3485. Once the request is finished this function can be used exactly once
  3486. to retrieve the return value. Following calls might lead to
  3487. undefined behavior. The return value itself is the value which
  3488. would have been returned by the ‘read’, ‘write’, or ‘fsync’ call.
  3489. The function can return ‘ENOSYS’ if it is not implemented. It
  3490. could also return ‘EINVAL’ if the AIOCBP parameter does not refer
  3491. to an asynchronous operation whose return status is not yet known.
  3492. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3493. function is in fact ‘aio_return64’ since the LFS interface
  3494. transparently replaces the normal implementation.
  3495. -- Function: ssize_t aio_return64 (struct aiocb64 *AIOCBP)
  3496. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3497. Concepts::.
  3498. This function is similar to ‘aio_return’ with the only difference
  3499. that the argument is a reference to a variable of type ‘struct
  3500. aiocb64’.
  3501. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3502. function is available under the name ‘aio_return’ and so
  3503. transparently replaces the interface for small files on 32 bit
  3504. machines.
  3505. 
  3506. File: libc.info, Node: Synchronizing AIO Operations, Next: Cancel AIO Operations, Prev: Status of AIO Operations, Up: Asynchronous I/O
  3507. 13.11.3 Getting into a Consistent State
  3508. ---------------------------------------
  3509. When dealing with asynchronous operations it is sometimes necessary to
  3510. get into a consistent state. This would mean for AIO that one wants to
  3511. know whether a certain request or a group of requests were processed.
  3512. This could be done by waiting for the notification sent by the system
  3513. after the operation terminated, but this sometimes would mean wasting
  3514. resources (mainly computation time). Instead POSIX.1b defines two
  3515. functions which will help with most kinds of consistency.
  3516. The ‘aio_fsync’ and ‘aio_fsync64’ functions are only available if the
  3517. symbol ‘_POSIX_SYNCHRONIZED_IO’ is defined in ‘unistd.h’.
  3518. -- Function: int aio_fsync (int OP, struct aiocb *AIOCBP)
  3519. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3520. *Note POSIX Safety Concepts::.
  3521. Calling this function forces all I/O operations queued at the time
  3522. of the function call operating on the file descriptor
  3523. ‘aiocbp->aio_fildes’ into the synchronized I/O completion state
  3524. (*note Synchronizing I/O::). The ‘aio_fsync’ function returns
  3525. immediately but the notification through the method described in
  3526. ‘aiocbp->aio_sigevent’ will happen only after all requests for this
  3527. file descriptor have terminated and the file is synchronized. This
  3528. also means that requests for this very same file descriptor which
  3529. are queued after the synchronization request are not affected.
  3530. If OP is ‘O_DSYNC’ the synchronization happens as with a call to
  3531. ‘fdatasync’. Otherwise OP should be ‘O_SYNC’ and the
  3532. synchronization happens as with ‘fsync’.
  3533. As long as the synchronization has not happened, a call to
  3534. ‘aio_error’ with the reference to the object pointed to by AIOCBP
  3535. returns ‘EINPROGRESS’. Once the synchronization is done
  3536. ‘aio_error’ return 0 if the synchronization was not successful.
  3537. Otherwise the value returned is the value to which the ‘fsync’ or
  3538. ‘fdatasync’ function would have set the ‘errno’ variable. In this
  3539. case nothing can be assumed about the consistency of the data
  3540. written to this file descriptor.
  3541. The return value of this function is 0 if the request was
  3542. successfully enqueued. Otherwise the return value is -1 and
  3543. ‘errno’ is set to one of the following values:
  3544. ‘EAGAIN’
  3545. The request could not be enqueued due to temporary lack of
  3546. resources.
  3547. ‘EBADF’
  3548. The file descriptor ‘AIOCBP->aio_fildes’ is not valid.
  3549. ‘EINVAL’
  3550. The implementation does not support I/O synchronization or the
  3551. OP parameter is other than ‘O_DSYNC’ and ‘O_SYNC’.
  3552. ‘ENOSYS’
  3553. This function is not implemented.
  3554. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3555. function is in fact ‘aio_fsync64’ since the LFS interface
  3556. transparently replaces the normal implementation.
  3557. -- Function: int aio_fsync64 (int OP, struct aiocb64 *AIOCBP)
  3558. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3559. *Note POSIX Safety Concepts::.
  3560. This function is similar to ‘aio_fsync’ with the only difference
  3561. that the argument is a reference to a variable of type ‘struct
  3562. aiocb64’.
  3563. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3564. function is available under the name ‘aio_fsync’ and so
  3565. transparently replaces the interface for small files on 32 bit
  3566. machines.
  3567. Another method of synchronization is to wait until one or more
  3568. requests of a specific set terminated. This could be achieved by the
  3569. ‘aio_*’ functions to notify the initiating process about the termination
  3570. but in some situations this is not the ideal solution. In a program
  3571. which constantly updates clients somehow connected to the server it is
  3572. not always the best solution to go round robin since some connections
  3573. might be slow. On the other hand letting the ‘aio_*’ functions notify
  3574. the caller might also be not the best solution since whenever the
  3575. process works on preparing data for a client it makes no sense to be
  3576. interrupted by a notification since the new client will not be handled
  3577. before the current client is served. For situations like this
  3578. ‘aio_suspend’ should be used.
  3579. -- Function: int aio_suspend (const struct aiocb *const LIST[], int
  3580. NENT, const struct timespec *TIMEOUT)
  3581. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3582. POSIX Safety Concepts::.
  3583. When calling this function, the calling thread is suspended until
  3584. at least one of the requests pointed to by the NENT elements of the
  3585. array LIST has completed. If any of the requests has already
  3586. completed at the time ‘aio_suspend’ is called, the function returns
  3587. immediately. Whether a request has terminated or not is determined
  3588. by comparing the error status of the request with ‘EINPROGRESS’.
  3589. If an element of LIST is ‘NULL’, the entry is simply ignored.
  3590. If no request has finished, the calling process is suspended. If
  3591. TIMEOUT is ‘NULL’, the process is not woken until a request has
  3592. finished. If TIMEOUT is not ‘NULL’, the process remains suspended
  3593. at least as long as specified in TIMEOUT. In this case,
  3594. ‘aio_suspend’ returns with an error.
  3595. The return value of the function is 0 if one or more requests from
  3596. the LIST have terminated. Otherwise the function returns -1 and
  3597. ‘errno’ is set to one of the following values:
  3598. ‘EAGAIN’
  3599. None of the requests from the LIST completed in the time
  3600. specified by TIMEOUT.
  3601. ‘EINTR’
  3602. A signal interrupted the ‘aio_suspend’ function. This signal
  3603. might also be sent by the AIO implementation while signalling
  3604. the termination of one of the requests.
  3605. ‘ENOSYS’
  3606. The ‘aio_suspend’ function is not implemented.
  3607. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3608. function is in fact ‘aio_suspend64’ since the LFS interface
  3609. transparently replaces the normal implementation.
  3610. -- Function: int aio_suspend64 (const struct aiocb64 *const LIST[], int
  3611. NENT, const struct timespec *TIMEOUT)
  3612. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3613. POSIX Safety Concepts::.
  3614. This function is similar to ‘aio_suspend’ with the only difference
  3615. that the argument is a reference to a variable of type ‘struct
  3616. aiocb64’.
  3617. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  3618. function is available under the name ‘aio_suspend’ and so
  3619. transparently replaces the interface for small files on 32 bit
  3620. machines.
  3621. 
  3622. File: libc.info, Node: Cancel AIO Operations, Next: Configuration of AIO, Prev: Synchronizing AIO Operations, Up: Asynchronous I/O
  3623. 13.11.4 Cancellation of AIO Operations
  3624. --------------------------------------
  3625. When one or more requests are asynchronously processed, it might be
  3626. useful in some situations to cancel a selected operation, e.g., if it
  3627. becomes obvious that the written data is no longer accurate and would
  3628. have to be overwritten soon. As an example, assume an application,
  3629. which writes data in files in a situation where new incoming data would
  3630. have to be written in a file which will be updated by an enqueued
  3631. request. The POSIX AIO implementation provides such a function, but
  3632. this function is not capable of forcing the cancellation of the request.
  3633. It is up to the implementation to decide whether it is possible to
  3634. cancel the operation or not. Therefore using this function is merely a
  3635. hint.
  3636. -- Function: int aio_cancel (int FILDES, struct aiocb *AIOCBP)
  3637. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3638. *Note POSIX Safety Concepts::.
  3639. The ‘aio_cancel’ function can be used to cancel one or more
  3640. outstanding requests. If the AIOCBP parameter is ‘NULL’, the
  3641. function tries to cancel all of the outstanding requests which
  3642. would process the file descriptor FILDES (i.e., whose ‘aio_fildes’
  3643. member is FILDES). If AIOCBP is not ‘NULL’, ‘aio_cancel’ attempts
  3644. to cancel the specific request pointed to by AIOCBP.
  3645. For requests which were successfully canceled, the normal
  3646. notification about the termination of the request should take
  3647. place. I.e., depending on the ‘struct sigevent’ object which
  3648. controls this, nothing happens, a signal is sent or a thread is
  3649. started. If the request cannot be canceled, it terminates the
  3650. usual way after performing the operation.
  3651. After a request is successfully canceled, a call to ‘aio_error’
  3652. with a reference to this request as the parameter will return
  3653. ‘ECANCELED’ and a call to ‘aio_return’ will return -1. If the
  3654. request wasn’t canceled and is still running the error status is
  3655. still ‘EINPROGRESS’.
  3656. The return value of the function is ‘AIO_CANCELED’ if there were
  3657. requests which haven’t terminated and which were successfully
  3658. canceled. If there is one or more requests left which couldn’t be
  3659. canceled, the return value is ‘AIO_NOTCANCELED’. In this case
  3660. ‘aio_error’ must be used to find out which of the, perhaps
  3661. multiple, requests (if AIOCBP is ‘NULL’) weren’t successfully
  3662. canceled. If all requests already terminated at the time
  3663. ‘aio_cancel’ is called the return value is ‘AIO_ALLDONE’.
  3664. If an error occurred during the execution of ‘aio_cancel’ the
  3665. function returns -1 and sets ‘errno’ to one of the following
  3666. values.
  3667. ‘EBADF’
  3668. The file descriptor FILDES is not valid.
  3669. ‘ENOSYS’
  3670. ‘aio_cancel’ is not implemented.
  3671. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3672. function is in fact ‘aio_cancel64’ since the LFS interface
  3673. transparently replaces the normal implementation.
  3674. -- Function: int aio_cancel64 (int FILDES, struct aiocb64 *AIOCBP)
  3675. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  3676. *Note POSIX Safety Concepts::.
  3677. This function is similar to ‘aio_cancel’ with the only difference
  3678. that the argument is a reference to a variable of type ‘struct
  3679. aiocb64’.
  3680. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’, this
  3681. function is available under the name ‘aio_cancel’ and so
  3682. transparently replaces the interface for small files on 32 bit
  3683. machines.
  3684. 
  3685. File: libc.info, Node: Configuration of AIO, Prev: Cancel AIO Operations, Up: Asynchronous I/O
  3686. 13.11.5 How to optimize the AIO implementation
  3687. ----------------------------------------------
  3688. The POSIX standard does not specify how the AIO functions are
  3689. implemented. They could be system calls, but it is also possible to
  3690. emulate them at userlevel.
  3691. At the time of writing, the available implementation is a user-level
  3692. implementation which uses threads for handling the enqueued requests.
  3693. While this implementation requires making some decisions about
  3694. limitations, hard limitations are something best avoided in the GNU C
  3695. Library. Therefore, the GNU C Library provides a means for tuning the
  3696. AIO implementation according to the individual use.
  3697. -- Data Type: struct aioinit
  3698. This data type is used to pass the configuration or tunable
  3699. parameters to the implementation. The program has to initialize
  3700. the members of this struct and pass it to the implementation using
  3701. the ‘aio_init’ function.
  3702. ‘int aio_threads’
  3703. This member specifies the maximal number of threads which may
  3704. be used at any one time.
  3705. ‘int aio_num’
  3706. This number provides an estimate on the maximal number of
  3707. simultaneously enqueued requests.
  3708. ‘int aio_locks’
  3709. Unused.
  3710. ‘int aio_usedba’
  3711. Unused.
  3712. ‘int aio_debug’
  3713. Unused.
  3714. ‘int aio_numusers’
  3715. Unused.
  3716. ‘int aio_reserved[2]’
  3717. Unused.
  3718. -- Function: void aio_init (const struct aioinit *INIT)
  3719. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3720. POSIX Safety Concepts::.
  3721. This function must be called before any other AIO function.
  3722. Calling it is completely voluntary, as it is only meant to help the
  3723. AIO implementation perform better.
  3724. Before calling ‘aio_init’, the members of a variable of type
  3725. ‘struct aioinit’ must be initialized. Then a reference to this
  3726. variable is passed as the parameter to ‘aio_init’ which itself may
  3727. or may not pay attention to the hints.
  3728. The function has no return value and no error cases are defined.
  3729. It is an extension which follows a proposal from the SGI
  3730. implementation in Irix 6. It is not covered by POSIX.1b or Unix98.
  3731. 
  3732. File: libc.info, Node: Control Operations, Next: Duplicating Descriptors, Prev: Asynchronous I/O, Up: Low-Level I/O
  3733. 13.12 Control Operations on Files
  3734. =================================
  3735. This section describes how you can perform various other operations on
  3736. file descriptors, such as inquiring about or setting flags describing
  3737. the status of the file descriptor, manipulating record locks, and the
  3738. like. All of these operations are performed by the function ‘fcntl’.
  3739. The second argument to the ‘fcntl’ function is a command that
  3740. specifies which operation to perform. The function and macros that name
  3741. various flags that are used with it are declared in the header file
  3742. ‘fcntl.h’. Many of these flags are also used by the ‘open’ function;
  3743. see *note Opening and Closing Files::.
  3744. -- Function: int fcntl (int FILEDES, int COMMAND, ...)
  3745. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3746. Concepts::.
  3747. The ‘fcntl’ function performs the operation specified by COMMAND on
  3748. the file descriptor FILEDES. Some commands require additional
  3749. arguments to be supplied. These additional arguments and the
  3750. return value and error conditions are given in the detailed
  3751. descriptions of the individual commands.
  3752. Briefly, here is a list of what the various commands are.
  3753. ‘F_DUPFD’
  3754. Duplicate the file descriptor (return another file descriptor
  3755. pointing to the same open file). *Note Duplicating
  3756. Descriptors::.
  3757. ‘F_GETFD’
  3758. Get flags associated with the file descriptor. *Note
  3759. Descriptor Flags::.
  3760. ‘F_SETFD’
  3761. Set flags associated with the file descriptor. *Note
  3762. Descriptor Flags::.
  3763. ‘F_GETFL’
  3764. Get flags associated with the open file. *Note File Status
  3765. Flags::.
  3766. ‘F_SETFL’
  3767. Set flags associated with the open file. *Note File Status
  3768. Flags::.
  3769. ‘F_GETLK’
  3770. Test a file lock. *Note File Locks::.
  3771. ‘F_SETLK’
  3772. Set or clear a file lock. *Note File Locks::.
  3773. ‘F_SETLKW’
  3774. Like ‘F_SETLK’, but wait for completion. *Note File Locks::.
  3775. ‘F_OFD_GETLK’
  3776. Test an open file description lock. *Note Open File
  3777. Description Locks::. Specific to Linux.
  3778. ‘F_OFD_SETLK’
  3779. Set or clear an open file description lock. *Note Open File
  3780. Description Locks::. Specific to Linux.
  3781. ‘F_OFD_SETLKW’
  3782. Like ‘F_OFD_SETLK’, but block until lock is acquired. *Note
  3783. Open File Description Locks::. Specific to Linux.
  3784. ‘F_GETOWN’
  3785. Get process or process group ID to receive ‘SIGIO’ signals.
  3786. *Note Interrupt Input::.
  3787. ‘F_SETOWN’
  3788. Set process or process group ID to receive ‘SIGIO’ signals.
  3789. *Note Interrupt Input::.
  3790. This function is a cancellation point in multi-threaded programs
  3791. for the commands ‘F_SETLKW’ (and the LFS analogous ‘F_SETLKW64’)
  3792. and ‘F_OFD_SETLKW’. This is a problem if the thread allocates some
  3793. resources (like memory, file descriptors, semaphores or whatever)
  3794. at the time ‘fcntl’ is called. If the thread gets canceled these
  3795. resources stay allocated until the program ends. To avoid this
  3796. calls to ‘fcntl’ should be protected using cancellation handlers.
  3797. 
  3798. File: libc.info, Node: Duplicating Descriptors, Next: Descriptor Flags, Prev: Control Operations, Up: Low-Level I/O
  3799. 13.13 Duplicating Descriptors
  3800. =============================
  3801. You can “duplicate” a file descriptor, or allocate another file
  3802. descriptor that refers to the same open file as the original. Duplicate
  3803. descriptors share one file position and one set of file status flags
  3804. (*note File Status Flags::), but each has its own set of file descriptor
  3805. flags (*note Descriptor Flags::).
  3806. The major use of duplicating a file descriptor is to implement
  3807. “redirection” of input or output: that is, to change the file or pipe
  3808. that a particular file descriptor corresponds to.
  3809. You can perform this operation using the ‘fcntl’ function with the
  3810. ‘F_DUPFD’ command, but there are also convenient functions ‘dup’ and
  3811. ‘dup2’ for duplicating descriptors.
  3812. The ‘fcntl’ function and flags are declared in ‘fcntl.h’, while
  3813. prototypes for ‘dup’ and ‘dup2’ are in the header file ‘unistd.h’.
  3814. -- Function: int dup (int OLD)
  3815. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3816. Concepts::.
  3817. This function copies descriptor OLD to the first available
  3818. descriptor number (the first number not currently open). It is
  3819. equivalent to ‘fcntl (OLD, F_DUPFD, 0)’.
  3820. -- Function: int dup2 (int OLD, int NEW)
  3821. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3822. Concepts::.
  3823. This function copies the descriptor OLD to descriptor number NEW.
  3824. If OLD is an invalid descriptor, then ‘dup2’ does nothing; it does
  3825. not close NEW. Otherwise, the new duplicate of OLD replaces any
  3826. previous meaning of descriptor NEW, as if NEW were closed first.
  3827. If OLD and NEW are different numbers, and OLD is a valid descriptor
  3828. number, then ‘dup2’ is equivalent to:
  3829. close (NEW);
  3830. fcntl (OLD, F_DUPFD, NEW)
  3831. However, ‘dup2’ does this atomically; there is no instant in the
  3832. middle of calling ‘dup2’ at which NEW is closed and not yet a
  3833. duplicate of OLD.
  3834. -- Macro: int F_DUPFD
  3835. This macro is used as the COMMAND argument to ‘fcntl’, to copy the
  3836. file descriptor given as the first argument.
  3837. The form of the call in this case is:
  3838. fcntl (OLD, F_DUPFD, NEXT-FILEDES)
  3839. The NEXT-FILEDES argument is of type ‘int’ and specifies that the
  3840. file descriptor returned should be the next available one greater
  3841. than or equal to this value.
  3842. The return value from ‘fcntl’ with this command is normally the
  3843. value of the new file descriptor. A return value of -1 indicates
  3844. an error. The following ‘errno’ error conditions are defined for
  3845. this command:
  3846. ‘EBADF’
  3847. The OLD argument is invalid.
  3848. ‘EINVAL’
  3849. The NEXT-FILEDES argument is invalid.
  3850. ‘EMFILE’
  3851. There are no more file descriptors available—your program is
  3852. already using the maximum. In BSD and GNU, the maximum is
  3853. controlled by a resource limit that can be changed; *note
  3854. Limits on Resources::, for more information about the
  3855. ‘RLIMIT_NOFILE’ limit.
  3856. ‘ENFILE’ is not a possible error code for ‘dup2’ because ‘dup2’
  3857. does not create a new opening of a file; duplicate descriptors do
  3858. not count toward the limit which ‘ENFILE’ indicates. ‘EMFILE’ is
  3859. possible because it refers to the limit on distinct descriptor
  3860. numbers in use in one process.
  3861. Here is an example showing how to use ‘dup2’ to do redirection.
  3862. Typically, redirection of the standard streams (like ‘stdin’) is done by
  3863. a shell or shell-like program before calling one of the ‘exec’ functions
  3864. (*note Executing a File::) to execute a new program in a child process.
  3865. When the new program is executed, it creates and initializes the
  3866. standard streams to point to the corresponding file descriptors, before
  3867. its ‘main’ function is invoked.
  3868. So, to redirect standard input to a file, the shell could do
  3869. something like:
  3870. pid = fork ();
  3871. if (pid == 0)
  3872. {
  3873. char *filename;
  3874. char *program;
  3875. int file;
  3876. ...
  3877. file = TEMP_FAILURE_RETRY (open (filename, O_RDONLY));
  3878. dup2 (file, STDIN_FILENO);
  3879. TEMP_FAILURE_RETRY (close (file));
  3880. execv (program, NULL);
  3881. }
  3882. There is also a more detailed example showing how to implement
  3883. redirection in the context of a pipeline of processes in *note Launching
  3884. Jobs::.
  3885. 
  3886. File: libc.info, Node: Descriptor Flags, Next: File Status Flags, Prev: Duplicating Descriptors, Up: Low-Level I/O
  3887. 13.14 File Descriptor Flags
  3888. ===========================
  3889. “File descriptor flags” are miscellaneous attributes of a file
  3890. descriptor. These flags are associated with particular file
  3891. descriptors, so that if you have created duplicate file descriptors from
  3892. a single opening of a file, each descriptor has its own set of flags.
  3893. Currently there is just one file descriptor flag: ‘FD_CLOEXEC’, which
  3894. causes the descriptor to be closed if you use any of the ‘exec...’
  3895. functions (*note Executing a File::).
  3896. The symbols in this section are defined in the header file ‘fcntl.h’.
  3897. -- Macro: int F_GETFD
  3898. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  3899. that it should return the file descriptor flags associated with the
  3900. FILEDES argument.
  3901. The normal return value from ‘fcntl’ with this command is a
  3902. nonnegative number which can be interpreted as the bitwise OR of
  3903. the individual flags (except that currently there is only one flag
  3904. to use).
  3905. In case of an error, ‘fcntl’ returns -1. The following ‘errno’
  3906. error conditions are defined for this command:
  3907. ‘EBADF’
  3908. The FILEDES argument is invalid.
  3909. -- Macro: int F_SETFD
  3910. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  3911. that it should set the file descriptor flags associated with the
  3912. FILEDES argument. This requires a third ‘int’ argument to specify
  3913. the new flags, so the form of the call is:
  3914. fcntl (FILEDES, F_SETFD, NEW-FLAGS)
  3915. The normal return value from ‘fcntl’ with this command is an
  3916. unspecified value other than -1, which indicates an error. The
  3917. flags and error conditions are the same as for the ‘F_GETFD’
  3918. command.
  3919. The following macro is defined for use as a file descriptor flag with
  3920. the ‘fcntl’ function. The value is an integer constant usable as a bit
  3921. mask value.
  3922. -- Macro: int FD_CLOEXEC
  3923. This flag specifies that the file descriptor should be closed when
  3924. an ‘exec’ function is invoked; see *note Executing a File::. When
  3925. a file descriptor is allocated (as with ‘open’ or ‘dup’), this bit
  3926. is initially cleared on the new file descriptor, meaning that
  3927. descriptor will survive into the new program after ‘exec’.
  3928. If you want to modify the file descriptor flags, you should get the
  3929. current flags with ‘F_GETFD’ and modify the value. Don’t assume that
  3930. the flags listed here are the only ones that are implemented; your
  3931. program may be run years from now and more flags may exist then. For
  3932. example, here is a function to set or clear the flag ‘FD_CLOEXEC’
  3933. without altering any other flags:
  3934. /* Set the ‘FD_CLOEXEC’ flag of DESC if VALUE is nonzero,
  3935. or clear the flag if VALUE is 0.
  3936. Return 0 on success, or -1 on error with ‘errno’ set. */
  3937. int
  3938. set_cloexec_flag (int desc, int value)
  3939. {
  3940. int oldflags = fcntl (desc, F_GETFD, 0);
  3941. /* If reading the flags failed, return error indication now. */
  3942. if (oldflags < 0)
  3943. return oldflags;
  3944. /* Set just the flag we want to set. */
  3945. if (value != 0)
  3946. oldflags |= FD_CLOEXEC;
  3947. else
  3948. oldflags &= ~FD_CLOEXEC;
  3949. /* Store modified flag word in the descriptor. */
  3950. return fcntl (desc, F_SETFD, oldflags);
  3951. }
  3952. 
  3953. File: libc.info, Node: File Status Flags, Next: File Locks, Prev: Descriptor Flags, Up: Low-Level I/O
  3954. 13.15 File Status Flags
  3955. =======================
  3956. “File status flags” are used to specify attributes of the opening of a
  3957. file. Unlike the file descriptor flags discussed in *note Descriptor
  3958. Flags::, the file status flags are shared by duplicated file descriptors
  3959. resulting from a single opening of the file. The file status flags are
  3960. specified with the FLAGS argument to ‘open’; *note Opening and Closing
  3961. Files::.
  3962. File status flags fall into three categories, which are described in
  3963. the following sections.
  3964. • *note Access Modes::, specify what type of access is allowed to the
  3965. file: reading, writing, or both. They are set by ‘open’ and are
  3966. returned by ‘fcntl’, but cannot be changed.
  3967. • *note Open-time Flags::, control details of what ‘open’ will do.
  3968. These flags are not preserved after the ‘open’ call.
  3969. • *note Operating Modes::, affect how operations such as ‘read’ and
  3970. ‘write’ are done. They are set by ‘open’, and can be fetched or
  3971. changed with ‘fcntl’.
  3972. The symbols in this section are defined in the header file ‘fcntl.h’.
  3973. * Menu:
  3974. * Access Modes:: Whether the descriptor can read or write.
  3975. * Open-time Flags:: Details of ‘open’.
  3976. * Operating Modes:: Special modes to control I/O operations.
  3977. * Getting File Status Flags:: Fetching and changing these flags.
  3978. 
  3979. File: libc.info, Node: Access Modes, Next: Open-time Flags, Up: File Status Flags
  3980. 13.15.1 File Access Modes
  3981. -------------------------
  3982. The file access mode allows a file descriptor to be used for reading,
  3983. writing, both, or neither. The access mode is determined when the file
  3984. is opened, and never change.
  3985. -- Macro: int O_RDONLY
  3986. Open the file for read access.
  3987. -- Macro: int O_WRONLY
  3988. Open the file for write access.
  3989. -- Macro: int O_RDWR
  3990. Open the file for both reading and writing.
  3991. -- Macro: int O_PATH
  3992. Obtain a file descriptor for the file, but do not open the file for
  3993. reading or writing. Permission checks for the file itself are
  3994. skipped when the file is opened (but permission to access the
  3995. directory that contains it is still needed), and permissions are
  3996. checked when the descriptor is used later on.
  3997. For example, such descriptors can be used with the ‘fexecve’
  3998. function (*note Executing a File::).
  3999. This access mode is specific to Linux. On GNU/Hurd systems, it is
  4000. possible to use ‘O_EXEC’ explicitly, or specify no access modes at
  4001. all (see below).
  4002. The portable file access modes ‘O_RDONLY’, ‘O_WRONLY’, and ‘O_RDWR’
  4003. may not correspond to individual bits. To determine the file access
  4004. mode with ‘fcntl’, you must extract the access mode bits from the
  4005. retrieved file status flags, using the ‘O_ACCMODE’ mask.
  4006. -- Macro: int O_ACCMODE
  4007. This macro is a mask that can be bitwise-ANDed with the file status
  4008. flag value to recover the file access mode, assuming that a
  4009. standard file access mode is in use.
  4010. If a non-standard file access mode is used (such as ‘O_PATH’ or
  4011. ‘O_EXEC’), masking with ‘O_ACCMODE’ may give incorrect results. These
  4012. non-standard access modes are identified by individual bits and have to
  4013. be checked directly (without masking with ‘O_ACCMODE’ first).
  4014. On GNU/Hurd systems (but not on other systems), ‘O_RDONLY’ and
  4015. ‘O_WRONLY’ are independent bits that can be bitwise-ORed together, and
  4016. it is valid for either bit to be set or clear. This means that ‘O_RDWR’
  4017. is the same as ‘O_RDONLY|O_WRONLY’. A file access mode of zero is
  4018. permissible; it allows no operations that do input or output to the
  4019. file, but does allow other operations such as ‘fchmod’. On GNU/Hurd
  4020. systems, since “read-only” or “write-only” is a misnomer, ‘fcntl.h’
  4021. defines additional names for the file access modes.
  4022. -- Macro: int O_READ
  4023. Open the file for reading. Same as ‘O_RDONLY’; only defined on
  4024. GNU/Hurd.
  4025. -- Macro: int O_WRITE
  4026. Open the file for writing. Same as ‘O_WRONLY’; only defined on
  4027. GNU/Hurd.
  4028. -- Macro: int O_EXEC
  4029. Open the file for executing. Only defined on GNU/Hurd.
  4030. 
  4031. File: libc.info, Node: Open-time Flags, Next: Operating Modes, Prev: Access Modes, Up: File Status Flags
  4032. 13.15.2 Open-time Flags
  4033. -----------------------
  4034. The open-time flags specify options affecting how ‘open’ will behave.
  4035. These options are not preserved once the file is open. The exception to
  4036. this is ‘O_NONBLOCK’, which is also an I/O operating mode and so it _is_
  4037. saved. *Note Opening and Closing Files::, for how to call ‘open’.
  4038. There are two sorts of options specified by open-time flags.
  4039. • “File name translation flags” affect how ‘open’ looks up the file
  4040. name to locate the file, and whether the file can be created.
  4041. • “Open-time action flags” specify extra operations that ‘open’ will
  4042. perform on the file once it is open.
  4043. Here are the file name translation flags.
  4044. -- Macro: int O_CREAT
  4045. If set, the file will be created if it doesn’t already exist.
  4046. -- Macro: int O_EXCL
  4047. If both ‘O_CREAT’ and ‘O_EXCL’ are set, then ‘open’ fails if the
  4048. specified file already exists. This is guaranteed to never clobber
  4049. an existing file.
  4050. The ‘O_EXCL’ flag has a special meaning in combination with
  4051. ‘O_TMPFILE’; see below.
  4052. -- Macro: int O_DIRECTORY
  4053. If set, the open operation fails if the given name is not the name
  4054. of a directory. The ‘errno’ variable is set to ‘ENOTDIR’ for this
  4055. error condition.
  4056. -- Macro: int O_NOFOLLOW
  4057. If set, the open operation fails if the final component of the file
  4058. name refers to a symbolic link. The ‘errno’ variable is set to
  4059. ‘ELOOP’ for this error condition.
  4060. -- Macro: int O_TMPFILE
  4061. If this flag is specified, functions in the ‘open’ family create an
  4062. unnamed temporary file. In this case, the pathname argument to the
  4063. ‘open’ family of functions (*note Opening and Closing Files::) is
  4064. interpreted as the directory in which the temporary file is created
  4065. (thus determining the file system which provides the storage for
  4066. the file). The ‘O_TMPFILE’ flag must be combined with ‘O_WRONLY’
  4067. or ‘O_RDWR’, and the MODE argument is required.
  4068. The temporary file can later be given a name using ‘linkat’,
  4069. turning it into a regular file. This allows the atomic creation of
  4070. a file with the specific file attributes (mode and extended
  4071. attributes) and file contents. If, for security reasons, it is not
  4072. desirable that a name can be given to the file, the ‘O_EXCL’ flag
  4073. can be specified along with ‘O_TMPFILE’.
  4074. Not all kernels support this open flag. If this flag is
  4075. unsupported, an attempt to create an unnamed temporary file fails
  4076. with an error of ‘EINVAL’. If the underlying file system does not
  4077. support the ‘O_TMPFILE’ flag, an ‘EOPNOTSUPP’ error is the result.
  4078. The ‘O_TMPFILE’ flag is a GNU extension.
  4079. -- Macro: int O_NONBLOCK
  4080. This prevents ‘open’ from blocking for a “long time” to open the
  4081. file. This is only meaningful for some kinds of files, usually
  4082. devices such as serial ports; when it is not meaningful, it is
  4083. harmless and ignored. Often, opening a port to a modem blocks
  4084. until the modem reports carrier detection; if ‘O_NONBLOCK’ is
  4085. specified, ‘open’ will return immediately without a carrier.
  4086. Note that the ‘O_NONBLOCK’ flag is overloaded as both an I/O
  4087. operating mode and a file name translation flag. This means that
  4088. specifying ‘O_NONBLOCK’ in ‘open’ also sets nonblocking I/O mode;
  4089. *note Operating Modes::. To open the file without blocking but do
  4090. normal I/O that blocks, you must call ‘open’ with ‘O_NONBLOCK’ set
  4091. and then call ‘fcntl’ to turn the bit off.
  4092. -- Macro: int O_NOCTTY
  4093. If the named file is a terminal device, don’t make it the
  4094. controlling terminal for the process. *Note Job Control::, for
  4095. information about what it means to be the controlling terminal.
  4096. On GNU/Hurd systems and 4.4 BSD, opening a file never makes it the
  4097. controlling terminal and ‘O_NOCTTY’ is zero. However, GNU/Linux
  4098. systems and some other systems use a nonzero value for ‘O_NOCTTY’
  4099. and set the controlling terminal when you open a file that is a
  4100. terminal device; so to be portable, use ‘O_NOCTTY’ when it is
  4101. important to avoid this.
  4102. The following three file name translation flags exist only on
  4103. GNU/Hurd systems.
  4104. -- Macro: int O_IGNORE_CTTY
  4105. Do not recognize the named file as the controlling terminal, even
  4106. if it refers to the process’s existing controlling terminal device.
  4107. Operations on the new file descriptor will never induce job control
  4108. signals. *Note Job Control::.
  4109. -- Macro: int O_NOLINK
  4110. If the named file is a symbolic link, open the link itself instead
  4111. of the file it refers to. (‘fstat’ on the new file descriptor will
  4112. return the information returned by ‘lstat’ on the link’s name.)
  4113. -- Macro: int O_NOTRANS
  4114. If the named file is specially translated, do not invoke the
  4115. translator. Open the bare file the translator itself sees.
  4116. The open-time action flags tell ‘open’ to do additional operations
  4117. which are not really related to opening the file. The reason to do them
  4118. as part of ‘open’ instead of in separate calls is that ‘open’ can do
  4119. them atomically.
  4120. -- Macro: int O_TRUNC
  4121. Truncate the file to zero length. This option is only useful for
  4122. regular files, not special files such as directories or FIFOs.
  4123. POSIX.1 requires that you open the file for writing to use
  4124. ‘O_TRUNC’. In BSD and GNU you must have permission to write the
  4125. file to truncate it, but you need not open for write access.
  4126. This is the only open-time action flag specified by POSIX.1. There
  4127. is no good reason for truncation to be done by ‘open’, instead of
  4128. by calling ‘ftruncate’ afterwards. The ‘O_TRUNC’ flag existed in
  4129. Unix before ‘ftruncate’ was invented, and is retained for backward
  4130. compatibility.
  4131. The remaining operating modes are BSD extensions. They exist only on
  4132. some systems. On other systems, these macros are not defined.
  4133. -- Macro: int O_SHLOCK
  4134. Acquire a shared lock on the file, as with ‘flock’. *Note File
  4135. Locks::.
  4136. If ‘O_CREAT’ is specified, the locking is done atomically when
  4137. creating the file. You are guaranteed that no other process will
  4138. get the lock on the new file first.
  4139. -- Macro: int O_EXLOCK
  4140. Acquire an exclusive lock on the file, as with ‘flock’. *Note File
  4141. Locks::. This is atomic like ‘O_SHLOCK’.
  4142. 
  4143. File: libc.info, Node: Operating Modes, Next: Getting File Status Flags, Prev: Open-time Flags, Up: File Status Flags
  4144. 13.15.3 I/O Operating Modes
  4145. ---------------------------
  4146. The operating modes affect how input and output operations using a file
  4147. descriptor work. These flags are set by ‘open’ and can be fetched and
  4148. changed with ‘fcntl’.
  4149. -- Macro: int O_APPEND
  4150. The bit that enables append mode for the file. If set, then all
  4151. ‘write’ operations write the data at the end of the file, extending
  4152. it, regardless of the current file position. This is the only
  4153. reliable way to append to a file. In append mode, you are
  4154. guaranteed that the data you write will always go to the current
  4155. end of the file, regardless of other processes writing to the file.
  4156. Conversely, if you simply set the file position to the end of file
  4157. and write, then another process can extend the file after you set
  4158. the file position but before you write, resulting in your data
  4159. appearing someplace before the real end of file.
  4160. -- Macro: int O_NONBLOCK
  4161. The bit that enables nonblocking mode for the file. If this bit is
  4162. set, ‘read’ requests on the file can return immediately with a
  4163. failure status if there is no input immediately available, instead
  4164. of blocking. Likewise, ‘write’ requests can also return
  4165. immediately with a failure status if the output can’t be written
  4166. immediately.
  4167. Note that the ‘O_NONBLOCK’ flag is overloaded as both an I/O
  4168. operating mode and a file name translation flag; *note Open-time
  4169. Flags::.
  4170. -- Macro: int O_NDELAY
  4171. This is an obsolete name for ‘O_NONBLOCK’, provided for
  4172. compatibility with BSD. It is not defined by the POSIX.1 standard.
  4173. The remaining operating modes are BSD and GNU extensions. They exist
  4174. only on some systems. On other systems, these macros are not defined.
  4175. -- Macro: int O_ASYNC
  4176. The bit that enables asynchronous input mode. If set, then ‘SIGIO’
  4177. signals will be generated when input is available. *Note Interrupt
  4178. Input::.
  4179. Asynchronous input mode is a BSD feature.
  4180. -- Macro: int O_FSYNC
  4181. The bit that enables synchronous writing for the file. If set,
  4182. each ‘write’ call will make sure the data is reliably stored on
  4183. disk before returning.
  4184. Synchronous writing is a BSD feature.
  4185. -- Macro: int O_SYNC
  4186. This is another name for ‘O_FSYNC’. They have the same value.
  4187. -- Macro: int O_NOATIME
  4188. If this bit is set, ‘read’ will not update the access time of the
  4189. file. *Note File Times::. This is used by programs that do
  4190. backups, so that backing a file up does not count as reading it.
  4191. Only the owner of the file or the superuser may use this bit.
  4192. This is a GNU extension.
  4193. 
  4194. File: libc.info, Node: Getting File Status Flags, Prev: Operating Modes, Up: File Status Flags
  4195. 13.15.4 Getting and Setting File Status Flags
  4196. ---------------------------------------------
  4197. The ‘fcntl’ function can fetch or change file status flags.
  4198. -- Macro: int F_GETFL
  4199. This macro is used as the COMMAND argument to ‘fcntl’, to read the
  4200. file status flags for the open file with descriptor FILEDES.
  4201. The normal return value from ‘fcntl’ with this command is a
  4202. nonnegative number which can be interpreted as the bitwise OR of
  4203. the individual flags. Since the file access modes are not
  4204. single-bit values, you can mask off other bits in the returned
  4205. flags with ‘O_ACCMODE’ to compare them.
  4206. In case of an error, ‘fcntl’ returns -1. The following ‘errno’
  4207. error conditions are defined for this command:
  4208. ‘EBADF’
  4209. The FILEDES argument is invalid.
  4210. -- Macro: int F_SETFL
  4211. This macro is used as the COMMAND argument to ‘fcntl’, to set the
  4212. file status flags for the open file corresponding to the FILEDES
  4213. argument. This command requires a third ‘int’ argument to specify
  4214. the new flags, so the call looks like this:
  4215. fcntl (FILEDES, F_SETFL, NEW-FLAGS)
  4216. You can’t change the access mode for the file in this way; that is,
  4217. whether the file descriptor was opened for reading or writing.
  4218. The normal return value from ‘fcntl’ with this command is an
  4219. unspecified value other than -1, which indicates an error. The
  4220. error conditions are the same as for the ‘F_GETFL’ command.
  4221. If you want to modify the file status flags, you should get the
  4222. current flags with ‘F_GETFL’ and modify the value. Don’t assume that
  4223. the flags listed here are the only ones that are implemented; your
  4224. program may be run years from now and more flags may exist then. For
  4225. example, here is a function to set or clear the flag ‘O_NONBLOCK’
  4226. without altering any other flags:
  4227. /* Set the ‘O_NONBLOCK’ flag of DESC if VALUE is nonzero,
  4228. or clear the flag if VALUE is 0.
  4229. Return 0 on success, or -1 on error with ‘errno’ set. */
  4230. int
  4231. set_nonblock_flag (int desc, int value)
  4232. {
  4233. int oldflags = fcntl (desc, F_GETFL, 0);
  4234. /* If reading the flags failed, return error indication now. */
  4235. if (oldflags == -1)
  4236. return -1;
  4237. /* Set just the flag we want to set. */
  4238. if (value != 0)
  4239. oldflags |= O_NONBLOCK;
  4240. else
  4241. oldflags &= ~O_NONBLOCK;
  4242. /* Store modified flag word in the descriptor. */
  4243. return fcntl (desc, F_SETFL, oldflags);
  4244. }
  4245. 
  4246. File: libc.info, Node: File Locks, Next: Open File Description Locks, Prev: File Status Flags, Up: Low-Level I/O
  4247. 13.16 File Locks
  4248. ================
  4249. This section describes record locks that are associated with the
  4250. process. There is also a different type of record lock that is
  4251. associated with the open file description instead of the process. *Note
  4252. Open File Description Locks::.
  4253. The remaining ‘fcntl’ commands are used to support “record locking”,
  4254. which permits multiple cooperating programs to prevent each other from
  4255. simultaneously accessing parts of a file in error-prone ways.
  4256. An “exclusive” or “write” lock gives a process exclusive access for
  4257. writing to the specified part of the file. While a write lock is in
  4258. place, no other process can lock that part of the file.
  4259. A “shared” or “read” lock prohibits any other process from requesting
  4260. a write lock on the specified part of the file. However, other
  4261. processes can request read locks.
  4262. The ‘read’ and ‘write’ functions do not actually check to see whether
  4263. there are any locks in place. If you want to implement a locking
  4264. protocol for a file shared by multiple processes, your application must
  4265. do explicit ‘fcntl’ calls to request and clear locks at the appropriate
  4266. points.
  4267. Locks are associated with processes. A process can only have one
  4268. kind of lock set for each byte of a given file. When any file
  4269. descriptor for that file is closed by the process, all of the locks that
  4270. process holds on that file are released, even if the locks were made
  4271. using other descriptors that remain open. Likewise, locks are released
  4272. when a process exits, and are not inherited by child processes created
  4273. using ‘fork’ (*note Creating a Process::).
  4274. When making a lock, use a ‘struct flock’ to specify what kind of lock
  4275. and where. This data type and the associated macros for the ‘fcntl’
  4276. function are declared in the header file ‘fcntl.h’.
  4277. -- Data Type: struct flock
  4278. This structure is used with the ‘fcntl’ function to describe a file
  4279. lock. It has these members:
  4280. ‘short int l_type’
  4281. Specifies the type of the lock; one of ‘F_RDLCK’, ‘F_WRLCK’,
  4282. or ‘F_UNLCK’.
  4283. ‘short int l_whence’
  4284. This corresponds to the WHENCE argument to ‘fseek’ or ‘lseek’,
  4285. and specifies what the offset is relative to. Its value can
  4286. be one of ‘SEEK_SET’, ‘SEEK_CUR’, or ‘SEEK_END’.
  4287. ‘off_t l_start’
  4288. This specifies the offset of the start of the region to which
  4289. the lock applies, and is given in bytes relative to the point
  4290. specified by the ‘l_whence’ member.
  4291. ‘off_t l_len’
  4292. This specifies the length of the region to be locked. A value
  4293. of ‘0’ is treated specially; it means the region extends to
  4294. the end of the file.
  4295. ‘pid_t l_pid’
  4296. This field is the process ID (*note Process Creation
  4297. Concepts::) of the process holding the lock. It is filled in
  4298. by calling ‘fcntl’ with the ‘F_GETLK’ command, but is ignored
  4299. when making a lock. If the conflicting lock is an open file
  4300. description lock (*note Open File Description Locks::), then
  4301. this field will be set to -1.
  4302. -- Macro: int F_GETLK
  4303. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4304. that it should get information about a lock. This command requires
  4305. a third argument of type ‘struct flock *’ to be passed to ‘fcntl’,
  4306. so that the form of the call is:
  4307. fcntl (FILEDES, F_GETLK, LOCKP)
  4308. If there is a lock already in place that would block the lock
  4309. described by the LOCKP argument, information about that lock
  4310. overwrites ‘*LOCKP’. Existing locks are not reported if they are
  4311. compatible with making a new lock as specified. Thus, you should
  4312. specify a lock type of ‘F_WRLCK’ if you want to find out about both
  4313. read and write locks, or ‘F_RDLCK’ if you want to find out about
  4314. write locks only.
  4315. There might be more than one lock affecting the region specified by
  4316. the LOCKP argument, but ‘fcntl’ only returns information about one
  4317. of them. The ‘l_whence’ member of the LOCKP structure is set to
  4318. ‘SEEK_SET’ and the ‘l_start’ and ‘l_len’ fields set to identify the
  4319. locked region.
  4320. If no lock applies, the only change to the LOCKP structure is to
  4321. update the ‘l_type’ to a value of ‘F_UNLCK’.
  4322. The normal return value from ‘fcntl’ with this command is an
  4323. unspecified value other than -1, which is reserved to indicate an
  4324. error. The following ‘errno’ error conditions are defined for this
  4325. command:
  4326. ‘EBADF’
  4327. The FILEDES argument is invalid.
  4328. ‘EINVAL’
  4329. Either the LOCKP argument doesn’t specify valid lock
  4330. information, or the file associated with FILEDES doesn’t
  4331. support locks.
  4332. -- Macro: int F_SETLK
  4333. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4334. that it should set or clear a lock. This command requires a third
  4335. argument of type ‘struct flock *’ to be passed to ‘fcntl’, so that
  4336. the form of the call is:
  4337. fcntl (FILEDES, F_SETLK, LOCKP)
  4338. If the process already has a lock on any part of the region, the
  4339. old lock on that part is replaced with the new lock. You can
  4340. remove a lock by specifying a lock type of ‘F_UNLCK’.
  4341. If the lock cannot be set, ‘fcntl’ returns immediately with a value
  4342. of -1. This function does not block while waiting for other
  4343. processes to release locks. If ‘fcntl’ succeeds, it returns a
  4344. value other than -1.
  4345. The following ‘errno’ error conditions are defined for this
  4346. function:
  4347. ‘EAGAIN’
  4348. ‘EACCES’
  4349. The lock cannot be set because it is blocked by an existing
  4350. lock on the file. Some systems use ‘EAGAIN’ in this case, and
  4351. other systems use ‘EACCES’; your program should treat them
  4352. alike, after ‘F_SETLK’. (GNU/Linux and GNU/Hurd systems
  4353. always use ‘EAGAIN’.)
  4354. ‘EBADF’
  4355. Either: the FILEDES argument is invalid; you requested a read
  4356. lock but the FILEDES is not open for read access; or, you
  4357. requested a write lock but the FILEDES is not open for write
  4358. access.
  4359. ‘EINVAL’
  4360. Either the LOCKP argument doesn’t specify valid lock
  4361. information, or the file associated with FILEDES doesn’t
  4362. support locks.
  4363. ‘ENOLCK’
  4364. The system has run out of file lock resources; there are
  4365. already too many file locks in place.
  4366. Well-designed file systems never report this error, because
  4367. they have no limitation on the number of locks. However, you
  4368. must still take account of the possibility of this error, as
  4369. it could result from network access to a file system on
  4370. another machine.
  4371. -- Macro: int F_SETLKW
  4372. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4373. that it should set or clear a lock. It is just like the ‘F_SETLK’
  4374. command, but causes the process to block (or wait) until the
  4375. request can be specified.
  4376. This command requires a third argument of type ‘struct flock *’, as
  4377. for the ‘F_SETLK’ command.
  4378. The ‘fcntl’ return values and errors are the same as for the
  4379. ‘F_SETLK’ command, but these additional ‘errno’ error conditions
  4380. are defined for this command:
  4381. ‘EINTR’
  4382. The function was interrupted by a signal while it was waiting.
  4383. *Note Interrupted Primitives::.
  4384. ‘EDEADLK’
  4385. The specified region is being locked by another process. But
  4386. that process is waiting to lock a region which the current
  4387. process has locked, so waiting for the lock would result in
  4388. deadlock. The system does not guarantee that it will detect
  4389. all such conditions, but it lets you know if it notices one.
  4390. The following macros are defined for use as values for the ‘l_type’
  4391. member of the ‘flock’ structure. The values are integer constants.
  4392. ‘F_RDLCK’
  4393. This macro is used to specify a read (or shared) lock.
  4394. ‘F_WRLCK’
  4395. This macro is used to specify a write (or exclusive) lock.
  4396. ‘F_UNLCK’
  4397. This macro is used to specify that the region is unlocked.
  4398. As an example of a situation where file locking is useful, consider a
  4399. program that can be run simultaneously by several different users, that
  4400. logs status information to a common file. One example of such a program
  4401. might be a game that uses a file to keep track of high scores. Another
  4402. example might be a program that records usage or accounting information
  4403. for billing purposes.
  4404. Having multiple copies of the program simultaneously writing to the
  4405. file could cause the contents of the file to become mixed up. But you
  4406. can prevent this kind of problem by setting a write lock on the file
  4407. before actually writing to the file.
  4408. If the program also needs to read the file and wants to make sure
  4409. that the contents of the file are in a consistent state, then it can
  4410. also use a read lock. While the read lock is set, no other process can
  4411. lock that part of the file for writing.
  4412. Remember that file locks are only an _advisory_ protocol for
  4413. controlling access to a file. There is still potential for access to
  4414. the file by programs that don’t use the lock protocol.
  4415. 
  4416. File: libc.info, Node: Open File Description Locks, Next: Open File Description Locks Example, Prev: File Locks, Up: Low-Level I/O
  4417. 13.17 Open File Description Locks
  4418. =================================
  4419. In contrast to process-associated record locks (*note File Locks::),
  4420. open file description record locks are associated with an open file
  4421. description rather than a process.
  4422. Using ‘fcntl’ to apply an open file description lock on a region that
  4423. already has an existing open file description lock that was created via
  4424. the same file descriptor will never cause a lock conflict.
  4425. Open file description locks are also inherited by child processes
  4426. across ‘fork’, or ‘clone’ with ‘CLONE_FILES’ set (*note Creating a
  4427. Process::), along with the file descriptor.
  4428. It is important to distinguish between the open file _description_
  4429. (an instance of an open file, usually created by a call to ‘open’) and
  4430. an open file _descriptor_, which is a numeric value that refers to the
  4431. open file description. The locks described here are associated with the
  4432. open file _description_ and not the open file _descriptor_.
  4433. Using ‘dup’ (*note Duplicating Descriptors::) to copy a file
  4434. descriptor does not give you a new open file description, but rather
  4435. copies a reference to an existing open file description and assigns it
  4436. to a new file descriptor. Thus, open file description locks set on a
  4437. file descriptor cloned by ‘dup’ will never conflict with open file
  4438. description locks set on the original descriptor since they refer to the
  4439. same open file description. Depending on the range and type of lock
  4440. involved, the original lock may be modified by a ‘F_OFD_SETLK’ or
  4441. ‘F_OFD_SETLKW’ command in this situation however.
  4442. Open file description locks always conflict with process-associated
  4443. locks, even if acquired by the same process or on the same open file
  4444. descriptor.
  4445. Open file description locks use the same ‘struct flock’ as
  4446. process-associated locks as an argument (*note File Locks::) and the
  4447. macros for the ‘command’ values are also declared in the header file
  4448. ‘fcntl.h’. To use them, the macro ‘_GNU_SOURCE’ must be defined prior
  4449. to including any header file.
  4450. In contrast to process-associated locks, any ‘struct flock’ used as
  4451. an argument to open file description lock commands must have the ‘l_pid’
  4452. value set to 0. Also, when returning information about an open file
  4453. description lock in a ‘F_GETLK’ or ‘F_OFD_GETLK’ request, the ‘l_pid’
  4454. field in ‘struct flock’ will be set to -1 to indicate that the lock is
  4455. not associated with a process.
  4456. When the same ‘struct flock’ is reused as an argument to a
  4457. ‘F_OFD_SETLK’ or ‘F_OFD_SETLKW’ request after being used for an
  4458. ‘F_OFD_GETLK’ request, it is necessary to inspect and reset the ‘l_pid’
  4459. field to 0.
  4460. -- Macro: int F_OFD_GETLK
  4461. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4462. that it should get information about a lock. This command requires
  4463. a third argument of type ‘struct flock *’ to be passed to ‘fcntl’,
  4464. so that the form of the call is:
  4465. fcntl (FILEDES, F_OFD_GETLK, LOCKP)
  4466. If there is a lock already in place that would block the lock
  4467. described by the LOCKP argument, information about that lock is
  4468. written to ‘*LOCKP’. Existing locks are not reported if they are
  4469. compatible with making a new lock as specified. Thus, you should
  4470. specify a lock type of ‘F_WRLCK’ if you want to find out about both
  4471. read and write locks, or ‘F_RDLCK’ if you want to find out about
  4472. write locks only.
  4473. There might be more than one lock affecting the region specified by
  4474. the LOCKP argument, but ‘fcntl’ only returns information about one
  4475. of them. Which lock is returned in this situation is undefined.
  4476. The ‘l_whence’ member of the LOCKP structure are set to ‘SEEK_SET’
  4477. and the ‘l_start’ and ‘l_len’ fields are set to identify the locked
  4478. region.
  4479. If no conflicting lock exists, the only change to the LOCKP
  4480. structure is to update the ‘l_type’ field to the value ‘F_UNLCK’.
  4481. The normal return value from ‘fcntl’ with this command is either 0
  4482. on success or -1, which indicates an error. The following ‘errno’
  4483. error conditions are defined for this command:
  4484. ‘EBADF’
  4485. The FILEDES argument is invalid.
  4486. ‘EINVAL’
  4487. Either the LOCKP argument doesn’t specify valid lock
  4488. information, the operating system kernel doesn’t support open
  4489. file description locks, or the file associated with FILEDES
  4490. doesn’t support locks.
  4491. -- Macro: int F_OFD_SETLK
  4492. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4493. that it should set or clear a lock. This command requires a third
  4494. argument of type ‘struct flock *’ to be passed to ‘fcntl’, so that
  4495. the form of the call is:
  4496. fcntl (FILEDES, F_OFD_SETLK, LOCKP)
  4497. If the open file already has a lock on any part of the region, the
  4498. old lock on that part is replaced with the new lock. You can
  4499. remove a lock by specifying a lock type of ‘F_UNLCK’.
  4500. If the lock cannot be set, ‘fcntl’ returns immediately with a value
  4501. of -1. This command does not wait for other tasks to release
  4502. locks. If ‘fcntl’ succeeds, it returns 0.
  4503. The following ‘errno’ error conditions are defined for this
  4504. command:
  4505. ‘EAGAIN’
  4506. The lock cannot be set because it is blocked by an existing
  4507. lock on the file.
  4508. ‘EBADF’
  4509. Either: the FILEDES argument is invalid; you requested a read
  4510. lock but the FILEDES is not open for read access; or, you
  4511. requested a write lock but the FILEDES is not open for write
  4512. access.
  4513. ‘EINVAL’
  4514. Either the LOCKP argument doesn’t specify valid lock
  4515. information, the operating system kernel doesn’t support open
  4516. file description locks, or the file associated with FILEDES
  4517. doesn’t support locks.
  4518. ‘ENOLCK’
  4519. The system has run out of file lock resources; there are
  4520. already too many file locks in place.
  4521. Well-designed file systems never report this error, because
  4522. they have no limitation on the number of locks. However, you
  4523. must still take account of the possibility of this error, as
  4524. it could result from network access to a file system on
  4525. another machine.
  4526. -- Macro: int F_OFD_SETLKW
  4527. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4528. that it should set or clear a lock. It is just like the
  4529. ‘F_OFD_SETLK’ command, but causes the process to wait until the
  4530. request can be completed.
  4531. This command requires a third argument of type ‘struct flock *’, as
  4532. for the ‘F_OFD_SETLK’ command.
  4533. The ‘fcntl’ return values and errors are the same as for the
  4534. ‘F_OFD_SETLK’ command, but these additional ‘errno’ error
  4535. conditions are defined for this command:
  4536. ‘EINTR’
  4537. The function was interrupted by a signal while it was waiting.
  4538. *Note Interrupted Primitives::.
  4539. Open file description locks are useful in the same sorts of
  4540. situations as process-associated locks. They can also be used to
  4541. synchronize file access between threads within the same process by
  4542. having each thread perform its own ‘open’ of the file, to obtain its own
  4543. open file description.
  4544. Because open file description locks are automatically freed only upon
  4545. closing the last file descriptor that refers to the open file
  4546. description, this locking mechanism avoids the possibility that locks
  4547. are inadvertently released due to a library routine opening and closing
  4548. a file without the application being aware.
  4549. As with process-associated locks, open file description locks are
  4550. advisory.
  4551. 
  4552. File: libc.info, Node: Open File Description Locks Example, Next: Interrupt Input, Prev: Open File Description Locks, Up: Low-Level I/O
  4553. 13.18 Open File Description Locks Example
  4554. =========================================
  4555. Here is an example of using open file description locks in a threaded
  4556. program. If this program used process-associated locks, then it would
  4557. be subject to data corruption because process-associated locks are
  4558. shared by the threads inside a process, and thus cannot be used by one
  4559. thread to lock out another thread in the same process.
  4560. Proper error handling has been omitted in the following program for
  4561. brevity.
  4562. #define _GNU_SOURCE
  4563. #include <stdio.h>
  4564. #include <sys/types.h>
  4565. #include <sys/stat.h>
  4566. #include <unistd.h>
  4567. #include <fcntl.h>
  4568. #include <pthread.h>
  4569. #define FILENAME "/tmp/foo"
  4570. #define NUM_THREADS 3
  4571. #define ITERATIONS 5
  4572. void *
  4573. thread_start (void *arg)
  4574. {
  4575. int i, fd, len;
  4576. long tid = (long) arg;
  4577. char buf[256];
  4578. struct flock lck = {
  4579. .l_whence = SEEK_SET,
  4580. .l_start = 0,
  4581. .l_len = 1,
  4582. };
  4583. fd = open ("/tmp/foo", O_RDWR | O_CREAT, 0666);
  4584. for (i = 0; i < ITERATIONS; i++)
  4585. {
  4586. lck.l_type = F_WRLCK;
  4587. fcntl (fd, F_OFD_SETLKW, &lck);
  4588. len = sprintf (buf, "%d: tid=%ld fd=%d\n", i, tid, fd);
  4589. lseek (fd, 0, SEEK_END);
  4590. write (fd, buf, len);
  4591. fsync (fd);
  4592. lck.l_type = F_UNLCK;
  4593. fcntl (fd, F_OFD_SETLK, &lck);
  4594. /* sleep to ensure lock is yielded to another thread */
  4595. usleep (1);
  4596. }
  4597. pthread_exit (NULL);
  4598. }
  4599. int
  4600. main (int argc, char **argv)
  4601. {
  4602. long i;
  4603. pthread_t threads[NUM_THREADS];
  4604. truncate (FILENAME, 0);
  4605. for (i = 0; i < NUM_THREADS; i++)
  4606. pthread_create (&threads[i], NULL, thread_start, (void *) i);
  4607. pthread_exit (NULL);
  4608. return 0;
  4609. }
  4610. This example creates three threads each of which loops five times,
  4611. appending to the file. Access to the file is serialized via open file
  4612. description locks. If we compile and run the above program, we’ll end
  4613. up with /tmp/foo that has 15 lines in it.
  4614. If we, however, were to replace the ‘F_OFD_SETLK’ and ‘F_OFD_SETLKW’
  4615. commands with their process-associated lock equivalents, the locking
  4616. essentially becomes a noop since it is all done within the context of
  4617. the same process. That leads to data corruption (typically manifested
  4618. as missing lines) as some threads race in and overwrite the data written
  4619. by others.
  4620. 
  4621. File: libc.info, Node: Interrupt Input, Next: IOCTLs, Prev: Open File Description Locks Example, Up: Low-Level I/O
  4622. 13.19 Interrupt-Driven Input
  4623. ============================
  4624. If you set the ‘O_ASYNC’ status flag on a file descriptor (*note File
  4625. Status Flags::), a ‘SIGIO’ signal is sent whenever input or output
  4626. becomes possible on that file descriptor. The process or process group
  4627. to receive the signal can be selected by using the ‘F_SETOWN’ command to
  4628. the ‘fcntl’ function. If the file descriptor is a socket, this also
  4629. selects the recipient of ‘SIGURG’ signals that are delivered when
  4630. out-of-band data arrives on that socket; see *note Out-of-Band Data::.
  4631. (‘SIGURG’ is sent in any situation where ‘select’ would report the
  4632. socket as having an “exceptional condition”. *Note Waiting for I/O::.)
  4633. If the file descriptor corresponds to a terminal device, then ‘SIGIO’
  4634. signals are sent to the foreground process group of the terminal. *Note
  4635. Job Control::.
  4636. The symbols in this section are defined in the header file ‘fcntl.h’.
  4637. -- Macro: int F_GETOWN
  4638. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4639. that it should get information about the process or process group
  4640. to which ‘SIGIO’ signals are sent. (For a terminal, this is
  4641. actually the foreground process group ID, which you can get using
  4642. ‘tcgetpgrp’; see *note Terminal Access Functions::.)
  4643. The return value is interpreted as a process ID; if negative, its
  4644. absolute value is the process group ID.
  4645. The following ‘errno’ error condition is defined for this command:
  4646. ‘EBADF’
  4647. The FILEDES argument is invalid.
  4648. -- Macro: int F_SETOWN
  4649. This macro is used as the COMMAND argument to ‘fcntl’, to specify
  4650. that it should set the process or process group to which ‘SIGIO’
  4651. signals are sent. This command requires a third argument of type
  4652. ‘pid_t’ to be passed to ‘fcntl’, so that the form of the call is:
  4653. fcntl (FILEDES, F_SETOWN, PID)
  4654. The PID argument should be a process ID. You can also pass a
  4655. negative number whose absolute value is a process group ID.
  4656. The return value from ‘fcntl’ with this command is -1 in case of
  4657. error and some other value if successful. The following ‘errno’
  4658. error conditions are defined for this command:
  4659. ‘EBADF’
  4660. The FILEDES argument is invalid.
  4661. ‘ESRCH’
  4662. There is no process or process group corresponding to PID.
  4663. 
  4664. File: libc.info, Node: IOCTLs, Prev: Interrupt Input, Up: Low-Level I/O
  4665. 13.20 Generic I/O Control operations
  4666. ====================================
  4667. GNU systems can handle most input/output operations on many different
  4668. devices and objects in terms of a few file primitives - ‘read’, ‘write’
  4669. and ‘lseek’. However, most devices also have a few peculiar operations
  4670. which do not fit into this model. Such as:
  4671. • Changing the character font used on a terminal.
  4672. • Telling a magnetic tape system to rewind or fast forward. (Since
  4673. they cannot move in byte increments, ‘lseek’ is inapplicable).
  4674. • Ejecting a disk from a drive.
  4675. • Playing an audio track from a CD-ROM drive.
  4676. • Maintaining routing tables for a network.
  4677. Although some such objects such as sockets and terminals (1) have
  4678. special functions of their own, it would not be practical to create
  4679. functions for all these cases.
  4680. Instead these minor operations, known as “IOCTL”s, are assigned code
  4681. numbers and multiplexed through the ‘ioctl’ function, defined in
  4682. ‘sys/ioctl.h’. The code numbers themselves are defined in many
  4683. different headers.
  4684. -- Function: int ioctl (int FILEDES, int COMMAND, ...)
  4685. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4686. Concepts::.
  4687. The ‘ioctl’ function performs the generic I/O operation COMMAND on
  4688. FILEDES.
  4689. A third argument is usually present, either a single number or a
  4690. pointer to a structure. The meaning of this argument, the returned
  4691. value, and any error codes depends upon the command used. Often -1
  4692. is returned for a failure.
  4693. On some systems, IOCTLs used by different devices share the same
  4694. numbers. Thus, although use of an inappropriate IOCTL _usually_ only
  4695. produces an error, you should not attempt to use device-specific IOCTLs
  4696. on an unknown device.
  4697. Most IOCTLs are OS-specific and/or only used in special system
  4698. utilities, and are thus beyond the scope of this document. For an
  4699. example of the use of an IOCTL, see *note Out-of-Band Data::.
  4700. ---------- Footnotes ----------
  4701. (1) Actually, the terminal-specific functions are implemented with
  4702. IOCTLs on many platforms.
  4703. 
  4704. File: libc.info, Node: File System Interface, Next: Pipes and FIFOs, Prev: Low-Level I/O, Up: Top
  4705. 14 File System Interface
  4706. ************************
  4707. This chapter describes the GNU C Library’s functions for manipulating
  4708. files. Unlike the input and output functions (*note I/O on Streams::;
  4709. *note Low-Level I/O::), these functions are concerned with operating on
  4710. the files themselves rather than on their contents.
  4711. Among the facilities described in this chapter are functions for
  4712. examining or modifying directories, functions for renaming and deleting
  4713. files, and functions for examining and setting file attributes such as
  4714. access permissions and modification times.
  4715. * Menu:
  4716. * Working Directory:: This is used to resolve relative
  4717. file names.
  4718. * Accessing Directories:: Finding out what files a directory
  4719. contains.
  4720. * Working with Directory Trees:: Apply actions to all files or a selectable
  4721. subset of a directory hierarchy.
  4722. * Hard Links:: Adding alternate names to a file.
  4723. * Symbolic Links:: A file that “points to” a file name.
  4724. * Deleting Files:: How to delete a file, and what that means.
  4725. * Renaming Files:: Changing a file’s name.
  4726. * Creating Directories:: A system call just for creating a directory.
  4727. * File Attributes:: Attributes of individual files.
  4728. * Making Special Files:: How to create special files.
  4729. * Temporary Files:: Naming and creating temporary files.
  4730. 
  4731. File: libc.info, Node: Working Directory, Next: Accessing Directories, Up: File System Interface
  4732. 14.1 Working Directory
  4733. ======================
  4734. Each process has associated with it a directory, called its “current
  4735. working directory” or simply “working directory”, that is used in the
  4736. resolution of relative file names (*note File Name Resolution::).
  4737. When you log in and begin a new session, your working directory is
  4738. initially set to the home directory associated with your login account
  4739. in the system user database. You can find any user’s home directory
  4740. using the ‘getpwuid’ or ‘getpwnam’ functions; see *note User Database::.
  4741. Users can change the working directory using shell commands like
  4742. ‘cd’. The functions described in this section are the primitives used
  4743. by those commands and by other programs for examining and changing the
  4744. working directory.
  4745. Prototypes for these functions are declared in the header file
  4746. ‘unistd.h’.
  4747. -- Function: char * getcwd (char *BUFFER, size_t SIZE)
  4748. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  4749. POSIX Safety Concepts::.
  4750. The ‘getcwd’ function returns an absolute file name representing
  4751. the current working directory, storing it in the character array
  4752. BUFFER that you provide. The SIZE argument is how you tell the
  4753. system the allocation size of BUFFER.
  4754. The GNU C Library version of this function also permits you to
  4755. specify a null pointer for the BUFFER argument. Then ‘getcwd’
  4756. allocates a buffer automatically, as with ‘malloc’ (*note
  4757. Unconstrained Allocation::). If the SIZE is greater than zero,
  4758. then the buffer is that large; otherwise, the buffer is as large as
  4759. necessary to hold the result.
  4760. The return value is BUFFER on success and a null pointer on
  4761. failure. The following ‘errno’ error conditions are defined for
  4762. this function:
  4763. ‘EINVAL’
  4764. The SIZE argument is zero and BUFFER is not a null pointer.
  4765. ‘ERANGE’
  4766. The SIZE argument is less than the length of the working
  4767. directory name. You need to allocate a bigger array and try
  4768. again.
  4769. ‘EACCES’
  4770. Permission to read or search a component of the file name was
  4771. denied.
  4772. You could implement the behavior of GNU’s ‘getcwd (NULL, 0)’ using
  4773. only the standard behavior of ‘getcwd’:
  4774. char *
  4775. gnu_getcwd ()
  4776. {
  4777. size_t size = 100;
  4778. while (1)
  4779. {
  4780. char *buffer = (char *) xmalloc (size);
  4781. if (getcwd (buffer, size) == buffer)
  4782. return buffer;
  4783. free (buffer);
  4784. if (errno != ERANGE)
  4785. return 0;
  4786. size *= 2;
  4787. }
  4788. }
  4789. *Note Malloc Examples::, for information about ‘xmalloc’, which is not a
  4790. library function but is a customary name used in most GNU software.
  4791. -- Deprecated Function: char * getwd (char *BUFFER)
  4792. Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem fd |
  4793. *Note POSIX Safety Concepts::.
  4794. This is similar to ‘getcwd’, but has no way to specify the size of
  4795. the buffer. The GNU C Library provides ‘getwd’ only for backwards
  4796. compatibility with BSD.
  4797. The BUFFER argument should be a pointer to an array at least
  4798. ‘PATH_MAX’ bytes long (*note Limits for Files::). On GNU/Hurd
  4799. systems there is no limit to the size of a file name, so this is
  4800. not necessarily enough space to contain the directory name. That
  4801. is why this function is deprecated.
  4802. -- Function: char * get_current_dir_name (void)
  4803. Preliminary: | MT-Safe env | AS-Unsafe heap | AC-Unsafe mem fd |
  4804. *Note POSIX Safety Concepts::.
  4805. The ‘get_current_dir_name’ function is basically equivalent to
  4806. ‘getcwd (NULL, 0)’, except the value of the ‘PWD’ environment
  4807. variable is first examined, and if it does in fact correspond to
  4808. the current directory, that value is returned. This is a subtle
  4809. difference which is visible if the path described by the value in
  4810. ‘PWD’ is using one or more symbolic links, in which case the value
  4811. returned by ‘getcwd’ would resolve the symbolic links and therefore
  4812. yield a different result.
  4813. This function is a GNU extension.
  4814. -- Function: int chdir (const char *FILENAME)
  4815. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4816. Concepts::.
  4817. This function is used to set the process’s working directory to
  4818. FILENAME.
  4819. The normal, successful return value from ‘chdir’ is ‘0’. A value
  4820. of ‘-1’ is returned to indicate an error. The ‘errno’ error
  4821. conditions defined for this function are the usual file name syntax
  4822. errors (*note File Name Errors::), plus ‘ENOTDIR’ if the file
  4823. FILENAME is not a directory.
  4824. -- Function: int fchdir (int FILEDES)
  4825. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4826. Concepts::.
  4827. This function is used to set the process’s working directory to
  4828. directory associated with the file descriptor FILEDES.
  4829. The normal, successful return value from ‘fchdir’ is ‘0’. A value
  4830. of ‘-1’ is returned to indicate an error. The following ‘errno’
  4831. error conditions are defined for this function:
  4832. ‘EACCES’
  4833. Read permission is denied for the directory named by
  4834. ‘dirname’.
  4835. ‘EBADF’
  4836. The FILEDES argument is not a valid file descriptor.
  4837. ‘ENOTDIR’
  4838. The file descriptor FILEDES is not associated with a
  4839. directory.
  4840. ‘EINTR’
  4841. The function call was interrupt by a signal.
  4842. ‘EIO’
  4843. An I/O error occurred.
  4844. 
  4845. File: libc.info, Node: Accessing Directories, Next: Working with Directory Trees, Prev: Working Directory, Up: File System Interface
  4846. 14.2 Accessing Directories
  4847. ==========================
  4848. The facilities described in this section let you read the contents of a
  4849. directory file. This is useful if you want your program to list all the
  4850. files in a directory, perhaps as part of a menu.
  4851. The ‘opendir’ function opens a “directory stream” whose elements are
  4852. directory entries. Alternatively ‘fdopendir’ can be used which can have
  4853. advantages if the program needs to have more control over the way the
  4854. directory is opened for reading. This allows, for instance, to pass the
  4855. ‘O_NOATIME’ flag to ‘open’.
  4856. You use the ‘readdir’ function on the directory stream to retrieve
  4857. these entries, represented as ‘struct dirent’ objects. The name of the
  4858. file for each entry is stored in the ‘d_name’ member of this structure.
  4859. There are obvious parallels here to the stream facilities for ordinary
  4860. files, described in *note I/O on Streams::.
  4861. * Menu:
  4862. * Directory Entries:: Format of one directory entry.
  4863. * Opening a Directory:: How to open a directory stream.
  4864. * Reading/Closing Directory:: How to read directory entries from the stream.
  4865. * Simple Directory Lister:: A very simple directory listing program.
  4866. * Random Access Directory:: Rereading part of the directory
  4867. already read with the same stream.
  4868. * Scanning Directory Content:: Get entries for user selected subset of
  4869. contents in given directory.
  4870. * Simple Directory Lister Mark II:: Revised version of the program.
  4871. * Low-level Directory Access:: AS-Safe functions for directory access.
  4872. 
  4873. File: libc.info, Node: Directory Entries, Next: Opening a Directory, Up: Accessing Directories
  4874. 14.2.1 Format of a Directory Entry
  4875. ----------------------------------
  4876. This section describes what you find in a single directory entry, as you
  4877. might obtain it from a directory stream. All the symbols are declared
  4878. in the header file ‘dirent.h’.
  4879. -- Data Type: struct dirent
  4880. This is a structure type used to return information about directory
  4881. entries. It contains the following fields:
  4882. ‘char d_name[]’
  4883. This is the null-terminated file name component. This is the
  4884. only field you can count on in all POSIX systems.
  4885. ‘ino_t d_fileno’
  4886. This is the file serial number. For BSD compatibility, you
  4887. can also refer to this member as ‘d_ino’. On GNU/Linux and
  4888. GNU/Hurd systems and most POSIX systems, for most files this
  4889. the same as the ‘st_ino’ member that ‘stat’ will return for
  4890. the file. *Note File Attributes::.
  4891. ‘unsigned char d_namlen’
  4892. This is the length of the file name, not including the
  4893. terminating null character. Its type is ‘unsigned char’
  4894. because that is the integer type of the appropriate size.
  4895. This member is a BSD extension. The symbol
  4896. ‘_DIRENT_HAVE_D_NAMLEN’ is defined if this member is
  4897. available.
  4898. ‘unsigned char d_type’
  4899. This is the type of the file, possibly unknown. The following
  4900. constants are defined for its value:
  4901. ‘DT_UNKNOWN’
  4902. The type is unknown. Only some filesystems have full
  4903. support to return the type of the file, others might
  4904. always return this value.
  4905. ‘DT_REG’
  4906. A regular file.
  4907. ‘DT_DIR’
  4908. A directory.
  4909. ‘DT_FIFO’
  4910. A named pipe, or FIFO. *Note FIFO Special Files::.
  4911. ‘DT_SOCK’
  4912. A local-domain socket.
  4913. ‘DT_CHR’
  4914. A character device.
  4915. ‘DT_BLK’
  4916. A block device.
  4917. ‘DT_LNK’
  4918. A symbolic link.
  4919. This member is a BSD extension. The symbol
  4920. ‘_DIRENT_HAVE_D_TYPE’ is defined if this member is available.
  4921. On systems where it is used, it corresponds to the file type
  4922. bits in the ‘st_mode’ member of ‘struct stat’. If the value
  4923. cannot be determined the member value is DT_UNKNOWN. These two
  4924. macros convert between ‘d_type’ values and ‘st_mode’ values:
  4925. -- Function: int IFTODT (mode_t MODE)
  4926. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX
  4927. Safety Concepts::.
  4928. This returns the ‘d_type’ value corresponding to MODE.
  4929. -- Function: mode_t DTTOIF (int DTYPE)
  4930. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX
  4931. Safety Concepts::.
  4932. This returns the ‘st_mode’ value corresponding to DTYPE.
  4933. This structure may contain additional members in the future. Their
  4934. availability is always announced in the compilation environment by
  4935. a macro named ‘_DIRENT_HAVE_D_XXX’ where XXX is replaced by the
  4936. name of the new member. For instance, the member ‘d_reclen’
  4937. available on some systems is announced through the macro
  4938. ‘_DIRENT_HAVE_D_RECLEN’.
  4939. When a file has multiple names, each name has its own directory
  4940. entry. The only way you can tell that the directory entries belong
  4941. to a single file is that they have the same value for the
  4942. ‘d_fileno’ field.
  4943. File attributes such as size, modification times etc., are part of
  4944. the file itself, not of any particular directory entry. *Note File
  4945. Attributes::.
  4946. 
  4947. File: libc.info, Node: Opening a Directory, Next: Reading/Closing Directory, Prev: Directory Entries, Up: Accessing Directories
  4948. 14.2.2 Opening a Directory Stream
  4949. ---------------------------------
  4950. This section describes how to open a directory stream. All the symbols
  4951. are declared in the header file ‘dirent.h’.
  4952. -- Data Type: DIR
  4953. The ‘DIR’ data type represents a directory stream.
  4954. You shouldn’t ever allocate objects of the ‘struct dirent’ or ‘DIR’
  4955. data types, since the directory access functions do that for you.
  4956. Instead, you refer to these objects using the pointers returned by the
  4957. following functions.
  4958. Directory streams are a high-level interface. On Linux, alternative
  4959. interfaces for accessing directories using file descriptors are
  4960. available. *Note Low-level Directory Access::.
  4961. -- Function: DIR * opendir (const char *DIRNAME)
  4962. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  4963. POSIX Safety Concepts::.
  4964. The ‘opendir’ function opens and returns a directory stream for
  4965. reading the directory whose file name is DIRNAME. The stream has
  4966. type ‘DIR *’.
  4967. If unsuccessful, ‘opendir’ returns a null pointer. In addition to
  4968. the usual file name errors (*note File Name Errors::), the
  4969. following ‘errno’ error conditions are defined for this function:
  4970. ‘EACCES’
  4971. Read permission is denied for the directory named by
  4972. ‘dirname’.
  4973. ‘EMFILE’
  4974. The process has too many files open.
  4975. ‘ENFILE’
  4976. The entire system, or perhaps the file system which contains
  4977. the directory, cannot support any additional open files at the
  4978. moment. (This problem cannot happen on GNU/Hurd systems.)
  4979. ‘ENOMEM’
  4980. Not enough memory available.
  4981. The ‘DIR’ type is typically implemented using a file descriptor,
  4982. and the ‘opendir’ function in terms of the ‘open’ function. *Note
  4983. Low-Level I/O::. Directory streams and the underlying file
  4984. descriptors are closed on ‘exec’ (*note Executing a File::).
  4985. The directory which is opened for reading by ‘opendir’ is identified
  4986. by the name. In some situations this is not sufficient. Or the way
  4987. ‘opendir’ implicitly creates a file descriptor for the directory is not
  4988. the way a program might want it. In these cases an alternative
  4989. interface can be used.
  4990. -- Function: DIR * fdopendir (int FD)
  4991. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  4992. POSIX Safety Concepts::.
  4993. The ‘fdopendir’ function works just like ‘opendir’ but instead of
  4994. taking a file name and opening a file descriptor for the directory
  4995. the caller is required to provide a file descriptor. This file
  4996. descriptor is then used in subsequent uses of the returned
  4997. directory stream object.
  4998. The caller must make sure the file descriptor is associated with a
  4999. directory and it allows reading.
  5000. If the ‘fdopendir’ call returns successfully the file descriptor is
  5001. now under the control of the system. It can be used in the same
  5002. way the descriptor implicitly created by ‘opendir’ can be used but
  5003. the program must not close the descriptor.
  5004. In case the function is unsuccessful it returns a null pointer and
  5005. the file descriptor remains to be usable by the program. The
  5006. following ‘errno’ error conditions are defined for this function:
  5007. ‘EBADF’
  5008. The file descriptor is not valid.
  5009. ‘ENOTDIR’
  5010. The file descriptor is not associated with a directory.
  5011. ‘EINVAL’
  5012. The descriptor does not allow reading the directory content.
  5013. ‘ENOMEM’
  5014. Not enough memory available.
  5015. In some situations it can be desirable to get hold of the file
  5016. descriptor which is created by the ‘opendir’ call. For instance, to
  5017. switch the current working directory to the directory just read the
  5018. ‘fchdir’ function could be used. Historically the ‘DIR’ type was
  5019. exposed and programs could access the fields. This does not happen in
  5020. the GNU C Library. Instead a separate function is provided to allow
  5021. access.
  5022. -- Function: int dirfd (DIR *DIRSTREAM)
  5023. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5024. Concepts::.
  5025. The function ‘dirfd’ returns the file descriptor associated with
  5026. the directory stream DIRSTREAM. This descriptor can be used until
  5027. the directory is closed with ‘closedir’. If the directory stream
  5028. implementation is not using file descriptors the return value is
  5029. ‘-1’.
  5030. 
  5031. File: libc.info, Node: Reading/Closing Directory, Next: Simple Directory Lister, Prev: Opening a Directory, Up: Accessing Directories
  5032. 14.2.3 Reading and Closing a Directory Stream
  5033. ---------------------------------------------
  5034. This section describes how to read directory entries from a directory
  5035. stream, and how to close the stream when you are done with it. All the
  5036. symbols are declared in the header file ‘dirent.h’.
  5037. -- Function: struct dirent * readdir (DIR *DIRSTREAM)
  5038. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  5039. POSIX Safety Concepts::.
  5040. This function reads the next entry from the directory. It normally
  5041. returns a pointer to a structure containing information about the
  5042. file. This structure is associated with the DIRSTREAM handle and
  5043. can be rewritten by a subsequent call.
  5044. *Portability Note:* On some systems ‘readdir’ may not return
  5045. entries for ‘.’ and ‘..’, even though these are always valid file
  5046. names in any directory. *Note File Name Resolution::.
  5047. If there are no more entries in the directory or an error is
  5048. detected, ‘readdir’ returns a null pointer. The following ‘errno’
  5049. error conditions are defined for this function:
  5050. ‘EBADF’
  5051. The DIRSTREAM argument is not valid.
  5052. To distinguish between an end-of-directory condition or an error,
  5053. you must set ‘errno’ to zero before calling ‘readdir’. To avoid
  5054. entering an infinite loop, you should stop reading from the
  5055. directory after the first error.
  5056. *Caution:* The pointer returned by ‘readdir’ points to a buffer
  5057. within the ‘DIR’ object. The data in that buffer will be
  5058. overwritten by the next call to ‘readdir’. You must take care, for
  5059. instance, to copy the ‘d_name’ string if you need it later.
  5060. Because of this, it is not safe to share a ‘DIR’ object among
  5061. multiple threads, unless you use your own locking to ensure that no
  5062. thread calls ‘readdir’ while another thread is still using the data
  5063. from the previous call. In the GNU C Library, it is safe to call
  5064. ‘readdir’ from multiple threads as long as each thread uses its own
  5065. ‘DIR’ object. POSIX.1-2008 does not require this to be safe, but
  5066. we are not aware of any operating systems where it does not work.
  5067. ‘readdir_r’ allows you to provide your own buffer for the ‘struct
  5068. dirent’, but it is less portable than ‘readdir’, and has problems
  5069. with very long filenames (see below). We recommend you use
  5070. ‘readdir’, but do not share ‘DIR’ objects.
  5071. -- Function: int readdir_r (DIR *DIRSTREAM, struct dirent *ENTRY,
  5072. struct dirent **RESULT)
  5073. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  5074. POSIX Safety Concepts::.
  5075. This function is a version of ‘readdir’ which performs internal
  5076. locking. Like ‘readdir’ it returns the next entry from the
  5077. directory. To prevent conflicts between simultaneously running
  5078. threads the result is stored inside the ENTRY object.
  5079. *Portability Note:* ‘readdir_r’ is deprecated. It is recommended
  5080. to use ‘readdir’ instead of ‘readdir_r’ for the following reasons:
  5081. • On systems which do not define ‘NAME_MAX’, it may not be
  5082. possible to use ‘readdir_r’ safely because the caller does not
  5083. specify the length of the buffer for the directory entry.
  5084. • On some systems, ‘readdir_r’ cannot read directory entries
  5085. with very long names. If such a name is encountered, the GNU
  5086. C Library implementation of ‘readdir_r’ returns with an error
  5087. code of ‘ENAMETOOLONG’ after the final directory entry has
  5088. been read. On other systems, ‘readdir_r’ may return
  5089. successfully, but the ‘d_name’ member may not be
  5090. NUL-terminated or may be truncated.
  5091. • POSIX-1.2008 does not guarantee that ‘readdir’ is thread-safe,
  5092. even when access to the same DIRSTREAM is serialized. But in
  5093. current implementations (including the GNU C Library), it is
  5094. safe to call ‘readdir’ concurrently on different DIRSTREAMs,
  5095. so there is no need to use ‘readdir_r’ in most multi-threaded
  5096. programs. In the rare case that multiple threads need to read
  5097. from the same DIRSTREAM, it is still better to use ‘readdir’
  5098. and external synchronization.
  5099. • It is expected that future versions of POSIX will obsolete
  5100. ‘readdir_r’ and mandate the level of thread safety for
  5101. ‘readdir’ which is provided by the GNU C Library and other
  5102. implementations today.
  5103. Normally ‘readdir_r’ returns zero and sets ‘*RESULT’ to ENTRY. If
  5104. there are no more entries in the directory or an error is detected,
  5105. ‘readdir_r’ sets ‘*RESULT’ to a null pointer and returns a nonzero
  5106. error code, also stored in ‘errno’, as described for ‘readdir’.
  5107. It is also important to look at the definition of the ‘struct
  5108. dirent’ type. Simply passing a pointer to an object of this type
  5109. for the second parameter of ‘readdir_r’ might not be enough. Some
  5110. systems don’t define the ‘d_name’ element sufficiently long. In
  5111. this case the user has to provide additional space. There must be
  5112. room for at least ‘NAME_MAX + 1’ characters in the ‘d_name’ array.
  5113. Code to call ‘readdir_r’ could look like this:
  5114. union
  5115. {
  5116. struct dirent d;
  5117. char b[offsetof (struct dirent, d_name) + NAME_MAX + 1];
  5118. } u;
  5119. if (readdir_r (dir, &u.d, &res) == 0)
  5120. ...
  5121. To support large filesystems on 32-bit machines there are LFS
  5122. variants of the last two functions.
  5123. -- Function: struct dirent64 * readdir64 (DIR *DIRSTREAM)
  5124. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  5125. POSIX Safety Concepts::.
  5126. The ‘readdir64’ function is just like the ‘readdir’ function except
  5127. that it returns a pointer to a record of type ‘struct dirent64’.
  5128. Some of the members of this data type (notably ‘d_ino’) might have
  5129. a different size to allow large filesystems.
  5130. In all other aspects this function is equivalent to ‘readdir’.
  5131. -- Function: int readdir64_r (DIR *DIRSTREAM, struct dirent64 *ENTRY,
  5132. struct dirent64 **RESULT)
  5133. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  5134. POSIX Safety Concepts::.
  5135. The deprecated ‘readdir64_r’ function is equivalent to the
  5136. ‘readdir_r’ function except that it takes parameters of base type
  5137. ‘struct dirent64’ instead of ‘struct dirent’ in the second and
  5138. third position. The same precautions mentioned in the
  5139. documentation of ‘readdir_r’ also apply here.
  5140. -- Function: int closedir (DIR *DIRSTREAM)
  5141. Preliminary: | MT-Safe | AS-Unsafe heap lock/hurd | AC-Unsafe mem
  5142. fd lock/hurd | *Note POSIX Safety Concepts::.
  5143. This function closes the directory stream DIRSTREAM. It returns
  5144. ‘0’ on success and ‘-1’ on failure.
  5145. The following ‘errno’ error conditions are defined for this
  5146. function:
  5147. ‘EBADF’
  5148. The DIRSTREAM argument is not valid.
  5149. 
  5150. File: libc.info, Node: Simple Directory Lister, Next: Random Access Directory, Prev: Reading/Closing Directory, Up: Accessing Directories
  5151. 14.2.4 Simple Program to List a Directory
  5152. -----------------------------------------
  5153. Here’s a simple program that prints the names of the files in the
  5154. current working directory:
  5155. #include <stdio.h>
  5156. #include <sys/types.h>
  5157. #include <dirent.h>
  5158. int
  5159. main (void)
  5160. {
  5161. DIR *dp;
  5162. struct dirent *ep;
  5163. dp = opendir ("./");
  5164. if (dp != NULL)
  5165. {
  5166. while (ep = readdir (dp))
  5167. puts (ep->d_name);
  5168. (void) closedir (dp);
  5169. }
  5170. else
  5171. perror ("Couldn't open the directory");
  5172. return 0;
  5173. }
  5174. The order in which files appear in a directory tends to be fairly
  5175. random. A more useful program would sort the entries (perhaps by
  5176. alphabetizing them) before printing them; see *note Scanning Directory
  5177. Content::, and *note Array Sort Function::.
  5178. 
  5179. File: libc.info, Node: Random Access Directory, Next: Scanning Directory Content, Prev: Simple Directory Lister, Up: Accessing Directories
  5180. 14.2.5 Random Access in a Directory Stream
  5181. ------------------------------------------
  5182. This section describes how to reread parts of a directory that you have
  5183. already read from an open directory stream. All the symbols are
  5184. declared in the header file ‘dirent.h’.
  5185. -- Function: void rewinddir (DIR *DIRSTREAM)
  5186. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  5187. POSIX Safety Concepts::.
  5188. The ‘rewinddir’ function is used to reinitialize the directory
  5189. stream DIRSTREAM, so that if you call ‘readdir’ it returns
  5190. information about the first entry in the directory again. This
  5191. function also notices if files have been added or removed to the
  5192. directory since it was opened with ‘opendir’. (Entries for these
  5193. files might or might not be returned by ‘readdir’ if they were
  5194. added or removed since you last called ‘opendir’ or ‘rewinddir’.)
  5195. -- Function: long int telldir (DIR *DIRSTREAM)
  5196. Preliminary: | MT-Safe | AS-Unsafe heap/bsd lock/bsd | AC-Unsafe
  5197. mem/bsd lock/bsd | *Note POSIX Safety Concepts::.
  5198. The ‘telldir’ function returns the file position of the directory
  5199. stream DIRSTREAM. You can use this value with ‘seekdir’ to restore
  5200. the directory stream to that position.
  5201. -- Function: void seekdir (DIR *DIRSTREAM, long int POS)
  5202. Preliminary: | MT-Safe | AS-Unsafe heap/bsd lock/bsd | AC-Unsafe
  5203. mem/bsd lock/bsd | *Note POSIX Safety Concepts::.
  5204. The ‘seekdir’ function sets the file position of the directory
  5205. stream DIRSTREAM to POS. The value POS must be the result of a
  5206. previous call to ‘telldir’ on this particular stream; closing and
  5207. reopening the directory can invalidate values returned by
  5208. ‘telldir’.
  5209. 
  5210. File: libc.info, Node: Scanning Directory Content, Next: Simple Directory Lister Mark II, Prev: Random Access Directory, Up: Accessing Directories
  5211. 14.2.6 Scanning the Content of a Directory
  5212. ------------------------------------------
  5213. A higher-level interface to the directory handling functions is the
  5214. ‘scandir’ function. With its help one can select a subset of the
  5215. entries in a directory, possibly sort them and get a list of names as
  5216. the result.
  5217. -- Function: int scandir (const char *DIR, struct dirent ***NAMELIST,
  5218. int (*SELECTOR) (const struct dirent *), int (*CMP) (const
  5219. struct dirent **, const struct dirent **))
  5220. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5221. POSIX Safety Concepts::.
  5222. The ‘scandir’ function scans the contents of the directory selected
  5223. by DIR. The result in *NAMELIST is an array of pointers to
  5224. structures of type ‘struct dirent’ which describe all selected
  5225. directory entries and which is allocated using ‘malloc’. Instead
  5226. of always getting all directory entries returned, the user supplied
  5227. function SELECTOR can be used to decide which entries are in the
  5228. result. Only the entries for which SELECTOR returns a non-zero
  5229. value are selected.
  5230. Finally the entries in *NAMELIST are sorted using the user-supplied
  5231. function CMP. The arguments passed to the CMP function are of type
  5232. ‘struct dirent **’, therefore one cannot directly use the ‘strcmp’
  5233. or ‘strcoll’ functions; instead see the functions ‘alphasort’ and
  5234. ‘versionsort’ below.
  5235. The return value of the function is the number of entries placed in
  5236. *NAMELIST. If it is ‘-1’ an error occurred (either the directory
  5237. could not be opened for reading or the malloc call failed) and the
  5238. global variable ‘errno’ contains more information on the error.
  5239. As described above, the fourth argument to the ‘scandir’ function
  5240. must be a pointer to a sorting function. For the convenience of the
  5241. programmer the GNU C Library contains implementations of functions which
  5242. are very helpful for this purpose.
  5243. -- Function: int alphasort (const struct dirent **A, const struct
  5244. dirent **B)
  5245. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  5246. *Note POSIX Safety Concepts::.
  5247. The ‘alphasort’ function behaves like the ‘strcoll’ function (*note
  5248. String/Array Comparison::). The difference is that the arguments
  5249. are not string pointers but instead they are of type ‘struct dirent
  5250. **’.
  5251. The return value of ‘alphasort’ is less than, equal to, or greater
  5252. than zero depending on the order of the two entries A and B.
  5253. -- Function: int versionsort (const struct dirent **A, const struct
  5254. dirent **B)
  5255. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5256. Safety Concepts::.
  5257. The ‘versionsort’ function is like ‘alphasort’ except that it uses
  5258. the ‘strverscmp’ function internally.
  5259. If the filesystem supports large files we cannot use the ‘scandir’
  5260. anymore since the ‘dirent’ structure might not able to contain all the
  5261. information. The LFS provides the new type ‘struct dirent64’. To use
  5262. this we need a new function.
  5263. -- Function: int scandir64 (const char *DIR, struct dirent64
  5264. ***NAMELIST, int (*SELECTOR) (const struct dirent64 *), int
  5265. (*CMP) (const struct dirent64 **, const struct dirent64 **))
  5266. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5267. POSIX Safety Concepts::.
  5268. The ‘scandir64’ function works like the ‘scandir’ function except
  5269. that the directory entries it returns are described by elements of
  5270. type ‘struct dirent64’. The function pointed to by SELECTOR is
  5271. again used to select the desired entries, except that SELECTOR now
  5272. must point to a function which takes a ‘struct dirent64 *’
  5273. parameter.
  5274. Similarly the CMP function should expect its two arguments to be of
  5275. type ‘struct dirent64 **’.
  5276. As CMP is now a function of a different type, the functions
  5277. ‘alphasort’ and ‘versionsort’ cannot be supplied for that argument.
  5278. Instead we provide the two replacement functions below.
  5279. -- Function: int alphasort64 (const struct dirent64 **A, const struct
  5280. dirent **B)
  5281. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  5282. *Note POSIX Safety Concepts::.
  5283. The ‘alphasort64’ function behaves like the ‘strcoll’ function
  5284. (*note String/Array Comparison::). The difference is that the
  5285. arguments are not string pointers but instead they are of type
  5286. ‘struct dirent64 **’.
  5287. Return value of ‘alphasort64’ is less than, equal to, or greater
  5288. than zero depending on the order of the two entries A and B.
  5289. -- Function: int versionsort64 (const struct dirent64 **A, const struct
  5290. dirent64 **B)
  5291. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5292. Safety Concepts::.
  5293. The ‘versionsort64’ function is like ‘alphasort64’, excepted that
  5294. it uses the ‘strverscmp’ function internally.
  5295. It is important not to mix the use of ‘scandir’ and the 64-bit
  5296. comparison functions or vice versa. There are systems on which this
  5297. works but on others it will fail miserably.
  5298. 
  5299. File: libc.info, Node: Simple Directory Lister Mark II, Next: Low-level Directory Access, Prev: Scanning Directory Content, Up: Accessing Directories
  5300. 14.2.7 Simple Program to List a Directory, Mark II
  5301. --------------------------------------------------
  5302. Here is a revised version of the directory lister found above (*note
  5303. Simple Directory Lister::). Using the ‘scandir’ function we can avoid
  5304. the functions which work directly with the directory contents. After
  5305. the call the returned entries are available for direct use.
  5306. #include <stdio.h>
  5307. #include <dirent.h>
  5308. static int
  5309. one (const struct dirent *unused)
  5310. {
  5311. return 1;
  5312. }
  5313. int
  5314. main (void)
  5315. {
  5316. struct dirent **eps;
  5317. int n;
  5318. n = scandir ("./", &eps, one, alphasort);
  5319. if (n >= 0)
  5320. {
  5321. int cnt;
  5322. for (cnt = 0; cnt < n; ++cnt)
  5323. puts (eps[cnt]->d_name);
  5324. }
  5325. else
  5326. perror ("Couldn't open the directory");
  5327. return 0;
  5328. }
  5329. Note the simple selector function in this example. Since we want to
  5330. see all directory entries we always return ‘1’.
  5331. 
  5332. File: libc.info, Node: Low-level Directory Access, Prev: Simple Directory Lister Mark II, Up: Accessing Directories
  5333. 14.2.8 Low-level Directory Access
  5334. ---------------------------------
  5335. The stream-based directory functions are not AS-Safe and cannot be used
  5336. after ‘vfork’. *Note POSIX Safety Concepts::. The functions below
  5337. provide an alternative that can be used in these contexts.
  5338. Directory data is obtained from a file descriptor, as created by the
  5339. ‘open’ function, with or without the ‘O_DIRECTORY’ flag. *Note Opening
  5340. and Closing Files::.
  5341. -- Function: ssize_t getdents64 (int FD, void *BUFFER, size_t LENGTH)
  5342. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5343. Concepts::.
  5344. The ‘getdents64’ function reads at most LENGTH bytes of directory
  5345. entry data from the file descriptor FD and stores it into the byte
  5346. array starting at BUFFER.
  5347. On success, the function returns the number of bytes written to the
  5348. buffer. This number is zero if FD is already at the end of the
  5349. directory stream. On error, the function returns ‘-1’ and sets
  5350. ‘errno’ to the appropriate error code.
  5351. The data is stored as a sequence of ‘struct dirent64’ records,
  5352. which can be traversed using the ‘d_reclen’ member. The buffer
  5353. should be large enough to hold the largest possible directory
  5354. entry. Note that some file systems support file names longer than
  5355. ‘NAME_MAX’ bytes (e.g., because they support up to 255 Unicode
  5356. characters), so a buffer size of at least 1024 is recommended.
  5357. This function is specific to Linux.
  5358. 
  5359. File: libc.info, Node: Working with Directory Trees, Next: Hard Links, Prev: Accessing Directories, Up: File System Interface
  5360. 14.3 Working with Directory Trees
  5361. =================================
  5362. The functions described so far for handling the files in a directory
  5363. have allowed you to either retrieve the information bit by bit, or to
  5364. process all the files as a group (see ‘scandir’). Sometimes it is
  5365. useful to process whole hierarchies of directories and their contained
  5366. files. The X/Open specification defines two functions to do this. The
  5367. simpler form is derived from an early definition in System V systems and
  5368. therefore this function is available on SVID-derived systems. The
  5369. prototypes and required definitions can be found in the ‘ftw.h’ header.
  5370. There are four functions in this family: ‘ftw’, ‘nftw’ and their
  5371. 64-bit counterparts ‘ftw64’ and ‘nftw64’. These functions take as one
  5372. of their arguments a pointer to a callback function of the appropriate
  5373. type.
  5374. -- Data Type: __ftw_func_t
  5375. int (*) (const char *, const struct stat *, int)
  5376. The type of callback functions given to the ‘ftw’ function. The
  5377. first parameter points to the file name, the second parameter to an
  5378. object of type ‘struct stat’ which is filled in for the file named
  5379. in the first parameter.
  5380. The last parameter is a flag giving more information about the
  5381. current file. It can have the following values:
  5382. ‘FTW_F’
  5383. The item is either a normal file or a file which does not fit
  5384. into one of the following categories. This could be special
  5385. files, sockets etc.
  5386. ‘FTW_D’
  5387. The item is a directory.
  5388. ‘FTW_NS’
  5389. The ‘stat’ call failed and so the information pointed to by
  5390. the second parameter is invalid.
  5391. ‘FTW_DNR’
  5392. The item is a directory which cannot be read.
  5393. ‘FTW_SL’
  5394. The item is a symbolic link. Since symbolic links are
  5395. normally followed seeing this value in a ‘ftw’ callback
  5396. function means the referenced file does not exist. The
  5397. situation for ‘nftw’ is different.
  5398. This value is only available if the program is compiled with
  5399. ‘_XOPEN_EXTENDED’ defined before including the first header.
  5400. The original SVID systems do not have symbolic links.
  5401. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  5402. type is in fact ‘__ftw64_func_t’ since this mode changes ‘struct
  5403. stat’ to be ‘struct stat64’.
  5404. For the LFS interface and for use in the function ‘ftw64’, the header
  5405. ‘ftw.h’ defines another function type.
  5406. -- Data Type: __ftw64_func_t
  5407. int (*) (const char *, const struct stat64 *, int)
  5408. This type is used just like ‘__ftw_func_t’ for the callback
  5409. function, but this time is called from ‘ftw64’. The second
  5410. parameter to the function is a pointer to a variable of type
  5411. ‘struct stat64’ which is able to represent the larger values.
  5412. -- Data Type: __nftw_func_t
  5413. int (*) (const char *, const struct stat *, int, struct FTW *)
  5414. The first three arguments are the same as for the ‘__ftw_func_t’
  5415. type. However for the third argument some additional values are
  5416. defined to allow finer differentiation:
  5417. ‘FTW_DP’
  5418. The current item is a directory and all subdirectories have
  5419. already been visited and reported. This flag is returned
  5420. instead of ‘FTW_D’ if the ‘FTW_DEPTH’ flag is passed to ‘nftw’
  5421. (see below).
  5422. ‘FTW_SLN’
  5423. The current item is a stale symbolic link. The file it points
  5424. to does not exist.
  5425. The last parameter of the callback function is a pointer to a
  5426. structure with some extra information as described below.
  5427. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ this
  5428. type is in fact ‘__nftw64_func_t’ since this mode changes ‘struct
  5429. stat’ to be ‘struct stat64’.
  5430. For the LFS interface there is also a variant of this data type
  5431. available which has to be used with the ‘nftw64’ function.
  5432. -- Data Type: __nftw64_func_t
  5433. int (*) (const char *, const struct stat64 *, int, struct FTW *)
  5434. This type is used just like ‘__nftw_func_t’ for the callback
  5435. function, but this time is called from ‘nftw64’. The second
  5436. parameter to the function is this time a pointer to a variable of
  5437. type ‘struct stat64’ which is able to represent the larger values.
  5438. -- Data Type: struct FTW
  5439. The information contained in this structure helps in interpreting
  5440. the name parameter and gives some information about the current
  5441. state of the traversal of the directory hierarchy.
  5442. ‘int base’
  5443. The value is the offset into the string passed in the first
  5444. parameter to the callback function of the beginning of the
  5445. file name. The rest of the string is the path of the file.
  5446. This information is especially important if the ‘FTW_CHDIR’
  5447. flag was set in calling ‘nftw’ since then the current
  5448. directory is the one the current item is found in.
  5449. ‘int level’
  5450. Whilst processing, the code tracks how many directories down
  5451. it has gone to find the current file. This nesting level
  5452. starts at 0 for files in the initial directory (or is zero for
  5453. the initial file if a file was passed).
  5454. -- Function: int ftw (const char *FILENAME, __ftw_func_t FUNC, int
  5455. DESCRIPTORS)
  5456. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5457. POSIX Safety Concepts::.
  5458. The ‘ftw’ function calls the callback function given in the
  5459. parameter FUNC for every item which is found in the directory
  5460. specified by FILENAME and all directories below. The function
  5461. follows symbolic links if necessary but does not process an item
  5462. twice. If FILENAME is not a directory then it itself is the only
  5463. object returned to the callback function.
  5464. The file name passed to the callback function is constructed by
  5465. taking the FILENAME parameter and appending the names of all passed
  5466. directories and then the local file name. So the callback function
  5467. can use this parameter to access the file. ‘ftw’ also calls ‘stat’
  5468. for the file and passes that information on to the callback
  5469. function. If this ‘stat’ call is not successful the failure is
  5470. indicated by setting the third argument of the callback function to
  5471. ‘FTW_NS’. Otherwise it is set according to the description given
  5472. in the account of ‘__ftw_func_t’ above.
  5473. The callback function is expected to return 0 to indicate that no
  5474. error occurred and that processing should continue. If an error
  5475. occurred in the callback function or it wants ‘ftw’ to return
  5476. immediately, the callback function can return a value other than 0.
  5477. This is the only correct way to stop the function. The program
  5478. must not use ‘setjmp’ or similar techniques to continue from
  5479. another place. This would leave resources allocated by the ‘ftw’
  5480. function unfreed.
  5481. The DESCRIPTORS parameter to ‘ftw’ specifies how many file
  5482. descriptors it is allowed to consume. The function runs faster the
  5483. more descriptors it can use. For each level in the directory
  5484. hierarchy at most one descriptor is used, but for very deep ones
  5485. any limit on open file descriptors for the process or the system
  5486. may be exceeded. Moreover, file descriptor limits in a
  5487. multi-threaded program apply to all the threads as a group, and
  5488. therefore it is a good idea to supply a reasonable limit to the
  5489. number of open descriptors.
  5490. The return value of the ‘ftw’ function is 0 if all callback
  5491. function calls returned 0 and all actions performed by the ‘ftw’
  5492. succeeded. If a function call failed (other than calling ‘stat’ on
  5493. an item) the function returns -1. If a callback function returns a
  5494. value other than 0 this value is returned as the return value of
  5495. ‘ftw’.
  5496. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5497. 32-bit system this function is in fact ‘ftw64’, i.e., the LFS
  5498. interface transparently replaces the old interface.
  5499. -- Function: int ftw64 (const char *FILENAME, __ftw64_func_t FUNC, int
  5500. DESCRIPTORS)
  5501. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5502. POSIX Safety Concepts::.
  5503. This function is similar to ‘ftw’ but it can work on filesystems
  5504. with large files. File information is reported using a variable of
  5505. type ‘struct stat64’ which is passed by reference to the callback
  5506. function.
  5507. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5508. 32-bit system this function is available under the name ‘ftw’ and
  5509. transparently replaces the old implementation.
  5510. -- Function: int nftw (const char *FILENAME, __nftw_func_t FUNC, int
  5511. DESCRIPTORS, int FLAG)
  5512. Preliminary: | MT-Safe cwd | AS-Unsafe heap | AC-Unsafe mem fd cwd
  5513. | *Note POSIX Safety Concepts::.
  5514. The ‘nftw’ function works like the ‘ftw’ functions. They call the
  5515. callback function FUNC for all items found in the directory
  5516. FILENAME and below. At most DESCRIPTORS file descriptors are
  5517. consumed during the ‘nftw’ call.
  5518. One difference is that the callback function is of a different
  5519. type. It is of type ‘struct FTW *’ and provides the callback
  5520. function with the extra information described above.
  5521. A second difference is that ‘nftw’ takes a fourth argument, which
  5522. is 0 or a bitwise-OR combination of any of the following values.
  5523. ‘FTW_PHYS’
  5524. While traversing the directory symbolic links are not
  5525. followed. Instead symbolic links are reported using the
  5526. ‘FTW_SL’ value for the type parameter to the callback
  5527. function. If the file referenced by a symbolic link does not
  5528. exist ‘FTW_SLN’ is returned instead.
  5529. ‘FTW_MOUNT’
  5530. The callback function is only called for items which are on
  5531. the same mounted filesystem as the directory given by the
  5532. FILENAME parameter to ‘nftw’.
  5533. ‘FTW_CHDIR’
  5534. If this flag is given the current working directory is changed
  5535. to the directory of the reported object before the callback
  5536. function is called. When ‘ntfw’ finally returns the current
  5537. directory is restored to its original value.
  5538. ‘FTW_DEPTH’
  5539. If this option is specified then all subdirectories and files
  5540. within them are processed before processing the top directory
  5541. itself (depth-first processing). This also means the type
  5542. flag given to the callback function is ‘FTW_DP’ and not
  5543. ‘FTW_D’.
  5544. ‘FTW_ACTIONRETVAL’
  5545. If this option is specified then return values from callbacks
  5546. are handled differently. If the callback returns
  5547. ‘FTW_CONTINUE’, walking continues normally. ‘FTW_STOP’ means
  5548. walking stops and ‘FTW_STOP’ is returned to the caller. If
  5549. ‘FTW_SKIP_SUBTREE’ is returned by the callback with ‘FTW_D’
  5550. argument, the subtree is skipped and walking continues with
  5551. next sibling of the directory. If ‘FTW_SKIP_SIBLINGS’ is
  5552. returned by the callback, all siblings of the current entry
  5553. are skipped and walking continues in its parent. No other
  5554. return values should be returned from the callbacks if this
  5555. option is set. This option is a GNU extension.
  5556. The return value is computed in the same way as for ‘ftw’. ‘nftw’
  5557. returns 0 if no failures occurred and all callback functions
  5558. returned 0. In case of internal errors, such as memory problems,
  5559. the return value is -1 and ‘errno’ is set accordingly. If the
  5560. return value of a callback invocation was non-zero then that value
  5561. is returned.
  5562. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5563. 32-bit system this function is in fact ‘nftw64’, i.e., the LFS
  5564. interface transparently replaces the old interface.
  5565. -- Function: int nftw64 (const char *FILENAME, __nftw64_func_t FUNC,
  5566. int DESCRIPTORS, int FLAG)
  5567. Preliminary: | MT-Safe cwd | AS-Unsafe heap | AC-Unsafe mem fd cwd
  5568. | *Note POSIX Safety Concepts::.
  5569. This function is similar to ‘nftw’ but it can work on filesystems
  5570. with large files. File information is reported using a variable of
  5571. type ‘struct stat64’ which is passed by reference to the callback
  5572. function.
  5573. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5574. 32-bit system this function is available under the name ‘nftw’ and
  5575. transparently replaces the old implementation.
  5576. 
  5577. File: libc.info, Node: Hard Links, Next: Symbolic Links, Prev: Working with Directory Trees, Up: File System Interface
  5578. 14.4 Hard Links
  5579. ===============
  5580. In POSIX systems, one file can have many names at the same time. All of
  5581. the names are equally real, and no one of them is preferred to the
  5582. others.
  5583. To add a name to a file, use the ‘link’ function. (The new name is
  5584. also called a “hard link” to the file.) Creating a new link to a file
  5585. does not copy the contents of the file; it simply makes a new name by
  5586. which the file can be known, in addition to the file’s existing name or
  5587. names.
  5588. One file can have names in several directories, so the organization
  5589. of the file system is not a strict hierarchy or tree.
  5590. In most implementations, it is not possible to have hard links to the
  5591. same file in multiple file systems. ‘link’ reports an error if you try
  5592. to make a hard link to the file from another file system when this
  5593. cannot be done.
  5594. The prototype for the ‘link’ function is declared in the header file
  5595. ‘unistd.h’.
  5596. -- Function: int link (const char *OLDNAME, const char *NEWNAME)
  5597. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5598. Concepts::.
  5599. The ‘link’ function makes a new link to the existing file named by
  5600. OLDNAME, under the new name NEWNAME.
  5601. This function returns a value of ‘0’ if it is successful and ‘-1’
  5602. on failure. In addition to the usual file name errors (*note File
  5603. Name Errors::) for both OLDNAME and NEWNAME, the following ‘errno’
  5604. error conditions are defined for this function:
  5605. ‘EACCES’
  5606. You are not allowed to write to the directory in which the new
  5607. link is to be written.
  5608. ‘EEXIST’
  5609. There is already a file named NEWNAME. If you want to replace
  5610. this link with a new link, you must remove the old link
  5611. explicitly first.
  5612. ‘EMLINK’
  5613. There are already too many links to the file named by OLDNAME.
  5614. (The maximum number of links to a file is ‘LINK_MAX’; see
  5615. *note Limits for Files::.)
  5616. ‘ENOENT’
  5617. The file named by OLDNAME doesn’t exist. You can’t make a
  5618. link to a file that doesn’t exist.
  5619. ‘ENOSPC’
  5620. The directory or file system that would contain the new link
  5621. is full and cannot be extended.
  5622. ‘EPERM’
  5623. On GNU/Linux and GNU/Hurd systems and some others, you cannot
  5624. make links to directories. Many systems allow only privileged
  5625. users to do so. This error is used to report the problem.
  5626. ‘EROFS’
  5627. The directory containing the new link can’t be modified
  5628. because it’s on a read-only file system.
  5629. ‘EXDEV’
  5630. The directory specified in NEWNAME is on a different file
  5631. system than the existing file.
  5632. ‘EIO’
  5633. A hardware error occurred while trying to read or write the to
  5634. filesystem.
  5635. -- Function: int linkat (int oldfd, const char *OLDNAME, int newfd,
  5636. const char *NEWNAME, int flags)
  5637. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5638. Concepts::.
  5639. The ‘linkat’ function is analogous to the ‘link’ function, except
  5640. that it identifies its source and target using a combination of a
  5641. file descriptor (referring to a directory) and a pathname. If a
  5642. pathnames is not absolute, it is resolved relative to the
  5643. corresponding file descriptor. The special file descriptor
  5644. ‘AT_FDCWD’ denotes the current directory.
  5645. The FLAGS argument is a combination of the following flags:
  5646. ‘AT_SYMLINK_FOLLOW’
  5647. If the source path identified by OLDFD and OLDNAME is a
  5648. symbolic link, ‘linkat’ follows the symbolic link and creates
  5649. a link to its target. If the flag is not set, a link for the
  5650. symbolic link itself is created; this is not supported by all
  5651. file systems and ‘linkat’ can fail in this case.
  5652. ‘AT_EMPTY_PATH’
  5653. If this flag is specified, OLDNAME can be an empty string. In
  5654. this case, a new link to the file denoted by the descriptor
  5655. OLDFD is created, which may have been opened with ‘O_PATH’ or
  5656. ‘O_TMPFILE’. This flag is a GNU extension.
  5657. 
  5658. File: libc.info, Node: Symbolic Links, Next: Deleting Files, Prev: Hard Links, Up: File System Interface
  5659. 14.5 Symbolic Links
  5660. ===================
  5661. GNU systems support “soft links” or “symbolic links”. This is a kind of
  5662. “file” that is essentially a pointer to another file name. Unlike hard
  5663. links, symbolic links can be made to directories or across file systems
  5664. with no restrictions. You can also make a symbolic link to a name which
  5665. is not the name of any file. (Opening this link will fail until a file
  5666. by that name is created.) Likewise, if the symbolic link points to an
  5667. existing file which is later deleted, the symbolic link continues to
  5668. point to the same file name even though the name no longer names any
  5669. file.
  5670. The reason symbolic links work the way they do is that special things
  5671. happen when you try to open the link. The ‘open’ function realizes you
  5672. have specified the name of a link, reads the file name contained in the
  5673. link, and opens that file name instead. The ‘stat’ function likewise
  5674. operates on the file that the symbolic link points to, instead of on the
  5675. link itself.
  5676. By contrast, other operations such as deleting or renaming the file
  5677. operate on the link itself. The functions ‘readlink’ and ‘lstat’ also
  5678. refrain from following symbolic links, because their purpose is to
  5679. obtain information about the link. ‘link’, the function that makes a
  5680. hard link, does too. It makes a hard link to the symbolic link, which
  5681. one rarely wants.
  5682. Some systems have, for some functions operating on files, a limit on
  5683. how many symbolic links are followed when resolving a path name. The
  5684. limit if it exists is published in the ‘sys/param.h’ header file.
  5685. -- Macro: int MAXSYMLINKS
  5686. The macro ‘MAXSYMLINKS’ specifies how many symlinks some function
  5687. will follow before returning ‘ELOOP’. Not all functions behave the
  5688. same and this value is not the same as that returned for
  5689. ‘_SC_SYMLOOP’ by ‘sysconf’. In fact, the ‘sysconf’ result can
  5690. indicate that there is no fixed limit although ‘MAXSYMLINKS’ exists
  5691. and has a finite value.
  5692. Prototypes for most of the functions listed in this section are in
  5693. ‘unistd.h’.
  5694. -- Function: int symlink (const char *OLDNAME, const char *NEWNAME)
  5695. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5696. Concepts::.
  5697. The ‘symlink’ function makes a symbolic link to OLDNAME named
  5698. NEWNAME.
  5699. The normal return value from ‘symlink’ is ‘0’. A return value of
  5700. ‘-1’ indicates an error. In addition to the usual file name syntax
  5701. errors (*note File Name Errors::), the following ‘errno’ error
  5702. conditions are defined for this function:
  5703. ‘EEXIST’
  5704. There is already an existing file named NEWNAME.
  5705. ‘EROFS’
  5706. The file NEWNAME would exist on a read-only file system.
  5707. ‘ENOSPC’
  5708. The directory or file system cannot be extended to make the
  5709. new link.
  5710. ‘EIO’
  5711. A hardware error occurred while reading or writing data on the
  5712. disk.
  5713. -- Function: ssize_t readlink (const char *FILENAME, char *BUFFER,
  5714. size_t SIZE)
  5715. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5716. Concepts::.
  5717. The ‘readlink’ function gets the value of the symbolic link
  5718. FILENAME. The file name that the link points to is copied into
  5719. BUFFER. This file name string is _not_ null-terminated; ‘readlink’
  5720. normally returns the number of characters copied. The SIZE
  5721. argument specifies the maximum number of characters to copy,
  5722. usually the allocation size of BUFFER.
  5723. If the return value equals SIZE, you cannot tell whether or not
  5724. there was room to return the entire name. So make a bigger buffer
  5725. and call ‘readlink’ again. Here is an example:
  5726. char *
  5727. readlink_malloc (const char *filename)
  5728. {
  5729. int size = 100;
  5730. char *buffer = NULL;
  5731. while (1)
  5732. {
  5733. buffer = (char *) xrealloc (buffer, size);
  5734. int nchars = readlink (filename, buffer, size);
  5735. if (nchars < 0)
  5736. {
  5737. free (buffer);
  5738. return NULL;
  5739. }
  5740. if (nchars < size)
  5741. return buffer;
  5742. size *= 2;
  5743. }
  5744. }
  5745. A value of ‘-1’ is returned in case of error. In addition to the
  5746. usual file name errors (*note File Name Errors::), the following
  5747. ‘errno’ error conditions are defined for this function:
  5748. ‘EINVAL’
  5749. The named file is not a symbolic link.
  5750. ‘EIO’
  5751. A hardware error occurred while reading or writing data on the
  5752. disk.
  5753. In some situations it is desirable to resolve all the symbolic links
  5754. to get the real name of a file where no prefix names a symbolic link
  5755. which is followed and no filename in the path is ‘.’ or ‘..’. This is
  5756. for instance desirable if files have to be compared in which case
  5757. different names can refer to the same inode.
  5758. -- Function: char * canonicalize_file_name (const char *NAME)
  5759. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5760. POSIX Safety Concepts::.
  5761. The ‘canonicalize_file_name’ function returns the absolute name of
  5762. the file named by NAME which contains no ‘.’, ‘..’ components nor
  5763. any repeated path separators (‘/’) or symlinks. The result is
  5764. passed back as the return value of the function in a block of
  5765. memory allocated with ‘malloc’. If the result is not used anymore
  5766. the memory should be freed with a call to ‘free’.
  5767. If any of the path components are missing the function returns a
  5768. NULL pointer. This is also what is returned if the length of the
  5769. path reaches or exceeds ‘PATH_MAX’ characters. In any case ‘errno’
  5770. is set accordingly.
  5771. ‘ENAMETOOLONG’
  5772. The resulting path is too long. This error only occurs on
  5773. systems which have a limit on the file name length.
  5774. ‘EACCES’
  5775. At least one of the path components is not readable.
  5776. ‘ENOENT’
  5777. The input file name is empty.
  5778. ‘ENOENT’
  5779. At least one of the path components does not exist.
  5780. ‘ELOOP’
  5781. More than ‘MAXSYMLINKS’ many symlinks have been followed.
  5782. This function is a GNU extension and is declared in ‘stdlib.h’.
  5783. The Unix standard includes a similar function which differs from
  5784. ‘canonicalize_file_name’ in that the user has to provide the buffer
  5785. where the result is placed in.
  5786. -- Function: char * realpath (const char *restrict NAME, char *restrict
  5787. RESOLVED)
  5788. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem fd | *Note
  5789. POSIX Safety Concepts::.
  5790. A call to ‘realpath’ where the RESOLVED parameter is ‘NULL’ behaves
  5791. exactly like ‘canonicalize_file_name’. The function allocates a
  5792. buffer for the file name and returns a pointer to it. If RESOLVED
  5793. is not ‘NULL’ it points to a buffer into which the result is
  5794. copied. It is the callers responsibility to allocate a buffer
  5795. which is large enough. On systems which define ‘PATH_MAX’ this
  5796. means the buffer must be large enough for a pathname of this size.
  5797. For systems without limitations on the pathname length the
  5798. requirement cannot be met and programs should not call ‘realpath’
  5799. with anything but ‘NULL’ for the second parameter.
  5800. One other difference is that the buffer RESOLVED (if nonzero) will
  5801. contain the part of the path component which does not exist or is
  5802. not readable if the function returns ‘NULL’ and ‘errno’ is set to
  5803. ‘EACCES’ or ‘ENOENT’.
  5804. This function is declared in ‘stdlib.h’.
  5805. The advantage of using this function is that it is more widely
  5806. available. The drawback is that it reports failures for long paths on
  5807. systems which have no limits on the file name length.
  5808. 
  5809. File: libc.info, Node: Deleting Files, Next: Renaming Files, Prev: Symbolic Links, Up: File System Interface
  5810. 14.6 Deleting Files
  5811. ===================
  5812. You can delete a file with ‘unlink’ or ‘remove’.
  5813. Deletion actually deletes a file name. If this is the file’s only
  5814. name, then the file is deleted as well. If the file has other remaining
  5815. names (*note Hard Links::), it remains accessible under those names.
  5816. -- Function: int unlink (const char *FILENAME)
  5817. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5818. Concepts::.
  5819. The ‘unlink’ function deletes the file name FILENAME. If this is a
  5820. file’s sole name, the file itself is also deleted. (Actually, if
  5821. any process has the file open when this happens, deletion is
  5822. postponed until all processes have closed the file.)
  5823. The function ‘unlink’ is declared in the header file ‘unistd.h’.
  5824. This function returns ‘0’ on successful completion, and ‘-1’ on
  5825. error. In addition to the usual file name errors (*note File Name
  5826. Errors::), the following ‘errno’ error conditions are defined for
  5827. this function:
  5828. ‘EACCES’
  5829. Write permission is denied for the directory from which the
  5830. file is to be removed, or the directory has the sticky bit set
  5831. and you do not own the file.
  5832. ‘EBUSY’
  5833. This error indicates that the file is being used by the system
  5834. in such a way that it can’t be unlinked. For example, you
  5835. might see this error if the file name specifies the root
  5836. directory or a mount point for a file system.
  5837. ‘ENOENT’
  5838. The file name to be deleted doesn’t exist.
  5839. ‘EPERM’
  5840. On some systems ‘unlink’ cannot be used to delete the name of
  5841. a directory, or at least can only be used this way by a
  5842. privileged user. To avoid such problems, use ‘rmdir’ to
  5843. delete directories. (On GNU/Linux and GNU/Hurd systems
  5844. ‘unlink’ can never delete the name of a directory.)
  5845. ‘EROFS’
  5846. The directory containing the file name to be deleted is on a
  5847. read-only file system and can’t be modified.
  5848. -- Function: int rmdir (const char *FILENAME)
  5849. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5850. Concepts::.
  5851. The ‘rmdir’ function deletes a directory. The directory must be
  5852. empty before it can be removed; in other words, it can only contain
  5853. entries for ‘.’ and ‘..’.
  5854. In most other respects, ‘rmdir’ behaves like ‘unlink’. There are
  5855. two additional ‘errno’ error conditions defined for ‘rmdir’:
  5856. ‘ENOTEMPTY’
  5857. ‘EEXIST’
  5858. The directory to be deleted is not empty.
  5859. These two error codes are synonymous; some systems use one, and
  5860. some use the other. GNU/Linux and GNU/Hurd systems always use
  5861. ‘ENOTEMPTY’.
  5862. The prototype for this function is declared in the header file
  5863. ‘unistd.h’.
  5864. -- Function: int remove (const char *FILENAME)
  5865. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5866. Concepts::.
  5867. This is the ISO C function to remove a file. It works like
  5868. ‘unlink’ for files and like ‘rmdir’ for directories. ‘remove’ is
  5869. declared in ‘stdio.h’.
  5870. 
  5871. File: libc.info, Node: Renaming Files, Next: Creating Directories, Prev: Deleting Files, Up: File System Interface
  5872. 14.7 Renaming Files
  5873. ===================
  5874. The ‘rename’ function is used to change a file’s name.
  5875. -- Function: int rename (const char *OLDNAME, const char *NEWNAME)
  5876. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5877. Concepts::.
  5878. The ‘rename’ function renames the file OLDNAME to NEWNAME. The
  5879. file formerly accessible under the name OLDNAME is afterwards
  5880. accessible as NEWNAME instead. (If the file had any other names
  5881. aside from OLDNAME, it continues to have those names.)
  5882. The directory containing the name NEWNAME must be on the same file
  5883. system as the directory containing the name OLDNAME.
  5884. One special case for ‘rename’ is when OLDNAME and NEWNAME are two
  5885. names for the same file. The consistent way to handle this case is
  5886. to delete OLDNAME. However, in this case POSIX requires that
  5887. ‘rename’ do nothing and report success—which is inconsistent. We
  5888. don’t know what your operating system will do.
  5889. If OLDNAME is not a directory, then any existing file named NEWNAME
  5890. is removed during the renaming operation. However, if NEWNAME is
  5891. the name of a directory, ‘rename’ fails in this case.
  5892. If OLDNAME is a directory, then either NEWNAME must not exist or it
  5893. must name a directory that is empty. In the latter case, the
  5894. existing directory named NEWNAME is deleted first. The name
  5895. NEWNAME must not specify a subdirectory of the directory ‘oldname’
  5896. which is being renamed.
  5897. One useful feature of ‘rename’ is that the meaning of NEWNAME
  5898. changes “atomically” from any previously existing file by that name
  5899. to its new meaning (i.e., the file that was called OLDNAME). There
  5900. is no instant at which NEWNAME is non-existent “in between” the old
  5901. meaning and the new meaning. If there is a system crash during the
  5902. operation, it is possible for both names to still exist; but
  5903. NEWNAME will always be intact if it exists at all.
  5904. If ‘rename’ fails, it returns ‘-1’. In addition to the usual file
  5905. name errors (*note File Name Errors::), the following ‘errno’ error
  5906. conditions are defined for this function:
  5907. ‘EACCES’
  5908. One of the directories containing NEWNAME or OLDNAME refuses
  5909. write permission; or NEWNAME and OLDNAME are directories and
  5910. write permission is refused for one of them.
  5911. ‘EBUSY’
  5912. A directory named by OLDNAME or NEWNAME is being used by the
  5913. system in a way that prevents the renaming from working. This
  5914. includes directories that are mount points for filesystems,
  5915. and directories that are the current working directories of
  5916. processes.
  5917. ‘ENOTEMPTY’
  5918. ‘EEXIST’
  5919. The directory NEWNAME isn’t empty. GNU/Linux and GNU/Hurd
  5920. systems always return ‘ENOTEMPTY’ for this, but some other
  5921. systems return ‘EEXIST’.
  5922. ‘EINVAL’
  5923. OLDNAME is a directory that contains NEWNAME.
  5924. ‘EISDIR’
  5925. NEWNAME is a directory but the OLDNAME isn’t.
  5926. ‘EMLINK’
  5927. The parent directory of NEWNAME would have too many links
  5928. (entries).
  5929. ‘ENOENT’
  5930. The file OLDNAME doesn’t exist.
  5931. ‘ENOSPC’
  5932. The directory that would contain NEWNAME has no room for
  5933. another entry, and there is no space left in the file system
  5934. to expand it.
  5935. ‘EROFS’
  5936. The operation would involve writing to a directory on a
  5937. read-only file system.
  5938. ‘EXDEV’
  5939. The two file names NEWNAME and OLDNAME are on different file
  5940. systems.