libc.info-7 293 KB

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