libc.info-6 297 KB

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