home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume9 / gwyn-dir-lib < prev    next >
SHell self-extracting ARchive  |  1987-04-30  |  44.7 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 30 39 69 30 36 |Subject:| v09i06|
|00000010| 35 3a 20 20 4e 65 77 20 | 64 69 72 65 63 74 6f 72 |5: New |director|
|00000020| 79 2d 61 63 63 65 73 73 | 20 6c 69 62 72 61 72 79 |y-access| library|
|00000030| 0a 4e 65 77 73 67 72 6f | 75 70 73 3a 20 6d 6f 64 |.Newsgro|ups: mod|
|00000040| 2e 73 6f 75 72 63 65 73 | 2c 20 63 6f 6d 70 2e 73 |.sources|, comp.s|
|00000050| 6f 75 72 63 65 73 2e 75 | 6e 69 78 0a 41 70 70 72 |ources.u|nix.Appr|
|00000060| 6f 76 65 64 3a 20 72 73 | 40 6d 69 72 72 6f 72 2e |oved: rs|@mirror.|
|00000070| 54 4d 43 2e 43 4f 4d 0a | 0a 53 75 62 6d 69 74 74 |TMC.COM.|.Submitt|
|00000080| 65 64 20 62 79 3a 20 67 | 77 79 6e 40 62 72 6c 2e |ed by: g|wyn@brl.|
|00000090| 61 72 70 61 20 3c 44 6f | 75 67 20 47 77 79 6e 3e |arpa <Do|ug Gwyn>|
|000000a0| 0a 4d 6f 64 2e 73 6f 75 | 72 63 65 73 3a 20 56 6f |.Mod.sou|rces: Vo|
|000000b0| 6c 75 6d 65 20 39 2c 20 | 49 73 73 75 65 20 36 35 |lume 9, |Issue 65|
|000000c0| 0a 41 72 63 68 69 76 65 | 2d 6e 61 6d 65 3a 20 67 |.Archive|-name: g|
|000000d0| 77 79 6e 2d 64 69 72 2d | 6c 69 62 0a 0a 5b 20 20 |wyn-dir-|lib..[ |
|000000e0| 54 68 69 73 20 69 73 20 | 67 72 65 61 74 20 70 61 |This is |great pa|
|000000f0| 63 6b 61 67 65 3a 20 20 | 69 74 20 61 6c 6d 6f 73 |ckage: |it almos|
|00000100| 74 20 73 65 65 6d 73 20 | 74 68 61 74 2c 20 62 65 |t seems |that, be|
|00000110| 74 77 65 65 6e 20 44 6f | 75 67 20 61 6e 64 0a 20 |tween Do|ug and. |
|00000120| 20 20 48 65 6e 72 79 20 | 53 70 65 6e 63 65 72 2c | Henry |Spencer,|
|00000130| 20 74 68 65 20 63 6f 6d | 6d 75 6e 69 74 79 20 77 | the com|munity w|
|00000140| 69 6c 6c 20 68 61 76 65 | 20 61 20 63 6f 6d 70 6c |ill have| a compl|
|00000150| 65 74 65 20 22 66 72 65 | 65 22 20 50 4f 53 49 58 |ete "fre|e" POSIX|
|00000160| 0a 20 20 20 43 20 6c 69 | 62 72 61 72 79 2e 20 20 |. C li|brary. |
|00000170| 28 4e 6f 20 71 75 69 62 | 62 6c 65 73 20 61 62 6f |(No quib|bles abo|
|00000180| 75 74 20 6c 65 67 61 6c | 20 6d 65 61 6e 69 6e 67 |ut legal| meaning|
|00000190| 20 6f 66 20 66 72 65 65 | 2c 20 70 6c 65 61 73 65 | of free|, please|
|000001a0| 2e 29 0a 20 20 20 49 20 | 72 65 70 61 63 6b 65 64 |.). I |repacked|
|000001b0| 20 74 68 65 20 61 72 63 | 68 69 76 65 20 74 6f 20 | the arc|hive to |
|000001c0| 62 75 6c 6c 65 74 2d 70 | 72 6f 6f 66 20 61 67 61 |bullet-p|roof aga|
|000001d0| 69 6e 73 74 20 74 68 69 | 6e 67 73 20 6c 69 6b 65 |inst thi|ngs like|
|000001e0| 20 69 6e 69 74 69 61 6c | 0a 20 20 20 70 65 72 69 | initial|. peri|
|000001f0| 6f 64 73 20 69 6e 20 74 | 68 65 20 6d 61 6e 70 61 |ods in t|he manpa|
|00000200| 67 65 2e 20 20 2d 2d 72 | 24 20 5d 0a 0a 23 21 20 |ge. --r|$ ]..#! |
|00000210| 2f 62 69 6e 2f 73 68 0a | 23 20 54 68 69 73 20 69 |/bin/sh.|# This i|
|00000220| 73 20 61 20 73 68 65 6c | 6c 20 61 72 63 68 69 76 |s a shel|l archiv|
|00000230| 65 2e 20 20 52 65 6d 6f | 76 65 20 61 6e 79 74 68 |e. Remo|ve anyth|
|00000240| 69 6e 67 20 62 65 66 6f | 72 65 20 74 68 69 73 20 |ing befo|re this |
|00000250| 6c 69 6e 65 2c 0a 23 20 | 74 68 65 6e 20 75 6e 70 |line,.# |then unp|
|00000260| 61 63 6b 20 69 74 20 62 | 79 20 73 61 76 69 6e 67 |ack it b|y saving|
|00000270| 20 69 74 20 69 6e 20 61 | 20 66 69 6c 65 20 61 6e | it in a| file an|
|00000280| 64 20 74 79 70 69 6e 67 | 20 22 73 68 20 66 69 6c |d typing| "sh fil|
|00000290| 65 22 2e 0a 23 20 49 66 | 20 74 68 69 73 20 61 72 |e"..# If| this ar|
|000002a0| 63 68 69 76 65 20 69 73 | 20 63 6f 6d 70 6c 65 74 |chive is| complet|
|000002b0| 65 2c 20 79 6f 75 20 77 | 69 6c 6c 20 73 65 65 20 |e, you w|ill see |
|000002c0| 74 68 65 20 6d 65 73 73 | 61 67 65 3a 0a 23 09 09 |the mess|age:.#..|
|000002d0| 22 45 6e 64 20 6f 66 20 | 73 68 65 6c 6c 20 61 72 |"End of |shell ar|
|000002e0| 63 68 69 76 65 2e 22 0a | 23 20 43 6f 6e 74 65 6e |chive.".|# Conten|
|000002f0| 74 73 3a 20 20 49 4e 53 | 54 41 4c 4c 20 4e 4f 54 |ts: INS|TALL NOT|
|00000300| 45 53 20 63 6c 6f 73 65 | 64 69 72 2e 63 20 64 69 |ES close|dir.c di|
|00000310| 72 65 63 74 6f 72 79 2e | 33 63 20 64 69 72 65 6e |rectory.|3c diren|
|00000320| 74 2e 34 20 64 69 72 65 | 6e 74 2e 68 0a 23 20 20 |t.4 dire|nt.h.# |
|00000330| 20 67 65 74 64 65 6e 74 | 73 2e 32 20 67 65 74 64 | getdent|s.2 getd|
|00000340| 65 6e 74 73 2e 63 20 6f | 70 65 6e 64 69 72 2e 63 |ents.c o|pendir.c|
|00000350| 20 72 65 61 64 64 69 72 | 2e 63 20 72 65 77 69 6e | readdir|.c rewin|
|00000360| 64 64 69 72 2e 63 20 73 | 65 65 6b 64 69 72 2e 63 |ddir.c s|eekdir.c|
|00000370| 0a 23 20 20 20 73 79 73 | 2e 5f 64 69 72 2e 68 20 |.# sys|._dir.h |
|00000380| 73 79 73 2e 64 69 72 65 | 6e 74 2e 68 20 74 65 6c |sys.dire|nt.h tel|
|00000390| 6c 64 69 72 2e 63 20 74 | 65 73 74 64 69 72 2e 63 |ldir.c t|estdir.c|
|000003a0| 0a 50 41 54 48 3d 2f 62 | 69 6e 3a 2f 75 73 72 2f |.PATH=/b|in:/usr/|
|000003b0| 62 69 6e 3a 2f 75 73 72 | 2f 75 63 62 20 3b 20 65 |bin:/usr|/ucb ; e|
|000003c0| 78 70 6f 72 74 20 50 41 | 54 48 0a 65 63 68 6f 20 |xport PA|TH.echo |
|000003d0| 73 68 61 72 3a 20 45 78 | 74 72 61 63 74 69 6e 67 |shar: Ex|tracting|
|000003e0| 20 5c 22 49 4e 53 54 41 | 4c 4c 5c 22 20 5c 28 35 | \"INSTA|LL\" \(5|
|000003f0| 34 39 30 20 63 68 61 72 | 61 63 74 65 72 73 5c 29 |490 char|acters\)|
|00000400| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 49 4e 53 54 |.if test| -f INST|
|00000410| 41 4c 4c 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |ALL ; th|en . ec|
|00000420| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|00000430| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00000440| 73 74 69 6e 67 20 66 69 | 6c 65 20 5c 22 49 4e 53 |sting fi|le \"INS|
|00000450| 54 41 4c 4c 5c 22 0a 65 | 6c 73 65 0a 73 65 64 20 |TALL\".e|lse.sed |
|00000460| 22 73 2f 5e 58 2f 2f 22 | 20 3e 49 4e 53 54 41 4c |"s/^X//"| >INSTAL|
|00000470| 4c 20 3c 3c 27 45 4e 44 | 5f 4f 46 5f 49 4e 53 54 |L <<'END|_OF_INST|
|00000480| 41 4c 4c 27 0a 58 0a 58 | 0a 58 09 09 09 49 4e 53 |ALL'.X.X|.X...INS|
|00000490| 54 41 4c 4c 41 54 49 4f | 4e 20 49 4e 53 54 52 55 |TALLATIO|N INSTRU|
|000004a0| 43 54 49 4f 4e 53 0a 58 | 0a 58 0a 58 54 68 65 20 |CTIONS.X|.X.XThe |
|000004b0| 66 6f 6c 6c 6f 77 69 6e | 67 20 69 6e 73 74 72 75 |followin|g instru|
|000004c0| 63 74 69 6f 6e 73 20 61 | 72 65 20 66 6f 72 20 73 |ctions a|re for s|
|000004d0| 79 73 74 65 6d 73 20 72 | 65 73 65 6d 62 6c 69 6e |ystems r|esemblin|
|000004e0| 67 20 4e 69 6e 74 68 20 | 45 64 69 74 69 6f 6e 20 |g Ninth |Edition |
|000004f0| 55 4e 49 58 2c 20 77 69 | 74 68 0a 58 68 69 6e 74 |UNIX, wi|th.Xhint|
|00000500| 73 20 61 62 6f 75 74 20 | 64 65 61 6c 69 6e 67 20 |s about |dealing |
|00000510| 77 69 74 68 20 76 61 72 | 69 61 74 69 6f 6e 73 20 |with var|iations |
|00000520| 79 6f 75 20 6d 61 79 20 | 65 6e 63 6f 75 6e 74 65 |you may |encounte|
|00000530| 72 20 66 6f 72 20 79 6f | 75 72 20 73 70 65 63 69 |r for yo|ur speci|
|00000540| 66 69 63 20 73 79 73 74 | 65 6d 2e 0a 58 49 6e 73 |fic syst|em..XIns|
|00000550| 74 61 6c 6c 61 74 69 6f | 6e 20 73 68 6f 75 6c 64 |tallatio|n should|
|00000560| 20 62 65 20 64 6f 6e 65 | 20 6f 6e 6c 79 20 62 79 | be done| only by|
|00000570| 20 73 6f 6d 65 6f 6e 65 | 20 77 68 6f 20 69 73 20 | someone| who is |
|00000580| 63 6f 6d 66 6f 72 74 61 | 62 6c 65 20 77 69 74 68 |comforta|ble with|
|00000590| 20 6d 6f 64 69 66 79 69 | 6e 67 0a 58 74 68 65 20 | modifyi|ng.Xthe |
|000005a0| 73 74 61 6e 64 61 72 64 | 20 43 20 6c 69 62 72 61 |standard| C libra|
|000005b0| 72 79 20 61 6e 64 20 68 | 65 61 64 65 72 20 66 69 |ry and h|eader fi|
|000005c0| 6c 65 73 2e 0a 58 0a 58 | 49 66 20 79 6f 75 72 20 |les..X.X|If your |
|000005d0| 73 79 73 74 65 6d 20 61 | 6c 72 65 61 64 79 20 69 |system a|lready i|
|000005e0| 6e 63 6c 75 64 65 73 20 | 64 69 72 65 63 74 6f 72 |ncludes |director|
|000005f0| 79 20 61 63 63 65 73 73 | 20 72 6f 75 74 69 6e 65 |y access| routine|
|00000600| 73 2c 20 79 6f 75 20 73 | 68 6f 75 6c 64 20 72 65 |s, you s|hould re|
|00000610| 70 6c 61 63 65 0a 58 74 | 68 65 6d 20 77 69 74 68 |place.Xt|hem with|
|00000620| 20 74 68 69 73 20 70 61 | 63 6b 61 67 65 2e 20 20 | this pa|ckage. |
|00000630| 57 65 27 72 65 20 74 72 | 79 69 6e 67 20 74 6f 20 |We're tr|ying to |
|00000640| 67 65 74 20 74 68 69 73 | 20 73 74 61 6e 64 61 72 |get this| standar|
|00000650| 64 69 7a 65 64 3b 20 73 | 65 65 20 74 68 65 0a 58 |dized; s|ee the.X|
|00000660| 64 69 73 63 75 73 73 69 | 6f 6e 20 69 6e 20 74 68 |discussi|on in th|
|00000670| 65 20 4e 4f 54 45 53 20 | 66 69 6c 65 2e 0a 58 0a |e NOTES |file..X.|
|00000680| 58 49 20 68 61 76 65 20 | 74 72 69 65 64 20 74 6f |XI have |tried to|
|00000690| 20 6d 61 6b 65 20 74 68 | 65 20 73 6f 75 72 63 65 | make th|e source|
|000006a0| 20 63 6f 64 65 20 61 73 | 20 67 65 6e 65 72 69 63 | code as| generic|
|000006b0| 20 61 73 20 70 6f 73 73 | 69 62 6c 65 2c 20 62 75 | as poss|ible, bu|
|000006c0| 74 20 69 66 20 79 6f 75 | 72 20 73 79 73 74 65 6d |t if you|r system|
|000006d0| 0a 58 70 72 65 64 61 74 | 65 73 20 53 65 76 65 6e |.Xpredat|es Seven|
|000006e0| 74 68 20 45 64 69 74 69 | 6f 6e 20 55 4e 49 58 20 |th Editi|on UNIX |
|000006f0| 79 6f 75 20 77 69 6c 6c | 20 68 61 76 65 20 70 72 |you will| have pr|
|00000700| 6f 62 6c 65 6d 73 2e 0a | 58 0a 58 44 49 53 43 4c |oblems..|X.XDISCL|
|00000710| 41 49 4d 45 52 3a 20 20 | 41 6c 74 68 6f 75 67 68 |AIMER: |Although|
|00000720| 20 49 20 62 65 6c 69 65 | 76 65 20 74 68 65 20 63 | I belie|ve the c|
|00000730| 6f 64 65 20 61 6e 64 20 | 70 72 6f 63 65 64 75 72 |ode and |procedur|
|00000740| 65 73 20 64 65 73 63 72 | 69 62 65 64 20 68 65 72 |es descr|ibed her|
|00000750| 65 20 74 6f 20 62 65 0a | 58 63 6f 72 72 65 63 74 |e to be.|Xcorrect|
|00000760| 2c 20 49 20 6d 61 6b 65 | 20 6e 6f 20 77 61 72 72 |, I make| no warr|
|00000770| 61 6e 74 79 20 6f 66 20 | 61 6e 79 20 6b 69 6e 64 |anty of |any kind|
|00000780| 2c 20 61 6e 64 20 79 6f | 75 20 61 72 65 20 61 64 |, and yo|u are ad|
|00000790| 76 69 73 65 64 20 74 6f | 20 70 65 72 66 6f 72 6d |vised to| perform|
|000007a0| 20 79 6f 75 72 0a 58 6f | 77 6e 20 63 61 72 65 66 | your.Xo|wn caref|
|000007b0| 75 6c 20 74 65 73 74 69 | 6e 67 20 62 65 66 6f 72 |ul testi|ng befor|
|000007c0| 65 20 6d 61 6b 69 6e 67 | 20 61 6e 79 20 73 75 62 |e making| any sub|
|000007d0| 73 74 61 6e 74 69 61 6c | 20 63 68 61 6e 67 65 20 |stantial| change |
|000007e0| 6c 69 6b 65 20 74 68 69 | 73 20 74 6f 20 79 6f 75 |like thi|s to you|
|000007f0| 72 0a 58 70 72 6f 67 72 | 61 6d 6d 69 6e 67 20 65 |r.Xprogr|amming e|
|00000800| 6e 76 69 72 6f 6e 6d 65 | 6e 74 2e 0a 58 0a 58 0a |nvironme|nt..X.X.|
|00000810| 58 30 29 20 20 46 6f 72 | 20 61 6e 74 69 71 75 65 |X0) For| antique|
|00000820| 20 73 79 73 74 65 6d 73 | 20 74 68 61 74 20 64 6f | systems| that do|
|00000830| 20 6e 6f 74 20 73 75 70 | 70 6f 72 74 20 43 27 73 | not sup|port C's|
|00000840| 20 22 76 6f 69 64 22 20 | 64 61 74 61 20 74 79 70 | "void" |data typ|
|00000850| 65 2c 20 65 64 69 74 20 | 74 68 65 20 66 69 6c 65 |e, edit |the file|
|00000860| 0a 58 20 20 20 20 73 79 | 73 2e 64 69 72 65 6e 74 |.X sy|s.dirent|
|00000870| 2e 68 20 74 6f 20 61 64 | 64 20 74 68 65 20 66 6f |.h to ad|d the fo|
|00000880| 6c 6c 6f 77 69 6e 67 3a | 0a 58 0a 58 09 74 79 70 |llowing:|.X.X.typ|
|00000890| 65 64 65 66 20 69 6e 74 | 09 09 76 6f 69 64 3b 09 |edef int|..void;.|
|000008a0| 2f 2a 20 67 6f 6f 64 20 | 65 6e 6f 75 67 68 20 66 |/* good |enough f|
|000008b0| 6f 72 20 67 6f 76 74 20 | 77 6f 72 6b 20 2a 2f 0a |or govt |work */.|
|000008c0| 58 0a 58 20 20 20 20 49 | 66 20 66 6f 72 20 73 6f |X.X I|f for so|
|000008d0| 6d 65 20 72 65 61 73 6f | 6e 20 79 6f 75 72 20 3c |me reaso|n your <|
|000008e0| 73 79 73 2f 74 79 70 65 | 73 2e 68 3e 20 64 6f 65 |sys/type|s.h> doe|
|000008f0| 73 6e 27 74 20 64 65 66 | 69 6e 65 20 74 68 65 6d |sn't def|ine them|
|00000900| 2c 20 61 64 64 20 74 68 | 65 0a 58 20 20 20 20 66 |, add th|e.X f|
|00000910| 6f 6c 6c 6f 77 69 6e 67 | 20 74 6f 20 73 79 73 2e |ollowing| to sys.|
|00000920| 64 69 72 65 6e 74 2e 68 | 3a 0a 58 0a 58 09 74 79 |dirent.h|:.X.X.ty|
|00000930| 70 65 64 65 66 20 75 6e | 73 69 67 6e 65 64 20 73 |pedef un|signed s|
|00000940| 68 6f 72 74 09 69 6e 6f | 5f 74 3b 09 2f 2a 20 28 |hort.ino|_t;./* (|
|00000950| 61 73 73 75 6d 69 6e 67 | 20 6f 72 69 67 69 6e 61 |assuming| origina|
|00000960| 6c 20 55 46 53 29 20 2a | 2f 0a 58 09 74 79 70 65 |l UFS) *|/.X.type|
|00000970| 64 65 66 20 6c 6f 6e 67 | 09 09 6f 66 66 5f 74 3b |def long|..off_t;|
|00000980| 09 2f 2a 20 6c 6f 6e 67 | 20 69 73 20 66 6f 72 63 |./* long| is forc|
|00000990| 65 64 20 62 79 20 6c 73 | 65 65 6b 28 29 20 2a 2f |ed by ls|eek() */|
|000009a0| 0a 58 0a 58 20 20 20 20 | 4e 6f 6e 65 20 6f 66 20 |.X.X |None of |
|000009b0| 74 68 69 73 20 73 68 6f | 75 6c 64 20 62 65 20 6e |this sho|uld be n|
|000009c0| 65 63 65 73 73 61 72 79 | 20 66 6f 72 20 61 6e 79 |ecessary| for any|
|000009d0| 20 6d 6f 64 65 72 6e 20 | 55 4e 49 58 20 73 79 73 | modern |UNIX sys|
|000009e0| 74 65 6d 2e 0a 58 0a 58 | 31 29 20 20 43 6f 70 79 |tem..X.X|1) Copy|
|000009f0| 20 74 68 65 20 66 69 6c | 65 20 64 69 72 65 6e 74 | the fil|e dirent|
|00000a00| 2e 68 20 74 6f 20 2f 75 | 73 72 2f 69 6e 63 6c 75 |.h to /u|sr/inclu|
|00000a10| 64 65 2f 64 69 72 65 6e | 74 2e 68 20 61 6e 64 20 |de/diren|t.h and |
|00000a20| 63 6f 70 79 20 74 68 65 | 20 66 69 6c 65 0a 58 20 |copy the| file.X |
|00000a30| 20 20 20 73 79 73 2e 64 | 69 72 65 6e 74 2e 68 20 | sys.d|irent.h |
|00000a40| 74 6f 20 2f 75 73 72 2f | 69 6e 63 6c 75 64 65 2f |to /usr/|include/|
|00000a50| 73 79 73 2f 64 69 72 65 | 6e 74 2e 68 2e 20 20 28 |sys/dire|nt.h. (|
|00000a60| 54 68 65 20 66 69 6c 65 | 20 73 79 73 2e 5f 64 69 |The file| sys._di|
|00000a70| 72 2e 68 20 69 73 20 61 | 6c 73 6f 0a 58 20 20 20 |r.h is a|lso.X |
|00000a80| 20 70 72 6f 76 69 64 65 | 64 20 66 6f 72 20 74 68 | provide|d for th|
|00000a90| 65 20 42 52 4c 20 55 4e | 49 58 20 53 79 73 74 65 |e BRL UN|IX Syste|
|00000aa0| 6d 20 56 20 65 6d 75 6c | 61 74 69 6f 6e 20 66 6f |m V emul|ation fo|
|00000ab0| 72 20 34 2e 6e 42 53 44 | 2e 20 20 54 68 61 74 20 |r 4.nBSD|. That |
|00000ac0| 65 6e 76 69 72 6f 6e 6d | 65 6e 74 0a 58 20 20 20 |environm|ent.X |
|00000ad0| 20 75 73 65 73 20 64 69 | 66 66 65 72 65 6e 74 20 | uses di|fferent |
|00000ae0| 64 69 72 65 63 74 6f 72 | 79 20 6e 61 6d 65 73 20 |director|y names |
|00000af0| 66 6f 72 20 65 76 65 72 | 79 74 68 69 6e 67 2e 29 |for ever|ything.)|
|00000b00| 0a 58 0a 58 32 29 20 20 | 43 6f 70 79 20 74 68 65 |.X.X2) |Copy the|
|00000b10| 20 66 69 6c 65 20 64 69 | 72 65 63 74 6f 72 79 2e | file di|rectory.|
|00000b20| 33 63 20 74 6f 20 2f 75 | 73 72 2f 6d 61 6e 2f 6d |3c to /u|sr/man/m|
|00000b30| 61 6e 33 2f 64 69 72 65 | 63 74 6f 72 79 2e 33 20 |an3/dire|ctory.3 |
|00000b40| 61 6e 64 20 63 6f 70 79 | 20 74 68 65 20 66 69 6c |and copy| the fil|
|00000b50| 65 0a 58 20 20 20 20 64 | 69 72 65 6e 74 2e 34 20 |e.X d|irent.4 |
|00000b60| 74 6f 20 2f 75 73 72 2f | 6d 61 6e 2f 6d 61 6e 35 |to /usr/|man/man5|
|00000b70| 2f 64 69 72 65 6e 74 2e | 35 3b 20 65 64 69 74 20 |/dirent.|5; edit |
|00000b80| 74 68 65 20 6e 65 77 20 | 66 69 6c 65 0a 58 20 20 |the new |file.X |
|00000b90| 20 20 2f 75 73 72 2f 6d | 61 6e 2f 6d 61 6e 33 2f | /usr/m|an/man3/|
|00000ba0| 64 69 72 65 63 74 6f 72 | 79 2e 33 20 74 6f 20 63 |director|y.3 to c|
|00000bb0| 68 61 6e 67 65 20 74 68 | 65 20 22 53 45 45 20 41 |hange th|e "SEE A|
|00000bc0| 4c 53 4f 22 20 72 65 66 | 65 72 65 6e 63 65 20 66 |LSO" ref|erence f|
|00000bd0| 72 6f 6d 20 64 69 72 65 | 6e 74 28 34 29 0a 58 20 |rom dire|nt(4).X |
|00000be0| 20 20 20 74 6f 20 64 69 | 72 65 6e 74 28 35 29 20 | to di|rent(5) |
|00000bf0| 61 6e 64 20 74 6f 20 63 | 68 61 6e 67 65 20 74 68 |and to c|hange th|
|00000c00| 65 20 33 43 20 6f 6e 20 | 74 68 65 20 66 69 72 73 |e 3C on |the firs|
|00000c10| 74 20 6c 69 6e 65 20 74 | 6f 20 33 3b 20 65 64 69 |t line t|o 3; edi|
|00000c20| 74 20 74 68 65 20 6e 65 | 77 20 66 69 6c 65 0a 58 |t the ne|w file.X|
|00000c30| 20 20 20 20 2f 75 73 72 | 2f 6d 61 6e 2f 6d 61 6e | /usr|/man/man|
|00000c40| 35 2f 64 69 72 65 6e 74 | 2e 35 20 74 6f 20 63 68 |5/dirent|.5 to ch|
|00000c50| 61 6e 67 65 20 74 68 65 | 20 34 20 6f 6e 20 74 68 |ange the| 4 on th|
|00000c60| 65 20 66 69 72 73 74 20 | 6c 69 6e 65 20 74 6f 20 |e first |line to |
|00000c70| 35 3b 20 74 68 65 6e 20 | 70 72 69 6e 74 0a 58 20 |5; then |print.X |
|00000c80| 20 20 20 74 68 65 20 6d | 61 6e 75 61 6c 20 70 61 | the m|anual pa|
|00000c90| 67 65 73 20 76 69 61 20 | 74 68 65 20 63 6f 6d 6d |ges via |the comm|
|00000ca0| 61 6e 64 0a 58 0a 58 09 | 6d 61 6e 20 64 69 72 65 |and.X.X.|man dire|
|00000cb0| 63 74 6f 72 79 20 64 69 | 72 65 6e 74 0a 58 0a 58 |ctory di|rent.X.X|
|00000cc0| 20 20 20 20 74 6f 20 73 | 65 65 20 77 68 61 74 20 | to s|ee what |
|00000cd0| 74 68 65 20 6e 65 77 20 | 72 6f 75 74 69 6e 65 73 |the new |routines|
|00000ce0| 20 61 72 65 20 6c 69 6b | 65 2e 20 20 28 49 66 20 | are lik|e. (If |
|00000cf0| 79 6f 75 20 68 61 76 65 | 20 61 20 22 63 61 74 6d |you have| a "catm|
|00000d00| 61 6e 22 20 73 74 79 6c | 65 20 6f 66 0a 58 20 20 |an" styl|e of.X |
|00000d10| 20 20 6f 6e 2d 6c 69 6e | 65 20 6d 61 6e 75 61 6c | on-lin|e manual|
|00000d20| 2c 20 61 64 61 70 74 20 | 74 68 65 73 65 20 69 6e |, adapt |these in|
|00000d30| 73 74 72 75 63 74 69 6f | 6e 73 20 61 63 63 6f 72 |structio|ns accor|
|00000d40| 64 69 6e 67 6c 79 2e 20 | 20 4d 61 6e 75 61 6c 20 |dingly. | Manual |
|00000d50| 65 6e 74 72 69 65 73 20 | 61 72 65 0a 58 20 20 20 |entries |are.X |
|00000d60| 20 6b 65 70 74 20 69 6e | 20 64 69 72 65 63 74 6f | kept in| directo|
|00000d70| 72 69 65 73 20 77 69 74 | 68 20 6f 74 68 65 72 20 |ries wit|h other |
|00000d80| 6e 61 6d 65 73 20 6f 6e | 20 73 6f 6d 65 20 73 79 |names on| some sy|
|00000d90| 73 74 65 6d 73 20 73 75 | 63 68 20 61 73 20 55 4e |stems su|ch as UN|
|00000da0| 49 58 20 53 79 73 74 65 | 6d 20 56 2e 0a 58 20 20 |IX Syste|m V..X |
|00000db0| 20 20 4f 6e 20 73 79 73 | 74 65 6d 73 20 74 68 61 | On sys|tems tha|
|00000dc0| 74 20 61 6c 72 65 61 64 | 79 20 68 61 64 20 61 20 |t alread|y had a |
|00000dd0| 64 69 72 65 63 74 6f 72 | 79 20 6c 69 62 72 61 72 |director|y librar|
|00000de0| 79 20 64 6f 63 75 6d 65 | 6e 74 65 64 20 69 6e 20 |y docume|nted in |
|00000df0| 73 6f 6d 65 20 6f 74 68 | 65 72 0a 58 20 20 20 20 |some oth|er.X |
|00000e00| 6d 61 6e 75 61 6c 20 65 | 6e 74 72 79 2c 20 72 65 |manual e|ntry, re|
|00000e10| 6d 6f 76 65 20 74 68 65 | 20 73 75 70 65 72 73 65 |move the| superse|
|00000e20| 64 65 64 20 6d 61 6e 75 | 61 6c 20 65 6e 74 72 79 |ded manu|al entry|
|00000e30| 3b 20 69 66 20 74 68 65 | 20 64 65 73 63 72 69 70 |; if the| descrip|
|00000e40| 74 69 6f 6e 20 6f 66 20 | 74 68 65 0a 58 20 20 20 |tion of |the.X |
|00000e50| 20 6e 61 74 69 76 65 20 | 66 69 6c 65 73 79 73 74 | native |filesyst|
|00000e60| 65 6d 20 64 69 72 65 63 | 74 6f 72 79 20 66 6f 72 |em direc|tory for|
|00000e70| 6d 61 74 20 66 6f 75 6e | 64 20 62 79 20 22 6d 61 |mat foun|d by "ma|
|00000e80| 6e 20 64 69 72 22 20 72 | 65 66 65 72 73 20 74 6f |n dir" r|efers to|
|00000e90| 20 61 20 64 69 72 65 63 | 74 6f 72 79 0a 58 20 20 | a direc|tory.X |
|00000ea0| 20 20 6c 69 62 72 61 72 | 79 2c 20 6d 6f 64 69 66 | librar|y, modif|
|00000eb0| 79 20 69 74 20 74 6f 20 | 73 69 6d 70 6c 79 20 72 |y it to |simply r|
|00000ec0| 65 66 65 72 20 74 6f 20 | 74 68 65 20 65 6e 74 72 |efer to |the entr|
|00000ed0| 79 20 66 6f 72 20 22 64 | 69 72 65 6e 74 22 2e 29 |y for "d|irent".)|
|00000ee0| 0a 58 0a 58 33 29 20 20 | 43 6f 70 79 20 74 68 65 |.X.X3) |Copy the|
|00000ef0| 20 66 69 6c 65 73 20 63 | 6c 6f 73 65 64 69 72 2e | files c|losedir.|
|00000f00| 63 2c 20 6f 70 65 6e 64 | 69 72 2e 63 2c 20 72 65 |c, opend|ir.c, re|
|00000f10| 61 64 64 69 72 2e 63 2c | 20 72 65 77 69 6e 64 64 |addir.c,| rewindd|
|00000f20| 69 72 2e 63 2c 20 73 65 | 65 6b 64 69 72 2e 63 2c |ir.c, se|ekdir.c,|
|00000f30| 0a 58 20 20 20 20 61 6e | 64 20 74 65 6c 6c 64 69 |.X an|d telldi|
|00000f40| 72 2e 63 20 74 6f 20 74 | 68 65 20 22 67 65 6e 22 |r.c to t|he "gen"|
|00000f50| 20 6f 72 20 22 70 6f 72 | 74 2f 67 65 6e 22 20 73 | or "por|t/gen" s|
|00000f60| 75 62 64 69 72 65 63 74 | 6f 72 79 20 6f 66 20 79 |ubdirect|ory of y|
|00000f70| 6f 75 72 20 43 20 6c 69 | 62 72 61 72 79 0a 58 20 |our C li|brary.X |
|00000f80| 20 20 20 73 6f 75 72 63 | 65 20 64 69 72 65 63 74 | sourc|e direct|
|00000f90| 6f 72 79 2e 20 20 49 66 | 20 79 6f 75 20 64 6f 20 |ory. If| you do |
|00000fa0| 6e 6f 74 20 68 61 76 65 | 20 61 20 67 65 74 64 65 |not have| a getde|
|00000fb0| 6e 74 73 28 29 20 73 79 | 73 74 65 6d 20 63 61 6c |nts() sy|stem cal|
|00000fc0| 6c 2c 20 63 6f 70 79 20 | 74 68 65 0a 58 20 20 20 |l, copy |the.X |
|00000fd0| 20 66 69 6c 65 20 67 65 | 74 64 65 6e 74 73 2e 63 | file ge|tdents.c|
|00000fe0| 20 74 6f 20 74 68 65 20 | 22 73 79 73 22 20 6f 72 | to the |"sys" or|
|00000ff0| 20 22 70 6f 72 74 2f 73 | 79 73 22 20 73 75 62 64 | "port/s|ys" subd|
|00001000| 69 72 65 63 74 6f 72 79 | 20 61 6e 64 20 63 6f 70 |irectory| and cop|
|00001010| 79 20 74 68 65 20 66 69 | 6c 65 0a 58 20 20 20 20 |y the fi|le.X |
|00001020| 67 65 74 64 65 6e 74 73 | 2e 32 20 74 6f 20 2f 75 |getdents|.2 to /u|
|00001030| 73 72 2f 6d 61 6e 2f 6d | 61 6e 32 2f 67 65 74 64 |sr/man/m|an2/getd|
|00001040| 65 6e 74 73 2e 32 20 28 | 61 63 74 75 61 6c 6c 79 |ents.2 (|actually|
|00001050| 20 79 6f 75 20 6d 61 79 | 20 70 72 65 66 65 72 20 | you may| prefer |
|00001060| 74 6f 20 70 75 74 20 74 | 68 69 73 0a 58 20 20 20 |to put t|his.X |
|00001070| 20 66 69 6c 65 20 69 6e | 20 73 65 63 74 69 6f 6e | file in| section|
|00001080| 20 33 20 61 6e 64 20 61 | 64 6a 75 73 74 20 74 68 | 3 and a|djust th|
|00001090| 65 20 72 65 66 65 72 65 | 6e 63 65 73 20 69 6e 20 |e refere|nces in |
|000010a0| 74 68 65 20 6f 74 68 65 | 72 20 6d 61 6e 75 61 6c |the othe|r manual|
|000010b0| 20 65 6e 74 72 69 65 73 | 0a 58 20 20 20 20 61 63 | entries|.X ac|
|000010c0| 63 6f 72 64 69 6e 67 6c | 79 3b 20 61 6c 73 6f 20 |cordingl|y; also |
|000010d0| 61 64 6a 75 73 74 20 74 | 68 65 20 72 65 66 65 72 |adjust t|he refer|
|000010e0| 65 6e 63 65 73 20 74 6f | 20 64 69 72 65 6e 74 28 |ences to| dirent(|
|000010f0| 34 29 20 74 6f 20 62 65 | 20 74 6f 20 64 69 72 65 |4) to be| to dire|
|00001100| 6e 74 28 35 29 20 69 66 | 0a 58 20 20 20 20 74 68 |nt(5) if|.X th|
|00001110| 61 74 27 73 20 77 68 65 | 72 65 20 74 68 65 20 65 |at's whe|re the e|
|00001120| 6e 74 72 79 20 69 73 29 | 2e 20 20 45 64 69 74 20 |ntry is)|. Edit |
|00001130| 74 68 65 20 43 20 6c 69 | 62 72 61 72 79 20 6d 61 |the C li|brary ma|
|00001140| 6b 65 66 69 6c 65 28 73 | 29 20 74 6f 20 69 6e 63 |kefile(s|) to inc|
|00001150| 6c 75 64 65 20 74 68 65 | 0a 58 20 20 20 20 6e 65 |lude the|.X ne|
|00001160| 77 20 6f 62 6a 65 63 74 | 20 6d 6f 64 75 6c 65 73 |w object| modules|
|00001170| 20 69 6e 20 74 68 65 20 | 43 20 6c 69 62 72 61 72 | in the |C librar|
|00001180| 79 2e 20 20 28 53 65 65 | 20 74 68 65 20 63 6f 6d |y. (See| the com|
|00001190| 6d 65 6e 74 73 20 61 74 | 20 74 68 65 20 62 65 67 |ments at| the beg|
|000011a0| 69 6e 6e 69 6e 67 20 6f | 66 0a 58 20 20 20 20 67 |inning o|f.X g|
|000011b0| 65 74 64 65 6e 74 73 2e | 63 20 66 6f 72 20 73 79 |etdents.|c for sy|
|000011c0| 6d 62 6f 6c 73 20 74 68 | 61 74 20 6d 75 73 74 20 |mbols th|at must |
|000011d0| 62 65 20 64 65 66 69 6e | 65 64 20 74 6f 20 63 6f |be defin|ed to co|
|000011e0| 6e 66 69 67 75 72 65 20 | 67 65 74 64 65 6e 74 73 |nfigure |getdents|
|000011f0| 2e 63 2e 29 20 20 54 68 | 65 6e 0a 58 20 20 20 20 |.c.) Th|en.X |
|00001200| 72 65 6d 61 6b 65 20 61 | 6e 64 20 72 65 69 6e 73 |remake a|nd reins|
|00001210| 74 61 6c 6c 20 74 68 65 | 20 43 20 6c 69 62 72 61 |tall the| C libra|
|00001220| 72 79 2e 20 20 41 6c 74 | 65 72 6e 61 74 69 76 65 |ry. Alt|ernative|
|00001230| 6c 79 2c 20 79 6f 75 20 | 63 61 6e 20 6a 75 73 74 |ly, you |can just|
|00001240| 20 63 6f 6d 70 69 6c 65 | 0a 58 20 20 20 20 74 68 | compile|.X th|
|00001250| 65 20 6e 65 77 20 73 6f | 75 72 63 65 73 20 61 6e |e new so|urces an|
|00001260| 64 20 69 6e 73 65 72 74 | 20 74 68 65 69 72 20 6f |d insert| their o|
|00001270| 62 6a 65 63 74 73 20 6e | 65 61 72 20 74 68 65 20 |bjects n|ear the |
|00001280| 66 72 6f 6e 74 20 6f 66 | 20 74 68 65 20 43 20 6c |front of| the C l|
|00001290| 69 62 72 61 72 79 0a 58 | 20 20 20 20 2f 6c 69 62 |ibrary.X| /lib|
|000012a0| 2f 6c 69 62 63 2e 61 20 | 75 73 69 6e 67 20 74 68 |/libc.a |using th|
|000012b0| 65 20 22 61 72 22 20 75 | 74 69 6c 69 74 79 20 28 |e "ar" u|tility (|
|000012c0| 73 65 65 6b 64 69 72 2e | 6f 20 73 68 6f 75 6c 64 |seekdir.|o should|
|000012d0| 20 70 72 65 63 65 64 65 | 20 72 65 61 64 64 69 72 | precede| readdir|
|000012e0| 2e 6f 2c 0a 58 20 20 20 | 20 77 68 69 63 68 20 69 |.o,.X | which i|
|000012f0| 6e 20 74 75 72 6e 20 73 | 68 6f 75 6c 64 20 70 72 |n turn s|hould pr|
|00001300| 65 63 65 64 65 20 67 65 | 74 64 65 6e 74 73 2e 6f |ecede ge|tdents.o|
|00001310| 29 2e 20 20 4f 6e 20 73 | 6f 6d 65 20 73 79 73 74 |). On s|ome syst|
|00001320| 65 6d 73 20 79 6f 75 20 | 74 68 65 6e 20 6e 65 65 |ems you |then nee|
|00001330| 64 20 74 6f 0a 58 20 20 | 20 20 75 73 65 20 74 68 |d to.X | use th|
|00001340| 65 20 22 72 61 6e 6c 69 | 62 22 20 75 74 69 6c 69 |e "ranli|b" utili|
|00001350| 74 79 20 74 6f 20 75 70 | 64 61 74 65 20 74 68 65 |ty to up|date the|
|00001360| 20 61 72 63 68 69 76 65 | 20 73 79 6d 62 6f 6c 20 | archive| symbol |
|00001370| 74 61 62 6c 65 2e 0a 58 | 0a 58 34 29 20 20 41 66 |table..X|.X4) Af|
|00001380| 74 65 72 20 74 68 65 20 | 43 20 6c 69 62 72 61 72 |ter the |C librar|
|00001390| 79 20 68 61 73 20 62 65 | 65 6e 20 75 70 64 61 74 |y has be|en updat|
|000013a0| 65 64 2c 20 64 65 6c 65 | 74 65 20 2f 75 73 72 2f |ed, dele|te /usr/|
|000013b0| 69 6e 63 6c 75 64 65 2f | 6e 64 69 72 2e 68 20 6f |include/|ndir.h o|
|000013c0| 72 20 61 6e 79 0a 58 20 | 20 20 20 6f 74 68 65 72 |r any.X | other|
|000013d0| 20 68 65 61 64 65 72 20 | 75 73 65 64 20 77 69 74 | header |used wit|
|000013e0| 68 20 61 20 70 72 65 76 | 69 6f 75 73 20 64 69 72 |h a prev|ious dir|
|000013f0| 65 63 74 6f 72 79 20 6c | 69 62 72 61 72 79 20 74 |ectory l|ibrary t|
|00001400| 6f 20 70 72 65 76 65 6e | 74 20 69 6e 61 64 76 65 |o preven|t inadve|
|00001410| 72 74 65 6e 74 0a 58 20 | 20 20 20 75 73 65 20 6f |rtent.X | use o|
|00001420| 66 20 74 68 65 20 73 75 | 70 65 72 73 65 64 65 64 |f the su|perseded|
|00001430| 20 64 69 72 65 63 74 6f | 72 79 20 61 63 63 65 73 | directo|ry acces|
|00001440| 73 20 69 6e 74 65 72 66 | 61 63 65 2e 20 20 41 6c |s interf|ace. Al|
|00001450| 73 6f 20 64 65 6c 65 74 | 65 20 61 6e 79 0a 58 20 |so delet|e any.X |
|00001460| 20 20 20 63 6f 72 72 65 | 73 70 6f 6e 64 69 6e 67 | corre|sponding|
|00001470| 20 6c 69 62 72 61 72 79 | 20 73 75 63 68 20 61 73 | library| such as|
|00001480| 20 2f 75 73 72 2f 6c 69 | 62 2f 6c 69 62 6e 64 69 | /usr/li|b/libndi|
|00001490| 72 2e 61 2e 0a 58 0a 58 | 35 29 20 20 54 6f 20 76 |r.a..X.X|5) To v|
|000014a0| 65 72 69 66 79 20 69 6e | 73 74 61 6c 6c 61 74 69 |erify in|stallati|
|000014b0| 6f 6e 2c 20 74 72 79 20 | 63 6f 6d 70 69 6c 69 6e |on, try |compilin|
|000014c0| 67 2c 20 6c 69 6e 6b 69 | 6e 67 2c 20 61 6e 64 20 |g, linki|ng, and |
|000014d0| 72 75 6e 6e 69 6e 67 20 | 74 68 65 20 70 72 6f 67 |running |the prog|
|000014e0| 72 61 6d 0a 58 20 20 20 | 20 74 65 73 74 64 69 72 |ram.X | testdir|
|000014f0| 2e 63 2e 20 20 54 68 69 | 73 20 70 72 6f 67 72 61 |.c. Thi|s progra|
|00001500| 6d 20 73 65 61 72 63 68 | 65 73 20 74 68 65 20 63 |m search|es the c|
|00001510| 75 72 72 65 6e 74 20 64 | 69 72 65 63 74 6f 72 79 |urrent d|irectory|
|00001520| 20 22 2e 22 20 66 6f 72 | 20 65 61 63 68 20 66 69 | "." for| each fi|
|00001530| 6c 65 0a 58 20 20 20 20 | 6e 61 6d 65 64 20 61 73 |le.X |named as|
|00001540| 20 61 20 70 72 6f 67 72 | 61 6d 20 61 72 67 75 6d | a progr|am argum|
|00001550| 65 6e 74 20 61 6e 64 20 | 70 72 69 6e 74 73 20 60 |ent and |prints `|
|00001560| 22 46 4f 4f 22 20 66 6f | 75 6e 64 2e 27 20 6f 72 |"FOO" fo|und.' or|
|00001570| 20 60 22 46 4f 4f 22 20 | 6e 6f 74 20 66 6f 75 6e | `"FOO" |not foun|
|00001580| 64 2e 27 0a 58 20 20 20 | 20 77 68 65 72 65 20 46 |d.'.X | where F|
|00001590| 4f 4f 20 69 73 20 6f 66 | 20 63 6f 75 72 73 65 20 |OO is of| course |
|000015a0| 72 65 70 6c 61 63 65 64 | 20 62 79 20 74 68 65 20 |replaced| by the |
|000015b0| 6e 61 6d 65 20 62 65 69 | 6e 67 20 73 6f 75 67 68 |name bei|ng sough|
|000015c0| 74 20 69 6e 20 74 68 65 | 20 64 69 72 65 63 74 6f |t in the| directo|
|000015d0| 72 79 2e 0a 58 20 20 20 | 20 54 72 79 20 73 6f 6d |ry..X | Try som|
|000015e0| 65 74 68 69 6e 67 20 6c | 69 6b 65 0a 58 0a 58 09 |ething l|ike.X.X.|
|000015f0| 63 64 20 2f 75 73 72 2f | 62 69 6e 09 09 09 23 20 |cd /usr/|bin...# |
|00001600| 61 20 6d 75 6c 74 69 2d | 62 6c 6f 63 6b 20 64 69 |a multi-|block di|
|00001610| 72 65 63 74 6f 72 79 0a | 58 09 57 48 45 52 45 56 |rectory.|X.WHEREV|
|00001620| 45 52 2f 74 65 73 74 64 | 69 72 20 46 4f 4f 20 6c |ER/testd|ir FOO l|
|00001630| 69 6e 74 20 42 41 52 20 | 66 37 37 20 58 59 5a 5a |int BAR |f77 XYZZ|
|00001640| 59 0a 58 0a 58 20 20 20 | 20 77 68 69 63 68 20 73 |Y.X.X | which s|
|00001650| 68 6f 75 6c 64 20 70 72 | 6f 64 75 63 65 20 74 68 |hould pr|oduce th|
|00001660| 65 20 6f 75 74 70 75 74 | 0a 58 0a 58 09 22 46 4f |e output|.X.X."FO|
|00001670| 4f 22 20 6e 6f 74 20 66 | 6f 75 6e 64 2e 0a 58 09 |O" not f|ound..X.|
|00001680| 22 6c 69 6e 74 22 20 66 | 6f 75 6e 64 2e 0a 58 09 |"lint" f|ound..X.|
|00001690| 22 42 41 52 22 20 6e 6f | 74 20 66 6f 75 6e 64 2e |"BAR" no|t found.|
|000016a0| 0a 58 09 22 66 37 37 22 | 20 66 6f 75 6e 64 2e 0a |.X."f77"| found..|
|000016b0| 58 09 22 58 59 5a 5a 59 | 22 20 6e 6f 74 20 66 6f |X."XYZZY|" not fo|
|000016c0| 75 6e 64 2e 0a 58 0a 58 | 20 20 20 20 41 20 6d 6f |und..X.X| A mo|
|000016d0| 72 65 20 74 68 6f 72 6f | 75 67 68 20 74 65 73 74 |re thoro|ugh test|
|000016e0| 20 77 6f 75 6c 64 20 62 | 65 0a 58 0a 58 09 63 64 | would b|e.X.X.cd|
|000016f0| 20 2f 75 73 72 2f 62 69 | 6e 09 09 09 23 20 61 20 | /usr/bi|n...# a |
|00001700| 6d 75 6c 74 69 2d 62 6c | 6f 63 6b 20 64 69 72 65 |multi-bl|ock dire|
|00001710| 63 74 6f 72 79 0a 58 09 | 57 48 45 52 45 56 45 52 |ctory.X.|WHEREVER|
|00001720| 2f 74 65 73 74 64 69 72 | 20 60 6c 73 20 2d 61 60 |/testdir| `ls -a`|
|00001730| 20 7c 20 67 72 65 70 20 | 27 6e 6f 74 20 66 6f 75 | | grep |'not fou|
|00001740| 6e 64 27 0a 58 0a 58 20 | 20 20 20 54 68 69 73 20 |nd'.X.X | This |
|00001750| 70 72 6f 67 72 61 6d 20 | 64 6f 65 73 20 6e 6f 74 |program |does not|
|00001760| 20 74 65 73 74 20 74 68 | 65 20 73 65 65 6b 64 69 | test th|e seekdi|
|00001770| 72 28 29 20 61 6e 64 20 | 74 65 6c 6c 64 69 72 28 |r() and |telldir(|
|00001780| 29 20 66 75 6e 63 74 69 | 6f 6e 73 2e 0a 58 0a 58 |) functi|ons..X.X|
|00001790| 36 29 20 20 4e 6f 74 69 | 66 79 20 79 6f 75 72 20 |6) Noti|fy your |
|000017a0| 70 72 6f 67 72 61 6d 6d | 65 72 73 20 74 68 61 74 |programm|ers that|
|000017b0| 20 61 6c 6c 20 64 69 72 | 65 63 74 6f 72 79 20 61 | all dir|ectory a|
|000017c0| 63 63 65 73 73 20 6d 75 | 73 74 20 62 65 20 6d 61 |ccess mu|st be ma|
|000017d0| 64 65 20 74 68 72 6f 75 | 67 68 20 74 68 65 0a 58 |de throu|gh the.X|
|000017e0| 20 20 20 20 6e 65 77 20 | 69 6e 74 65 72 66 61 63 | new |interfac|
|000017f0| 65 2c 20 61 6e 64 20 74 | 68 61 74 20 64 6f 63 75 |e, and t|hat docu|
|00001800| 6d 65 6e 74 61 74 69 6f | 6e 20 69 73 20 61 76 61 |mentatio|n is ava|
|00001810| 69 6c 61 62 6c 65 20 76 | 69 61 0a 58 0a 58 09 6d |ilable v|ia.X.X.m|
|00001820| 61 6e 20 64 69 72 65 63 | 74 6f 72 79 20 64 69 72 |an direc|tory dir|
|00001830| 65 6e 74 0a 58 0a 58 20 | 20 20 20 4d 61 6b 65 20 |ent.X.X | Make |
|00001840| 74 68 65 20 4e 4f 54 45 | 53 20 66 69 6c 65 20 61 |the NOTE|S file a|
|00001850| 76 61 69 6c 61 62 6c 65 | 20 74 6f 20 74 68 6f 73 |vailable| to thos|
|00001860| 65 20 70 72 6f 67 72 61 | 6d 6d 65 72 73 20 77 68 |e progra|mmers wh|
|00001870| 6f 20 6d 69 67 68 74 20 | 77 61 6e 74 20 74 6f 0a |o might |want to.|
|00001880| 58 20 20 20 20 75 6e 64 | 65 72 73 74 61 6e 64 20 |X und|erstand |
|00001890| 77 68 61 74 20 74 68 69 | 73 20 69 73 20 61 6c 6c |what thi|s is all|
|000018a0| 20 61 62 6f 75 74 2e 0a | 58 0a 58 37 29 20 20 43 | about..|X.X7) C|
|000018b0| 68 61 6e 67 65 20 61 6c | 6c 20 73 79 73 74 65 6d |hange al|l system|
|000018c0| 20 73 6f 75 72 63 65 73 | 20 74 68 61 74 20 77 65 | sources| that we|
|000018d0| 72 65 20 61 63 63 65 73 | 73 69 6e 67 20 64 69 72 |re acces|sing dir|
|000018e0| 65 63 74 6f 72 69 65 73 | 20 74 6f 20 75 73 65 20 |ectories| to use |
|000018f0| 74 68 65 20 6e 65 77 0a | 58 20 20 20 20 72 6f 75 |the new.|X rou|
|00001900| 74 69 6e 65 73 2e 20 20 | 4e 65 61 72 6c 79 20 61 |tines. |Nearly a|
|00001910| 6c 6c 20 73 75 63 68 20 | 73 6f 75 72 63 65 73 20 |ll such |sources |
|00001920| 63 6f 6e 74 61 69 6e 20 | 74 68 65 20 6c 69 6e 65 |contain |the line|
|00001930| 0a 58 0a 58 09 23 69 6e | 63 6c 75 64 65 20 3c 73 |.X.X.#in|clude <s|
|00001940| 79 73 2f 64 69 72 2e 68 | 3e 0a 58 20 20 20 20 6f |ys/dir.h|>.X o|
|00001950| 72 0a 58 09 23 69 6e 63 | 6c 75 64 65 20 3c 6e 64 |r.X.#inc|lude <nd|
|00001960| 69 72 2e 68 3e 0a 58 0a | 58 20 20 20 20 73 6f 20 |ir.h>.X.|X so |
|00001970| 74 68 65 79 20 73 68 6f | 75 6c 64 20 62 65 20 65 |they sho|uld be e|
|00001980| 61 73 79 20 74 6f 20 66 | 69 6e 64 2e 20 20 28 49 |asy to f|ind. (I|
|00001990| 66 20 79 6f 75 20 65 61 | 72 6c 69 65 72 20 72 65 |f you ea|rlier re|
|000019a0| 6d 6f 76 65 64 20 73 6f | 6d 65 20 6f 74 68 65 72 |moved so|me other|
|000019b0| 20 68 65 61 64 65 72 0a | 58 20 20 20 20 66 69 6c | header.|X fil|
|000019c0| 65 2c 20 74 68 61 74 20 | 69 73 2c 20 69 66 20 74 |e, that |is, if t|
|000019d0| 68 69 73 20 70 61 63 6b | 61 67 65 20 73 75 70 65 |his pack|age supe|
|000019e0| 72 73 65 64 65 64 20 61 | 6e 20 65 61 72 6c 69 65 |rseded a|n earlie|
|000019f0| 72 20 76 65 72 73 69 6f | 6e 20 6f 66 20 74 68 65 |r versio|n of the|
|00001a00| 0a 58 20 20 20 20 64 69 | 72 65 63 74 6f 72 79 20 |.X di|rectory |
|00001a10| 61 63 63 65 73 73 20 6c | 69 62 72 61 72 79 2c 20 |access l|ibrary, |
|00001a20| 6c 6f 6f 6b 20 66 6f 72 | 20 69 74 73 20 6e 61 6d |look for| its nam|
|00001a30| 65 20 74 6f 6f 2e 20 20 | 53 65 65 20 74 68 65 20 |e too. |See the |
|00001a40| 63 6f 6e 76 65 72 73 69 | 6f 6e 0a 58 20 20 20 20 |conversi|on.X |
|00001a50| 69 6e 73 74 72 75 63 74 | 69 6f 6e 73 20 69 6e 20 |instruct|ions in |
|00001a60| 74 68 65 20 4e 4f 54 45 | 53 20 66 69 6c 65 2e 29 |the NOTE|S file.)|
|00001a70| 0a 45 4e 44 5f 4f 46 5f | 49 4e 53 54 41 4c 4c 0a |.END_OF_|INSTALL.|
|00001a80| 69 66 20 74 65 73 74 20 | 35 34 39 30 20 2d 6e 65 |if test |5490 -ne|
|00001a90| 20 60 77 63 20 2d 63 20 | 3c 49 4e 53 54 41 4c 4c | `wc -c |<INSTALL|
|00001aa0| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00001ab0| 20 73 68 61 72 3a 20 5c | 22 49 4e 53 54 41 4c 4c | shar: \|"INSTALL|
|00001ac0| 5c 22 20 75 6e 70 61 63 | 6b 65 64 20 77 69 74 68 |\" unpac|ked with|
|00001ad0| 20 77 72 6f 6e 67 20 73 | 69 7a 65 21 3f 0a 66 69 | wrong s|ize!?.fi|
|00001ae0| 0a 23 20 65 6e 64 20 6f | 66 20 6f 76 65 72 77 72 |.# end o|f overwr|
|00001af0| 69 74 69 6e 67 20 63 68 | 65 63 6b 0a 66 69 0a 65 |iting ch|eck.fi.e|
|00001b00| 63 68 6f 20 73 68 61 72 | 3a 20 45 78 74 72 61 63 |cho shar|: Extrac|
|00001b10| 74 69 6e 67 20 5c 22 4e | 4f 54 45 53 5c 22 20 5c |ting \"N|OTES\" \|
|00001b20| 28 35 33 31 34 20 63 68 | 61 72 61 63 74 65 72 73 |(5314 ch|aracters|
|00001b30| 5c 29 0a 69 66 20 74 65 | 73 74 20 2d 66 20 4e 4f |\).if te|st -f NO|
|00001b40| 54 45 53 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |TES ; th|en . ec|
|00001b50| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|00001b60| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00001b70| 73 74 69 6e 67 20 66 69 | 6c 65 20 5c 22 4e 4f 54 |sting fi|le \"NOT|
|00001b80| 45 53 5c 22 0a 65 6c 73 | 65 0a 73 65 64 20 22 73 |ES\".els|e.sed "s|
|00001b90| 2f 5e 58 2f 2f 22 20 3e | 4e 4f 54 45 53 20 3c 3c |/^X//" >|NOTES <<|
|00001ba0| 27 45 4e 44 5f 4f 46 5f | 4e 4f 54 45 53 27 0a 58 |'END_OF_|NOTES'.X|
|00001bb0| 0a 58 0a 58 4e 4f 54 45 | 53 20 46 4f 52 20 4e 45 |.X.XNOTE|S FOR NE|
|00001bc0| 41 52 4c 59 2d 50 4f 53 | 49 58 2d 43 4f 4d 50 41 |ARLY-POS|IX-COMPA|
|00001bd0| 54 49 42 4c 45 20 43 20 | 4c 49 42 52 41 52 59 20 |TIBLE C |LIBRARY |
|00001be0| 44 49 52 45 43 54 4f 52 | 59 2d 41 43 43 45 53 53 |DIRECTOR|Y-ACCESS|
|00001bf0| 20 52 4f 55 54 49 4e 45 | 53 0a 58 0a 58 0a 58 4f | ROUTINE|S.X.X.XO|
|00001c00| 6c 64 65 72 20 55 4e 49 | 58 20 43 20 6c 69 62 72 |lder UNI|X C libr|
|00001c10| 61 72 69 65 73 20 6c 61 | 63 6b 65 64 20 73 75 70 |aries la|cked sup|
|00001c20| 70 6f 72 74 20 66 6f 72 | 20 72 65 61 64 69 6e 67 |port for| reading|
|00001c30| 20 64 69 72 65 63 74 6f | 72 69 65 73 2c 20 73 6f | directo|ries, so|
|00001c40| 20 68 69 73 74 6f 72 69 | 63 61 6c 6c 79 0a 58 70 | histori|cally.Xp|
|00001c50| 72 6f 67 72 61 6d 73 20 | 68 61 64 20 6b 6e 6f 77 |rograms |had know|
|00001c60| 6c 65 64 67 65 20 6f 66 | 20 55 4e 49 58 20 64 69 |ledge of| UNIX di|
|00001c70| 72 65 63 74 6f 72 79 20 | 73 74 72 75 63 74 75 72 |rectory |structur|
|00001c80| 65 20 68 61 72 64 2d 63 | 6f 64 65 64 20 69 6e 74 |e hard-c|oded int|
|00001c90| 6f 20 74 68 65 6d 2e 20 | 20 57 68 65 6e 0a 58 42 |o them. | When.XB|
|00001ca0| 65 72 6b 65 6c 65 79 20 | 63 68 61 6e 67 65 64 20 |erkeley |changed |
|00001cb0| 74 68 65 20 66 6f 72 6d | 61 74 20 6f 66 20 64 69 |the form|at of di|
|00001cc0| 72 65 63 74 6f 72 69 65 | 73 20 66 6f 72 20 34 2e |rectorie|s for 4.|
|00001cd0| 32 42 53 44 2c 20 69 74 | 20 62 65 63 61 6d 65 20 |2BSD, it| became |
|00001ce0| 6e 65 63 65 73 73 61 72 | 79 20 74 6f 0a 58 63 68 |necessar|y to.Xch|
|00001cf0| 61 6e 67 65 20 70 72 6f | 67 72 61 6d 73 20 74 6f |ange pro|grams to|
|00001d00| 20 77 6f 72 6b 20 77 69 | 74 68 20 74 68 65 20 6e | work wi|th the n|
|00001d10| 65 77 20 73 74 72 75 63 | 74 75 72 65 2e 20 20 46 |ew struc|ture. F|
|00001d20| 6f 72 74 75 6e 61 74 65 | 6c 79 2c 20 42 65 72 6b |ortunate|ly, Berk|
|00001d30| 65 6c 65 79 20 64 65 73 | 69 67 6e 65 64 0a 58 61 |eley des|igned.Xa|
|00001d40| 20 73 6d 61 6c 6c 20 73 | 65 74 20 6f 66 20 64 69 | small s|et of di|
|00001d50| 72 65 63 74 6f 72 79 20 | 61 63 63 65 73 73 20 72 |rectory |access r|
|00001d60| 6f 75 74 69 6e 65 73 20 | 74 6f 20 65 6e 63 61 70 |outines |to encap|
|00001d70| 73 75 6c 61 74 65 20 6b | 6e 6f 77 6c 65 64 67 65 |sulate k|nowledge|
|00001d80| 20 6f 66 20 74 68 65 20 | 6e 65 77 0a 58 64 69 72 | of the |new.Xdir|
|00001d90| 65 63 74 6f 72 79 20 66 | 6f 72 6d 61 74 20 73 6f |ectory f|ormat so|
|00001da0| 20 74 68 61 74 20 75 73 | 65 72 20 70 72 6f 67 72 | that us|er progr|
|00001db0| 61 6d 73 20 63 6f 75 6c | 64 20 64 65 61 6c 20 77 |ams coul|d deal w|
|00001dc0| 69 74 68 20 64 69 72 65 | 63 74 6f 72 79 20 65 6e |ith dire|ctory en|
|00001dd0| 74 72 69 65 73 20 61 73 | 20 61 6e 0a 58 61 62 73 |tries as| an.Xabs|
|00001de0| 74 72 61 63 74 20 64 61 | 74 61 20 74 79 70 65 2e |tract da|ta type.|
|00001df0| 20 20 28 55 6e 66 6f 72 | 74 75 6e 61 74 65 6c 79 | (Unfor|tunately|
|00001e00| 2c 20 74 68 65 79 20 64 | 69 64 6e 27 74 20 67 65 |, they d|idn't ge|
|00001e10| 74 20 69 74 20 71 75 69 | 74 65 20 72 69 67 68 74 |t it qui|te right|
|00001e20| 2e 29 20 20 54 68 65 0a | 58 69 6e 74 65 72 66 61 |.) The.|Xinterfa|
|00001e30| 63 65 20 74 6f 20 74 68 | 65 73 65 20 72 6f 75 74 |ce to th|ese rout|
|00001e40| 69 6e 65 73 20 77 61 73 | 20 6e 65 61 72 6c 79 20 |ines was| nearly |
|00001e50| 69 6e 64 65 70 65 6e 64 | 65 6e 74 20 6f 66 20 74 |independ|ent of t|
|00001e60| 68 65 20 70 61 72 74 69 | 63 75 6c 61 72 0a 58 69 |he parti|cular.Xi|
|00001e70| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 6f 66 |mplement|ation of|
|00001e80| 20 64 69 72 65 63 74 6f | 72 69 65 73 20 6f 6e 20 | directo|ries on |
|00001e90| 61 6e 79 20 67 69 76 65 | 6e 20 55 4e 49 58 20 73 |any give|n UNIX s|
|00001ea0| 79 73 74 65 6d 3b 20 74 | 68 69 73 20 68 61 73 20 |ystem; t|his has |
|00001eb0| 62 65 63 6f 6d 65 20 61 | 0a 58 70 61 72 74 69 63 |become a|.Xpartic|
|00001ec0| 75 6c 61 72 6c 79 20 69 | 6d 70 6f 72 74 61 6e 74 |ularly i|mportant|
|00001ed0| 20 72 65 71 75 69 72 65 | 6d 65 6e 74 20 77 69 74 | require|ment wit|
|00001ee0| 68 20 74 68 65 20 61 64 | 76 65 6e 74 20 6f 66 20 |h the ad|vent of |
|00001ef0| 68 65 74 65 72 6f 67 65 | 6e 65 6f 75 73 20 6e 65 |heteroge|neous ne|
|00001f00| 74 77 6f 72 6b 0a 58 66 | 69 6c 65 73 79 73 74 65 |twork.Xf|ilesyste|
|00001f10| 6d 73 20 73 75 63 68 20 | 61 73 20 4e 46 53 2e 0a |ms such |as NFS..|
|00001f20| 58 0a 58 49 74 20 68 61 | 73 20 63 6f 6e 73 65 71 |X.XIt ha|s conseq|
|00001f30| 75 65 6e 74 6c 79 20 62 | 65 63 6f 6d 65 20 70 6f |uently b|ecome po|
|00001f40| 73 73 69 62 6c 65 20 74 | 6f 20 77 72 69 74 65 20 |ssible t|o write |
|00001f50| 70 6f 72 74 61 62 6c 65 | 20 61 70 70 6c 69 63 61 |portable| applica|
|00001f60| 74 69 6f 6e 73 20 74 68 | 61 74 20 73 65 61 72 63 |tions th|at searc|
|00001f70| 68 0a 58 64 69 72 65 63 | 74 6f 72 69 65 73 20 62 |h.Xdirec|tories b|
|00001f80| 79 20 72 65 73 74 72 69 | 63 74 69 6e 67 20 61 6c |y restri|cting al|
|00001f90| 6c 20 64 69 72 65 63 74 | 6f 72 79 20 61 63 63 65 |l direct|ory acce|
|00001fa0| 73 73 20 74 6f 20 75 73 | 65 20 74 68 65 73 65 20 |ss to us|e these |
|00001fb0| 6e 65 77 20 69 6e 74 65 | 72 66 61 63 65 0a 58 72 |new inte|rface.Xr|
|00001fc0| 6f 75 74 69 6e 65 73 2e | 20 20 54 68 65 20 73 6f |outines.| The so|
|00001fd0| 75 72 63 65 73 20 73 75 | 70 70 6c 69 65 64 20 68 |urces su|pplied h|
|00001fe0| 65 72 65 20 61 72 65 20 | 61 20 74 6f 74 61 6c 20 |ere are |a total |
|00001ff0| 72 65 77 72 69 74 65 20 | 6f 66 20 42 65 72 6b 65 |rewrite |of Berke|
|00002000| 6c 65 79 27 73 20 63 6f | 64 65 2c 0a 58 69 6e 63 |ley's co|de,.Xinc|
|00002010| 6f 72 70 6f 72 61 74 69 | 6e 67 20 69 64 65 61 73 |orporati|ng ideas|
|00002020| 20 66 72 6f 6d 20 61 20 | 76 61 72 69 65 74 79 20 | from a |variety |
|00002030| 6f 66 20 73 6f 75 72 63 | 65 73 20 61 6e 64 20 63 |of sourc|es and c|
|00002040| 6f 6e 66 6f 72 6d 69 6e | 67 20 61 73 20 63 6c 6f |onformin|g as clo|
|00002050| 73 65 6c 79 20 74 6f 0a | 58 70 75 62 6c 69 73 68 |sely to.|Xpublish|
|00002060| 65 64 20 73 74 61 6e 64 | 61 72 64 73 20 61 73 20 |ed stand|ards as |
|00002070| 70 6f 73 73 69 62 6c 65 | 2c 20 61 6e 64 20 61 72 |possible|, and ar|
|00002080| 65 20 69 6e 20 74 68 65 | 20 50 55 42 4c 49 43 20 |e in the| PUBLIC |
|00002090| 44 4f 4d 41 49 4e 20 74 | 6f 20 65 6e 63 6f 75 72 |DOMAIN t|o encour|
|000020a0| 61 67 65 0a 58 74 68 65 | 69 72 20 77 69 64 65 73 |age.Xthe|ir wides|
|000020b0| 70 72 65 61 64 20 61 64 | 6f 70 74 69 6f 6e 2e 20 |pread ad|option. |
|000020c0| 20 54 68 65 79 20 73 75 | 70 70 6f 72 74 20 66 6f | They su|pport fo|
|000020d0| 75 72 20 6d 65 74 68 6f | 64 73 20 6f 66 20 61 63 |ur metho|ds of ac|
|000020e0| 63 65 73 73 20 74 6f 20 | 73 79 73 74 65 6d 0a 58 |cess to |system.X|
|000020f0| 64 69 72 65 63 74 6f 72 | 69 65 73 3a 20 74 68 65 |director|ies: the|
|00002100| 20 6f 72 69 67 69 6e 61 | 6c 20 55 4e 49 58 20 66 | origina|l UNIX f|
|00002110| 69 6c 65 73 79 73 74 65 | 6d 20 76 69 61 20 72 65 |ilesyste|m via re|
|00002120| 61 64 28 29 2c 20 74 68 | 65 20 34 2e 32 42 53 44 |ad(), th|e 4.2BSD|
|00002130| 20 66 69 6c 65 73 79 73 | 74 65 6d 20 76 69 61 0a | filesys|tem via.|
|00002140| 58 72 65 61 64 28 29 2c | 20 4e 46 53 20 61 6e 64 |Xread(),| NFS and|
|00002150| 20 6e 61 74 69 76 65 20 | 66 69 6c 65 73 79 73 74 | native |filesyst|
|00002160| 65 6d 73 20 76 69 61 20 | 67 65 74 64 69 72 65 6e |ems via |getdiren|
|00002170| 74 72 69 65 73 28 29 2c | 20 61 6e 64 20 53 56 52 |tries(),| and SVR|
|00002180| 33 20 67 65 74 64 65 6e | 74 73 28 29 2e 0a 58 54 |3 getden|ts()..XT|
|00002190| 68 65 20 6f 74 68 65 72 | 20 74 68 72 65 65 20 74 |he other| three t|
|000021a0| 79 70 65 73 20 61 72 65 | 20 61 63 63 6f 6d 70 6c |ypes are| accompl|
|000021b0| 69 73 68 65 64 20 62 79 | 20 61 70 70 72 6f 70 72 |ished by| appropr|
|000021c0| 69 61 74 65 20 65 6d 75 | 6c 61 74 69 6f 6e 20 6f |iate emu|lation o|
|000021d0| 66 20 74 68 65 20 53 56 | 52 33 0a 58 67 65 74 64 |f the SV|R3.Xgetd|
|000021e0| 65 6e 74 73 28 29 20 73 | 79 73 74 65 6d 20 63 61 |ents() s|ystem ca|
|000021f0| 6c 6c 2c 20 77 68 69 63 | 68 20 61 74 74 61 69 6e |ll, whic|h attain|
|00002200| 73 20 70 6f 72 74 61 62 | 69 6c 69 74 79 20 61 74 |s portab|ility at|
|00002210| 20 74 68 65 20 63 6f 73 | 74 20 6f 66 20 73 6c 69 | the cos|t of sli|
|00002220| 67 68 74 6c 79 20 6d 6f | 72 65 0a 58 64 61 74 61 |ghtly mo|re.Xdata|
|00002230| 20 6d 6f 76 65 6d 65 6e | 74 20 74 68 61 6e 20 61 | movemen|t than a|
|00002240| 62 73 6f 6c 75 74 65 6c | 79 20 6e 65 63 65 73 73 |bsolutel|y necess|
|00002250| 61 72 79 20 66 6f 72 20 | 73 6f 6d 65 20 73 79 73 |ary for |some sys|
|00002260| 74 65 6d 73 2e 20 20 54 | 68 65 73 65 20 72 6f 75 |tems. T|hese rou|
|00002270| 74 69 6e 65 73 0a 58 73 | 68 6f 75 6c 64 20 62 65 |tines.Xs|hould be|
|00002280| 20 61 64 64 65 64 20 74 | 6f 20 74 68 65 20 73 74 | added t|o the st|
|00002290| 61 6e 64 61 72 64 20 43 | 20 6c 69 62 72 61 72 79 |andard C| library|
|000022a0| 20 6f 6e 20 61 6c 6c 20 | 55 4e 49 58 20 73 79 73 | on all |UNIX sys|
|000022b0| 74 65 6d 73 2c 20 61 6e | 64 20 61 6c 6c 20 65 78 |tems, an|d all ex|
|000022c0| 69 73 74 69 6e 67 0a 58 | 61 6e 64 20 66 75 74 75 |isting.X|and futu|
|000022d0| 72 65 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 20 |re appli|cations |
|000022e0| 73 68 6f 75 6c 64 20 62 | 65 20 63 68 61 6e 67 65 |should b|e change|
|000022f0| 64 20 74 6f 20 75 73 65 | 20 74 68 69 73 20 69 6e |d to use| this in|
|00002300| 74 65 72 66 61 63 65 2e | 20 20 4f 6e 63 65 20 74 |terface.| Once t|
|00002310| 68 69 73 20 69 73 0a 58 | 64 6f 6e 65 2c 20 74 68 |his is.X|done, th|
|00002320| 65 72 65 20 73 68 6f 75 | 6c 64 20 62 65 20 6e 6f |ere shou|ld be no|
|00002330| 20 70 6f 72 74 61 62 69 | 6c 69 74 79 20 70 72 6f | portabi|lity pro|
|00002340| 62 6c 65 6d 73 20 64 75 | 65 20 74 6f 20 64 69 66 |blems du|e to dif|
|00002350| 66 65 72 65 6e 63 65 73 | 20 69 6e 20 75 6e 64 65 |ferences| in unde|
|00002360| 72 6c 79 69 6e 67 0a 58 | 64 69 72 65 63 74 6f 72 |rlying.X|director|
|00002370| 79 20 73 74 72 75 63 74 | 75 72 65 73 20 61 6d 6f |y struct|ures amo|
|00002380| 6e 67 20 55 4e 49 58 20 | 73 79 73 74 65 6d 73 2e |ng UNIX |systems.|
|00002390| 20 20 28 57 68 65 6e 20 | 70 6f 72 74 69 6e 67 20 | (When |porting |
|000023a0| 79 6f 75 72 20 61 70 70 | 6c 69 63 61 74 69 6f 6e |your app|lication|
|000023b0| 73 20 74 6f 0a 58 6f 74 | 68 65 72 20 55 4e 49 58 |s to.Xot|her UNIX|
|000023c0| 20 73 79 73 74 65 6d 73 | 2c 20 79 6f 75 20 63 61 | systems|, you ca|
|000023d0| 6e 20 61 6c 77 61 79 73 | 20 63 61 72 72 79 20 74 |n always| carry t|
|000023e0| 68 69 73 20 70 61 63 6b | 61 67 65 20 61 72 6f 75 |his pack|age arou|
|000023f0| 6e 64 20 77 69 74 68 20 | 79 6f 75 2e 29 0a 58 0a |nd with |you.).X.|
|00002400| 58 41 6e 20 61 64 64 69 | 74 69 6f 6e 61 6c 20 62 |XAn addi|tional b|
|00002410| 65 6e 65 66 69 74 20 6f | 66 20 74 68 65 73 65 20 |enefit o|f these |
|00002420| 72 6f 75 74 69 6e 65 73 | 20 69 73 20 74 68 61 74 |routines| is that|
|00002430| 20 74 68 65 79 20 62 75 | 66 66 65 72 20 64 69 72 | they bu|ffer dir|
|00002440| 65 63 74 6f 72 79 20 69 | 6e 70 75 74 2c 0a 58 77 |ectory i|nput,.Xw|
|00002450| 68 69 63 68 20 70 72 6f | 76 69 64 65 73 20 69 6d |hich pro|vides im|
|00002460| 70 72 6f 76 65 64 20 61 | 63 63 65 73 73 20 73 70 |proved a|ccess sp|
|00002470| 65 65 64 20 6f 76 65 72 | 20 72 61 77 20 72 65 61 |eed over| raw rea|
|00002480| 64 28 29 73 20 6f 66 20 | 6f 6e 65 20 65 6e 74 72 |d()s of |one entr|
|00002490| 79 20 61 74 20 61 20 74 | 69 6d 65 2e 0a 58 0a 58 |y at a t|ime..X.X|
|000024a0| 4f 6e 65 20 61 6e 6e 6f | 79 69 6e 67 20 63 6f 6d |One anno|ying com|
|000024b0| 70 61 74 69 62 69 6c 69 | 74 79 20 70 72 6f 62 6c |patibili|ty probl|
|000024c0| 65 6d 20 68 61 73 20 61 | 72 69 73 65 6e 20 61 6c |em has a|risen al|
|000024d0| 6f 6e 67 20 74 68 65 20 | 77 61 79 2c 20 6e 61 6d |ong the |way, nam|
|000024e0| 65 6c 79 20 74 68 61 74 | 20 74 68 65 0a 58 6f 72 |ely that| the.Xor|
|000024f0| 69 67 69 6e 61 6c 20 42 | 65 72 6b 65 6c 65 79 20 |iginal B|erkeley |
|00002500| 69 6e 74 65 72 66 61 63 | 65 20 75 73 65 64 20 74 |interfac|e used t|
|00002510| 68 65 20 73 61 6d 65 20 | 6e 61 6d 65 2c 20 73 74 |he same |name, st|
|00002520| 72 75 63 74 20 64 69 72 | 65 63 74 2c 20 66 6f 72 |ruct dir|ect, for|
|00002530| 20 74 68 65 20 6e 65 77 | 20 64 61 74 61 0a 58 73 | the new| data.Xs|
|00002540| 74 72 75 63 74 75 72 65 | 20 61 73 20 68 61 64 20 |tructure| as had |
|00002550| 62 65 65 6e 20 75 73 65 | 64 20 66 6f 72 20 74 68 |been use|d for th|
|00002560| 65 20 6f 72 69 67 69 6e | 61 6c 20 55 4e 49 58 20 |e origin|al UNIX |
|00002570| 66 69 6c 65 73 79 73 74 | 65 6d 20 64 69 72 65 63 |filesyst|em direc|
|00002580| 74 6f 72 79 20 72 65 63 | 6f 72 64 0a 58 73 74 72 |tory rec|ord.Xstr|
|00002590| 75 63 74 75 72 65 2e 20 | 20 54 68 69 73 20 6e 61 |ucture. | This na|
|000025a0| 6d 65 20 77 61 73 20 63 | 68 61 6e 67 65 64 20 62 |me was c|hanged b|
|000025b0| 79 20 74 68 65 20 49 45 | 45 45 20 31 30 30 33 2e |y the IE|EE 1003.|
|000025c0| 31 20 28 50 4f 53 49 58 | 29 20 57 6f 72 6b 69 6e |1 (POSIX|) Workin|
|000025d0| 67 20 47 72 6f 75 70 20 | 74 6f 0a 58 22 73 74 72 |g Group |to.X"str|
|000025e0| 75 63 74 20 64 69 72 65 | 6e 74 22 20 61 6e 64 20 |uct dire|nt" and |
|000025f0| 77 61 73 20 70 69 63 6b | 65 64 20 75 70 20 66 6f |was pick|ed up fo|
|00002600| 72 20 53 56 52 33 20 75 | 6e 64 65 72 20 74 68 65 |r SVR3 u|nder the|
|00002610| 20 6e 65 77 20 6e 61 6d | 65 3b 20 69 74 20 69 73 | new nam|e; it is|
|00002620| 20 61 6c 73 6f 20 74 68 | 65 0a 58 6e 61 6d 65 20 | also th|e.Xname |
|00002630| 75 73 65 64 20 69 6e 20 | 74 68 69 73 20 70 6f 72 |used in |this por|
|00002640| 74 61 62 6c 65 20 70 61 | 63 6b 61 67 65 2e 20 20 |table pa|ckage. |
|00002650| 49 20 62 65 6c 69 65 76 | 65 20 69 74 20 69 73 20 |I believ|e it is |
|00002660| 6e 65 63 65 73 73 61 72 | 79 20 74 6f 20 62 69 74 |necessar|y to bit|
|00002670| 65 20 74 68 65 0a 58 62 | 75 6c 6c 65 74 20 61 6e |e the.Xb|ullet an|
|00002680| 64 20 61 64 6f 70 74 20 | 74 68 65 20 6e 65 77 20 |d adopt |the new |
|00002690| 6e 6f 6e 2d 63 6f 6e 66 | 6c 69 63 74 69 6e 67 20 |non-conf|licting |
|000026a0| 6e 61 6d 65 2e 20 20 43 | 6f 64 65 20 75 73 69 6e |name. C|ode usin|
|000026b0| 67 20 61 20 34 2e 32 42 | 53 44 2d 63 6f 6d 70 61 |g a 4.2B|SD-compa|
|000026c0| 74 69 62 6c 65 0a 58 70 | 61 63 6b 61 67 65 20 6e |tible.Xp|ackage n|
|000026d0| 65 65 64 73 20 74 6f 20 | 62 65 20 73 6c 69 67 68 |eeds to |be sligh|
|000026e0| 74 6c 79 20 72 65 76 69 | 73 65 64 20 74 6f 20 77 |tly revi|sed to w|
|000026f0| 6f 72 6b 20 77 69 74 68 | 20 74 68 69 73 20 6e 65 |ork with| this ne|
|00002700| 77 20 70 61 63 6b 61 67 | 65 2c 20 61 73 20 66 6f |w packag|e, as fo|
|00002710| 6c 6c 6f 77 73 3a 0a 58 | 09 43 68 61 6e 67 65 0a |llows:.X|.Change.|
|00002720| 58 09 09 23 69 6e 63 6c | 75 64 65 20 3c 6e 64 69 |X..#incl|ude <ndi|
|00002730| 72 2e 68 3e 09 2f 2a 20 | 4e 69 6e 74 68 20 45 64 |r.h>./* |Ninth Ed|
|00002740| 69 74 69 6f 6e 20 55 4e | 49 58 20 2a 2f 0a 58 09 |ition UN|IX */.X.|
|00002750| 6f 72 0a 58 09 09 23 69 | 6e 63 6c 75 64 65 20 3c |or.X..#i|nclude <|
|00002760| 73 79 73 2f 64 69 72 2e | 68 3e 09 2f 2a 20 34 2e |sys/dir.|h>./* 4.|
|00002770| 32 42 53 44 20 2a 2f 0a | 58 09 6f 72 0a 58 09 09 |2BSD */.|X.or.X..|
|00002780| 23 69 6e 63 6c 75 64 65 | 20 3c 64 69 72 2e 68 3e |#include| <dir.h>|
|00002790| 09 2f 2a 20 42 52 4c 20 | 53 79 73 74 65 6d 20 56 |./* BRL |System V|
|000027a0| 20 65 6d 75 6c 61 74 69 | 6f 6e 20 2a 2f 0a 58 09 | emulati|on */.X.|
|000027b0| 74 6f 0a 58 09 09 23 69 | 6e 63 6c 75 64 65 20 3c |to.X..#i|nclude <|
|000027c0| 73 79 73 2f 74 79 70 65 | 73 2e 68 3e 09 2f 2a 20 |sys/type|s.h>./* |
|000027d0| 69 66 20 6e 6f 74 20 61 | 6c 72 65 61 64 79 20 23 |if not a|lready #|
|000027e0| 69 6e 63 6c 75 64 65 64 | 20 2a 2f 0a 58 09 09 23 |included| */.X..#|
|000027f0| 69 6e 63 6c 75 64 65 20 | 3c 64 69 72 65 6e 74 2e |include |<dirent.|
|00002800| 68 3e 0a 58 0a 58 09 43 | 68 61 6e 67 65 0a 58 09 |h>.X.X.C|hange.X.|
|00002810| 09 73 74 72 75 63 74 20 | 64 69 72 65 63 74 0a 58 |.struct |direct.X|
|00002820| 09 74 6f 0a 58 09 09 73 | 74 72 75 63 74 20 64 69 |.to.X..s|truct di|
|00002830| 72 65 6e 74 0a 58 0a 58 | 09 43 68 61 6e 67 65 0a |rent.X.X|.Change.|
|00002840| 58 09 09 28 61 6e 79 74 | 68 69 6e 67 29 2d 3e 64 |X..(anyt|hing)->d|
|00002850| 5f 6e 61 6d 6c 65 6e 0a | 58 09 74 6f 0a 58 09 09 |_namlen.|X.to.X..|
|00002860| 73 74 72 6c 65 6e 28 20 | 28 61 6e 79 74 68 69 6e |strlen( |(anythin|
|00002870| 67 29 2d 3e 64 5f 6e 61 | 6d 65 20 29 0a 58 0a 58 |g)->d_na|me ).X.X|
|00002880| 54 68 65 72 65 20 69 73 | 20 61 20 6d 69 6e 6f 72 |There is| a minor|
|00002890| 20 63 6f 6d 70 61 74 69 | 62 69 6c 69 74 79 20 70 | compati|bility p|
|000028a0| 72 6f 62 6c 65 6d 20 69 | 6e 20 74 68 61 74 20 74 |roblem i|n that t|
|000028b0| 68 65 20 63 6c 6f 73 65 | 64 69 72 28 29 20 66 75 |he close|dir() fu|
|000028c0| 6e 63 74 69 6f 6e 20 77 | 61 73 0a 58 6f 72 69 67 |nction w|as.Xorig|
|000028d0| 69 6e 61 6c 6c 79 20 64 | 65 66 69 6e 65 64 20 74 |inally d|efined t|
|000028e0| 6f 20 68 61 76 65 20 74 | 79 70 65 20 76 6f 69 64 |o have t|ype void|
|000028f0| 2c 20 62 75 74 20 49 45 | 45 45 20 31 30 30 33 2e |, but IE|EE 1003.|
|00002900| 31 20 63 68 61 6e 67 65 | 64 20 74 68 69 73 20 74 |1 change|d this t|
|00002910| 6f 20 74 79 70 65 20 69 | 6e 74 2c 0a 58 77 68 69 |o type i|nt,.Xwhi|
|00002920| 63 68 20 69 73 20 77 68 | 61 74 20 74 68 69 73 20 |ch is wh|at this |
|00002930| 69 6d 70 6c 65 6d 65 6e | 74 61 74 69 6f 6e 20 73 |implemen|tation s|
|00002940| 75 70 70 6f 72 74 73 20 | 28 65 76 65 6e 20 74 68 |upports |(even th|
|00002950| 6f 75 67 68 20 49 20 64 | 69 73 61 67 72 65 65 20 |ough I d|isagree |
|00002960| 77 69 74 68 20 74 68 65 | 0a 58 63 68 61 6e 67 65 |with the|.Xchange|
|00002970| 29 2e 20 20 48 6f 77 65 | 76 65 72 2c 20 74 68 65 |). Howe|ver, the|
|00002980| 20 64 69 66 66 65 72 65 | 6e 63 65 20 64 6f 65 73 | differe|nce does|
|00002990| 20 6e 6f 74 20 61 66 66 | 65 63 74 20 6d 6f 73 74 | not aff|ect most|
|000029a0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 73 2e 0a 58 | applica|tions..X|
|000029b0| 0a 58 41 6e 6f 74 68 65 | 72 20 6d 69 6e 6f 72 20 |.XAnothe|r minor |
|000029c0| 70 72 6f 62 6c 65 6d 20 | 69 73 20 74 68 61 74 20 |problem |is that |
|000029d0| 49 45 45 45 20 31 30 30 | 33 2e 31 20 64 65 66 69 |IEEE 100|3.1 defi|
|000029e0| 6e 65 64 20 74 68 65 20 | 64 5f 6e 61 6d 65 20 6d |ned the |d_name m|
|000029f0| 65 6d 62 65 72 20 6f 66 | 20 61 20 73 74 72 75 63 |ember of| a struc|
|00002a00| 74 0a 58 64 69 72 65 6e | 74 20 74 6f 20 62 65 20 |t.Xdiren|t to be |
|00002a10| 61 6e 20 61 72 72 61 79 | 20 6f 66 20 6d 61 78 69 |an array| of maxi|
|00002a20| 6d 75 6d 20 6c 65 6e 67 | 74 68 3b 20 74 68 69 73 |mum leng|th; this|
|00002a30| 20 64 6f 65 73 20 6e 6f | 74 20 70 65 72 6d 69 74 | does no|t permit|
|00002a40| 20 75 73 65 20 6f 66 20 | 63 6f 6d 70 61 63 74 0a | use of |compact.|
|00002a50| 58 76 61 72 69 61 62 6c | 65 2d 6c 65 6e 67 74 68 |Xvariabl|e-length|
|00002a60| 20 65 6e 74 72 69 65 73 | 20 64 69 72 65 63 74 6c | entries| directl|
|00002a70| 79 20 66 72 6f 6d 20 61 | 20 64 69 72 65 63 74 6f |y from a| directo|
|00002a80| 72 79 20 62 6c 6f 63 6b | 20 62 75 66 66 65 72 2e |ry block| buffer.|
|00002a90| 20 20 54 68 69 73 20 70 | 61 72 74 20 6f 66 0a 58 | This p|art of.X|
|00002aa0| 74 68 65 20 73 70 65 63 | 69 66 69 63 61 74 69 6f |the spec|ificatio|
|00002ab0| 6e 20 69 73 20 69 6e 63 | 6f 6d 70 61 74 69 62 6c |n is inc|ompatibl|
|00002ac0| 65 20 77 69 74 68 20 65 | 66 66 69 63 69 65 6e 74 |e with e|fficient|
|00002ad0| 20 75 73 65 20 6f 66 20 | 74 68 65 20 67 65 74 64 | use of |the getd|
|00002ae0| 65 6e 74 73 28 29 20 73 | 79 73 74 65 6d 0a 58 63 |ents() s|ystem.Xc|
|00002af0| 61 6c 6c 2c 20 61 6e 64 | 20 49 20 68 61 76 65 20 |all, and| I have |
|00002b00| 74 68 65 72 65 66 6f 72 | 65 20 63 68 6f 73 65 6e |therefor|e chosen|
|00002b10| 20 74 6f 20 66 6f 6c 6c | 6f 77 20 74 68 65 20 53 | to foll|ow the S|
|00002b20| 56 49 44 20 73 70 65 63 | 69 66 69 63 61 74 69 6f |VID spec|ificatio|
|00002b30| 6e 20 69 6e 73 74 65 61 | 64 20 6f 66 0a 58 49 45 |n instea|d of.XIE|
|00002b40| 45 45 20 31 30 30 33 2e | 31 20 28 77 68 69 63 68 |EE 1003.|1 (which|
|00002b50| 20 49 20 68 6f 70 65 20 | 69 73 20 63 68 61 6e 67 | I hope |is chang|
|00002b60| 65 64 20 66 6f 72 20 74 | 68 65 20 66 69 6e 61 6c |ed for t|he final|
|00002b70| 2d 75 73 65 20 73 74 61 | 6e 64 61 72 64 29 2e 20 |-use sta|ndard). |
|00002b80| 20 54 68 69 73 0a 58 64 | 65 76 69 61 74 69 6f 6e | This.Xd|eviation|
|00002b90| 20 73 68 6f 75 6c 64 20 | 68 61 76 65 20 6c 69 74 | should |have lit|
|00002ba0| 74 6c 65 20 6f 72 20 6e | 6f 20 69 6d 70 61 63 74 |tle or n|o impact|
|00002bb0| 20 6f 6e 20 73 65 6e 73 | 69 62 6c 79 2d 63 6f 64 | on sens|ibly-cod|
|00002bc0| 65 64 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 2c |ed appli|cations,|
|00002bd0| 20 73 69 6e 63 65 0a 58 | 74 68 65 20 72 65 6c 65 | since.X|the rele|
|00002be0| 76 61 6e 74 20 64 5f 6e | 61 6d 65 20 6c 65 6e 67 |vant d_n|ame leng|
|00002bf0| 74 68 20 69 73 20 74 68 | 61 74 20 67 69 76 65 6e |th is th|at given|
|00002c00| 20 62 79 20 73 74 72 6c | 65 6e 28 29 2c 20 6e 6f | by strl|en(), no|
|00002c10| 74 20 74 68 65 20 64 65 | 63 6c 61 72 65 64 20 61 |t the de|clared a|
|00002c20| 72 72 61 79 0a 58 73 69 | 7a 65 2e 0a 58 0a 58 45 |rray.Xsi|ze..X.XE|
|00002c30| 72 72 6f 72 20 68 61 6e | 64 6c 69 6e 67 20 69 73 |rror han|dling is|
|00002c40| 20 6e 6f 74 20 63 6f 6d | 70 6c 65 74 65 6c 79 20 | not com|pletely |
|00002c50| 73 61 74 69 73 66 61 63 | 74 6f 72 79 2c 20 64 75 |satisfac|tory, du|
|00002c60| 65 20 74 6f 20 74 68 65 | 20 76 61 72 69 65 74 79 |e to the| variety|
|00002c70| 20 6f 66 20 70 6f 73 73 | 69 62 6c 65 0a 58 66 61 | of poss|ible.Xfa|
|00002c80| 69 6c 75 72 65 20 6d 6f | 64 65 73 20 69 6e 20 61 |ilure mo|des in a|
|00002c90| 20 67 65 6e 65 72 61 6c | 20 73 65 74 74 69 6e 67 | general| setting|
|00002ca0| 2e 20 20 46 6f 72 20 65 | 78 61 6d 70 6c 65 2c 20 |. For e|xample, |
|00002cb0| 74 68 65 20 72 65 77 69 | 6e 64 64 69 72 28 29 20 |the rewi|nddir() |
|00002cc0| 66 75 6e 63 74 69 6f 6e | 0a 58 6d 69 67 68 74 20 |function|.Xmight |
|00002cd0| 66 61 69 6c 2c 20 62 75 | 74 20 74 68 65 72 65 20 |fail, bu|t there |
|00002ce0| 69 73 20 6e 6f 20 67 6f | 6f 64 20 77 61 79 20 74 |is no go|od way t|
|00002cf0| 6f 20 69 6e 64 69 63 61 | 74 65 20 74 68 69 73 2e |o indica|te this.|
|00002d00| 20 20 49 20 68 61 76 65 | 20 74 72 69 65 64 20 74 | I have| tried t|
|00002d10| 6f 0a 58 66 6f 6c 6c 6f | 77 20 74 68 65 20 73 70 |o.Xfollo|w the sp|
|00002d20| 65 63 69 66 69 63 61 74 | 69 6f 6e 73 20 69 6e 20 |ecificat|ions in |
|00002d30| 49 45 45 45 20 31 30 30 | 33 2e 31 20 61 6e 64 20 |IEEE 100|3.1 and |
|00002d40| 74 68 65 20 53 56 49 44 | 20 61 73 20 63 6c 6f 73 |the SVID| as clos|
|00002d50| 65 6c 79 20 61 73 20 70 | 6f 73 73 69 62 6c 65 2c |ely as p|ossible,|
|00002d60| 0a 58 62 75 74 20 74 68 | 65 72 65 20 61 72 65 20 |.Xbut th|ere are |
|00002d70| 6d 69 6e 6f 72 20 64 65 | 76 69 61 74 69 6f 6e 73 |minor de|viations|
|00002d80| 20 69 6e 20 74 68 69 73 | 20 72 65 67 61 72 64 2e | in this| regard.|
|00002d90| 20 20 41 70 70 6c 69 63 | 61 74 69 6f 6e 73 20 73 | Applic|ations s|
|00002da0| 68 6f 75 6c 64 20 6e 6f | 74 20 72 65 6c 79 0a 58 |hould no|t rely.X|
|00002db0| 74 6f 6f 20 68 65 61 76 | 69 6c 79 20 6f 6e 20 65 |too heav|ily on e|
|00002dc0| 78 61 63 74 20 66 61 69 | 6c 75 72 65 20 6d 6f 64 |xact fai|lure mod|
|00002dd0| 65 20 73 65 6d 61 6e 74 | 69 63 73 2e 0a 58 0a 58 |e semant|ics..X.X|
|00002de0| 50 6c 65 61 73 65 20 64 | 6f 20 6e 6f 74 20 63 68 |Please d|o not ch|
|00002df0| 61 6e 67 65 20 74 68 65 | 20 6e 65 77 20 73 74 61 |ange the| new sta|
|00002e00| 6e 64 61 72 64 20 69 6e | 74 65 72 66 61 63 65 20 |ndard in|terface |
|00002e10| 69 6e 20 61 6e 79 20 77 | 61 79 2c 20 61 73 20 74 |in any w|ay, as t|
|00002e20| 68 61 74 20 77 6f 75 6c | 64 0a 58 64 65 66 65 61 |hat woul|d.Xdefea|
|00002e30| 74 20 74 68 65 20 6d 61 | 6a 6f 72 20 70 75 72 70 |t the ma|jor purp|
|00002e40| 6f 73 65 20 6f 66 20 74 | 68 69 73 20 70 61 63 6b |ose of t|his pack|
|00002e50| 61 67 65 21 20 20 28 49 | 74 27 73 20 6f 6b 61 79 |age! (I|t's okay|
|00002e60| 20 74 6f 20 61 6c 74 65 | 72 20 74 68 65 20 69 6e | to alte|r the in|
|00002e70| 74 65 72 6e 61 6c 0a 58 | 69 6d 70 6c 65 6d 65 6e |ternal.X|implemen|
|00002e80| 74 61 74 69 6f 6e 20 69 | 66 20 79 6f 75 20 72 65 |tation i|f you re|
|00002e90| 61 6c 6c 79 20 68 61 76 | 65 20 74 6f 2c 20 61 6c |ally hav|e to, al|
|00002ea0| 74 68 6f 75 67 68 20 49 | 20 74 72 69 65 64 20 74 |though I| tried t|
|00002eb0| 6f 20 6d 61 6b 65 20 74 | 68 69 73 20 75 6e 6e 65 |o make t|his unne|
|00002ec0| 63 65 73 73 61 72 79 0a | 58 66 6f 72 20 74 68 65 |cessary.|Xfor the|
|00002ed0| 20 76 61 73 74 20 6d 61 | 6a 6f 72 69 74 79 20 6f | vast ma|jority o|
|00002ee0| 66 20 55 4e 49 58 20 76 | 61 72 69 61 6e 74 73 2e |f UNIX v|ariants.|
|00002ef0| 29 0a 58 0a 58 49 6e 73 | 74 61 6c 6c 61 74 69 6f |).X.XIns|tallatio|
|00002f00| 6e 20 69 6e 73 74 72 75 | 63 74 69 6f 6e 73 20 63 |n instru|ctions c|
|00002f10| 61 6e 20 62 65 20 66 6f | 75 6e 64 20 69 6e 20 74 |an be fo|und in t|
|00002f20| 68 65 20 66 69 6c 65 20 | 6e 61 6d 65 64 20 49 4e |he file |named IN|
|00002f30| 53 54 41 4c 4c 2e 0a 58 | 0a 58 54 68 69 73 20 69 |STALL..X|.XThis i|
|00002f40| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 69 73 |mplement|ation is|
|00002f50| 20 70 72 6f 76 69 64 65 | 64 20 62 79 3a 0a 58 0a | provide|d by:.X.|
|00002f60| 58 09 44 6f 75 67 6c 61 | 73 20 41 2e 20 47 77 79 |X.Dougla|s A. Gwy|
|00002f70| 6e 0a 58 09 55 2e 53 2e | 20 41 72 6d 79 20 42 61 |n.X.U.S.| Army Ba|
|00002f80| 6c 6c 69 73 74 69 63 20 | 52 65 73 65 61 72 63 68 |llistic |Research|
|00002f90| 20 4c 61 62 6f 72 61 74 | 6f 72 79 0a 58 09 53 4c | Laborat|ory.X.SL|
|00002fa0| 43 42 52 2d 56 4c 2d 56 | 0a 58 09 41 62 65 72 64 |CBR-VL-V|.X.Aberd|
|00002fb0| 65 65 6e 20 50 72 6f 76 | 69 6e 67 20 47 72 6f 75 |een Prov|ing Grou|
|00002fc0| 6e 64 2c 20 4d 44 20 32 | 31 30 30 35 2d 35 30 36 |nd, MD 2|1005-506|
|00002fd0| 36 0a 58 0a 58 09 28 33 | 30 31 29 32 37 38 2d 36 |6.X.X.(3|01)278-6|
|00002fe0| 36 34 37 0a 58 0a 58 09 | 47 77 79 6e 40 42 52 4c |647.X.X.|Gwyn@BRL|
|00002ff0| 2e 4d 49 4c 20 6f 72 20 | 73 65 69 73 6d 6f 21 62 |.MIL or |seismo!b|
|00003000| 72 6c 21 67 77 79 6e 0a | 58 0a 58 54 68 69 73 20 |rl!gwyn.|X.XThis |
|00003010| 69 73 20 55 4e 53 55 50 | 50 4f 52 54 45 44 2c 20 |is UNSUP|PORTED, |
|00003020| 75 73 65 2d 61 74 2d 79 | 6f 75 72 2d 6f 77 6e 2d |use-at-y|our-own-|
|00003030| 72 69 73 6b 2c 20 66 72 | 65 65 20 73 6f 66 74 77 |risk, fr|ee softw|
|00003040| 61 72 65 20 69 6e 20 74 | 68 65 20 70 75 62 6c 69 |are in t|he publi|
|00003050| 63 20 64 6f 6d 61 69 6e | 2e 0a 58 48 6f 77 65 76 |c domain|..XHowev|
|00003060| 65 72 2c 20 49 20 77 6f | 75 6c 64 20 61 70 70 72 |er, I wo|uld appr|
|00003070| 65 63 69 61 74 65 20 68 | 65 61 72 69 6e 67 20 6f |eciate h|earing o|
|00003080| 66 20 61 6e 79 20 61 63 | 74 75 61 6c 20 62 75 67 |f any ac|tual bug|
|00003090| 73 20 79 6f 75 20 66 69 | 6e 64 20 69 6e 20 74 68 |s you fi|nd in th|
|000030a0| 69 73 0a 58 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |is.Ximpl|ementati|
|000030b0| 6f 6e 20 61 6e 64 2f 6f | 72 20 61 6e 79 20 69 6d |on and/o|r any im|
|000030c0| 70 72 6f 76 65 6d 65 6e | 74 73 20 79 6f 75 20 63 |provemen|ts you c|
|000030d0| 6f 6d 65 20 75 70 20 77 | 69 74 68 2e 0a 45 4e 44 |ome up w|ith..END|
|000030e0| 5f 4f 46 5f 4e 4f 54 45 | 53 0a 69 66 20 74 65 73 |_OF_NOTE|S.if tes|
|000030f0| 74 20 35 33 31 34 20 2d | 6e 65 20 60 77 63 20 2d |t 5314 -|ne `wc -|
|00003100| 63 20 3c 4e 4f 54 45 53 | 60 3b 20 74 68 65 6e 0a |c <NOTES|`; then.|
|00003110| 20 20 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 5c | echo| shar: \|
|00003120| 22 4e 4f 54 45 53 5c 22 | 20 75 6e 70 61 63 6b 65 |"NOTES\"| unpacke|
|00003130| 64 20 77 69 74 68 20 77 | 72 6f 6e 67 20 73 69 7a |d with w|rong siz|
|00003140| 65 21 3f 0a 66 69 0a 23 | 20 65 6e 64 20 6f 66 20 |e!?.fi.#| end of |
|00003150| 6f 76 65 72 77 72 69 74 | 69 6e 67 20 63 68 65 63 |overwrit|ing chec|
|00003160| 6b 0a 66 69 0a 65 63 68 | 6f 20 73 68 61 72 3a 20 |k.fi.ech|o shar: |
|00003170| 45 78 74 72 61 63 74 69 | 6e 67 20 5c 22 63 6c 6f |Extracti|ng \"clo|
|00003180| 73 65 64 69 72 2e 63 5c | 22 20 5c 28 35 36 38 20 |sedir.c\|" \(568 |
|00003190| 63 68 61 72 61 63 74 65 | 72 73 5c 29 0a 69 66 20 |characte|rs\).if |
|000031a0| 74 65 73 74 20 2d 66 20 | 63 6c 6f 73 65 64 69 72 |test -f |closedir|
|000031b0| 2e 63 20 3b 20 74 68 65 | 6e 20 0a 20 20 65 63 68 |.c ; the|n . ech|
|000031c0| 6f 20 73 68 61 72 3a 20 | 57 69 6c 6c 20 6e 6f 74 |o shar: |Will not|
|000031d0| 20 6f 76 65 72 2d 77 72 | 69 74 65 20 65 78 69 73 | over-wr|ite exis|
|000031e0| 74 69 6e 67 20 66 69 6c | 65 20 5c 22 63 6c 6f 73 |ting fil|e \"clos|
|000031f0| 65 64 69 72 2e 63 5c 22 | 0a 65 6c 73 65 0a 73 65 |edir.c\"|.else.se|
|00003200| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 63 6c 6f 73 |d "s/^X/|/" >clos|
|00003210| 65 64 69 72 2e 63 20 3c | 3c 27 45 4e 44 5f 4f 46 |edir.c <|<'END_OF|
|00003220| 5f 63 6c 6f 73 65 64 69 | 72 2e 63 27 0a 58 2f 2a |_closedi|r.c'.X/*|
|00003230| 0a 58 09 63 6c 6f 73 65 | 64 69 72 20 2d 2d 20 63 |.X.close|dir -- c|
|00003240| 6c 6f 73 65 20 61 20 64 | 69 72 65 63 74 6f 72 79 |lose a d|irectory|
|00003250| 20 73 74 72 65 61 6d 0a | 58 0a 58 09 6c 61 73 74 | stream.|X.X.last|
|00003260| 20 65 64 69 74 3a 09 32 | 35 2d 41 70 72 2d 31 39 | edit:.2|5-Apr-19|
|00003270| 38 37 09 44 20 41 20 47 | 77 79 6e 0a 58 2a 2f 0a |87.D A G|wyn.X*/.|
|00003280| 58 0a 58 23 69 6e 63 6c | 75 64 65 09 3c 73 79 73 |X.X#incl|ude.<sys|
|00003290| 2f 65 72 72 6e 6f 2e 68 | 3e 0a 58 23 69 6e 63 6c |/errno.h|>.X#incl|
|000032a0| 75 64 65 09 3c 73 79 73 | 2f 74 79 70 65 73 2e 68 |ude.<sys|/types.h|
|000032b0| 3e 0a 58 23 69 6e 63 6c | 75 64 65 09 3c 64 69 72 |>.X#incl|ude.<dir|
|000032c0| 65 6e 74 2e 68 3e 0a 58 | 0a 58 74 79 70 65 64 65 |ent.h>.X|.Xtypede|
|000032d0| 66 20 63 68 61 72 09 2a | 70 6f 69 6e 74 65 72 3b |f char.*|pointer;|
|000032e0| 09 09 2f 2a 20 28 76 6f | 69 64 20 2a 29 20 69 66 |../* (vo|id *) if|
|000032f0| 20 79 6f 75 20 68 61 76 | 65 20 69 74 20 2a 2f 0a | you hav|e it */.|
|00003300| 58 0a 58 65 78 74 65 72 | 6e 20 76 6f 69 64 09 66 |X.Xexter|n void.f|
|00003310| 72 65 65 28 29 3b 0a 58 | 65 78 74 65 72 6e 20 69 |ree();.X|extern i|
|00003320| 6e 74 09 63 6c 6f 73 65 | 28 29 3b 0a 58 0a 58 65 |nt.close|();.X.Xe|
|00003330| 78 74 65 72 6e 20 69 6e | 74 09 65 72 72 6e 6f 3b |xtern in|t.errno;|
|00003340| 0a 58 0a 58 23 69 66 6e | 64 65 66 20 4e 55 4c 4c |.X.X#ifn|def NULL|
|00003350| 0a 58 23 64 65 66 69 6e | 65 09 4e 55 4c 4c 09 30 |.X#defin|e.NULL.0|
|00003360| 0a 58 23 65 6e 64 69 66 | 0a 58 0a 58 69 6e 74 0a |.X#endif|.X.Xint.|
|00003370| 58 63 6c 6f 73 65 64 69 | 72 28 20 64 69 72 70 20 |Xclosedi|r( dirp |
|00003380| 29 0a 58 09 72 65 67 69 | 73 74 65 72 20 44 49 52 |).X.regi|ster DIR|
|00003390| 09 2a 64 69 72 70 3b 09 | 09 2f 2a 20 73 74 72 65 |.*dirp;.|./* stre|
|000033a0| 61 6d 20 66 72 6f 6d 20 | 6f 70 65 6e 64 69 72 28 |am from |opendir(|
|000033b0| 29 20 2a 2f 0a 58 09 7b | 0a 58 09 69 66 20 28 20 |) */.X.{|.X.if ( |
|000033c0| 64 69 72 70 20 3d 3d 20 | 4e 55 4c 4c 20 7c 7c 20 |dirp == |NULL || |
|000033d0| 64 69 72 70 2d 3e 64 64 | 5f 62 75 66 20 3d 3d 20 |dirp->dd|_buf == |
|000033e0| 4e 55 4c 4c 20 29 0a 58 | 09 09 7b 0a 58 09 09 65 |NULL ).X|..{.X..e|
|000033f0| 72 72 6e 6f 20 3d 20 45 | 46 41 55 4c 54 3b 0a 58 |rrno = E|FAULT;.X|
|00003400| 09 09 72 65 74 75 72 6e | 20 2d 31 3b 09 09 2f 2a |..return| -1;../*|
|00003410| 20 69 6e 76 61 6c 69 64 | 20 70 6f 69 6e 74 65 72 | invalid| pointer|
|00003420| 20 2a 2f 0a 58 09 09 7d | 0a 58 0a 58 09 66 72 65 | */.X..}|.X.X.fre|
|00003430| 65 28 20 28 70 6f 69 6e | 74 65 72 29 64 69 72 70 |e( (poin|ter)dirp|
|00003440| 2d 3e 64 64 5f 62 75 66 | 20 29 3b 0a 58 09 66 72 |->dd_buf| );.X.fr|
|00003450| 65 65 28 20 28 70 6f 69 | 6e 74 65 72 29 64 69 72 |ee( (poi|nter)dir|
|00003460| 70 20 29 3b 0a 58 09 72 | 65 74 75 72 6e 20 63 6c |p );.X.r|eturn cl|
|00003470| 6f 73 65 28 20 64 69 72 | 70 2d 3e 64 64 5f 66 64 |ose( dir|p->dd_fd|
|00003480| 20 29 3b 0a 58 09 7d 0a | 45 4e 44 5f 4f 46 5f 63 | );.X.}.|END_OF_c|
|00003490| 6c 6f 73 65 64 69 72 2e | 63 0a 69 66 20 74 65 73 |losedir.|c.if tes|
|000034a0| 74 20 35 36 38 20 2d 6e | 65 20 60 77 63 20 2d 63 |t 568 -n|e `wc -c|
|000034b0| 20 3c 63 6c 6f 73 65 64 | 69 72 2e 63 60 3b 20 74 | <closed|ir.c`; t|
|000034c0| 68 65 6e 0a 20 20 20 20 | 65 63 68 6f 20 73 68 61 |hen. |echo sha|
|000034d0| 72 3a 20 5c 22 63 6c 6f | 73 65 64 69 72 2e 63 5c |r: \"clo|sedir.c\|
|000034e0| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|000034f0| 77 72 6f 6e 67 20 73 69 | 7a 65 21 3f 0a 66 69 0a |wrong si|ze!?.fi.|
|00003500| 23 20 65 6e 64 20 6f 66 | 20 6f 76 65 72 77 72 69 |# end of| overwri|
|00003510| 74 69 6e 67 20 63 68 65 | 63 6b 0a 66 69 0a 65 63 |ting che|ck.fi.ec|
|00003520| 68 6f 20 73 68 61 72 3a | 20 45 78 74 72 61 63 74 |ho shar:| Extract|
|00003530| 69 6e 67 20 5c 22 64 69 | 72 65 63 74 6f 72 79 2e |ing \"di|rectory.|
|00003540| 33 63 5c 22 20 5c 28 34 | 31 33 36 20 63 68 61 72 |3c\" \(4|136 char|
|00003550| 61 63 74 65 72 73 5c 29 | 0a 69 66 20 74 65 73 74 |acters\)|.if test|
|00003560| 20 2d 66 20 64 69 72 65 | 63 74 6f 72 79 2e 33 63 | -f dire|ctory.3c|
|00003570| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00003580| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 6f |shar: Wi|ll not o|
|00003590| 76 65 72 2d 77 72 69 74 | 65 20 65 78 69 73 74 69 |ver-writ|e existi|
|000035a0| 6e 67 20 66 69 6c 65 20 | 5c 22 64 69 72 65 63 74 |ng file |\"direct|
|000035b0| 6f 72 79 2e 33 63 5c 22 | 0a 65 6c 73 65 0a 73 65 |ory.3c\"|.else.se|
|000035c0| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 64 69 72 65 |d "s/^X/|/" >dire|
|000035d0| 63 74 6f 72 79 2e 33 63 | 20 3c 3c 27 45 4e 44 5f |ctory.3c| <<'END_|
|000035e0| 4f 46 5f 64 69 72 65 63 | 74 6f 72 79 2e 33 63 27 |OF_direc|tory.3c'|
|000035f0| 0a 58 2e 54 48 20 44 49 | 52 45 43 54 4f 52 59 20 |.X.TH DI|RECTORY |
|00003600| 33 43 20 22 53 74 61 6e | 64 61 72 64 20 45 78 74 |3C "Stan|dard Ext|
|00003610| 65 6e 73 69 6f 6e 22 0a | 58 2e 53 48 20 4e 41 4d |ension".|X.SH NAM|
|00003620| 45 0a 58 6f 70 65 6e 64 | 69 72 2c 20 72 65 61 64 |E.Xopend|ir, read|
|00003630| 64 69 72 2c 20 74 65 6c | 6c 64 69 72 2c 20 73 65 |dir, tel|ldir, se|
|00003640| 65 6b 64 69 72 2c 20 72 | 65 77 69 6e 64 64 69 72 |ekdir, r|ewinddir|
|00003650| 2c 20 63 6c 6f 73 65 64 | 69 72 20 5c 2d 20 64 69 |, closed|ir \- di|
|00003660| 72 65 63 74 6f 72 79 20 | 6f 70 65 72 61 74 69 6f |rectory |operatio|
|00003670| 6e 73 0a 58 2e 53 48 20 | 53 59 4e 4f 50 53 49 53 |ns.X.SH |SYNOPSIS|
|00003680| 0a 58 2e 42 20 22 23 69 | 6e 63 6c 75 64 65 20 3c |.X.B "#i|nclude <|
|00003690| 73 79 73 2f 74 79 70 65 | 73 2e 68 3e 22 0a 58 2e |sys/type|s.h>".X.|
|000036a0| 62 72 0a 58 2e 42 20 22 | 23 69 6e 63 6c 75 64 65 |br.X.B "|#include|
|000036b0| 20 3c 64 69 72 65 6e 74 | 2e 68 3e 22 0a 58 2e 50 | <dirent|.h>".X.P|
|000036c0| 0a 58 2e 42 20 22 44 49 | 52 20 5c 28 2a 2a 6f 70 |.X.B "DI|R \(**op|
|000036d0| 65 6e 64 69 72 20 28 64 | 69 72 6e 61 6d 65 29 22 |endir (d|irname)"|
|000036e0| 0a 58 2e 62 72 0a 58 2e | 42 20 22 63 68 61 72 20 |.X.br.X.|B "char |
|000036f0| 5c 28 2a 2a 64 69 72 6e | 61 6d 65 3b 22 0a 58 2e |\(**dirn|ame;".X.|
|00003700| 50 0a 58 2e 42 20 22 73 | 74 72 75 63 74 20 64 69 |P.X.B "s|truct di|
|00003710| 72 65 6e 74 20 5c 28 2a | 2a 72 65 61 64 64 69 72 |rent \(*|*readdir|
|00003720| 20 28 64 69 72 70 29 22 | 0a 58 2e 62 72 0a 58 2e | (dirp)"|.X.br.X.|
|00003730| 42 20 22 44 49 52 20 5c | 28 2a 2a 64 69 72 70 3b |B "DIR \|(**dirp;|
|00003740| 22 0a 58 2e 50 0a 58 2e | 42 20 22 6f 66 66 5f 74 |".X.P.X.|B "off_t|
|00003750| 20 74 65 6c 6c 64 69 72 | 20 28 64 69 72 70 29 22 | telldir| (dirp)"|
|00003760| 0a 58 2e 62 72 0a 58 2e | 42 20 22 44 49 52 20 5c |.X.br.X.|B "DIR \|
|00003770| 28 2a 2a 64 69 72 70 3b | 22 0a 58 2e 50 0a 58 2e |(**dirp;|".X.P.X.|
|00003780| 42 20 22 76 6f 69 64 20 | 73 65 65 6b 64 69 72 20 |B "void |seekdir |
|00003790| 28 64 69 72 70 2c 20 6c | 6f 63 29 22 0a 58 2e 62 |(dirp, l|oc)".X.b|
|000037a0| 72 0a 58 2e 42 20 22 44 | 49 52 20 5c 28 2a 2a 64 |r.X.B "D|IR \(**d|
|000037b0| 69 72 70 3b 22 0a 58 2e | 62 72 0a 58 2e 42 20 22 |irp;".X.|br.X.B "|
|000037c0| 6f 66 66 5f 74 20 6c 6f | 63 3b 22 0a 58 2e 50 0a |off_t lo|c;".X.P.|
|000037d0| 58 2e 42 20 22 76 6f 69 | 64 20 72 65 77 69 6e 64 |X.B "voi|d rewind|
|000037e0| 64 69 72 20 28 64 69 72 | 70 29 22 0a 58 2e 62 72 |dir (dir|p)".X.br|
|000037f0| 0a 58 2e 42 20 22 44 49 | 52 20 5c 28 2a 2a 64 69 |.X.B "DI|R \(**di|
|00003800| 72 70 3b 22 0a 58 2e 50 | 0a 58 2e 42 20 22 69 6e |rp;".X.P|.X.B "in|
|00003810| 74 20 63 6c 6f 73 65 64 | 69 72 20 28 64 69 72 70 |t closed|ir (dirp|
|00003820| 29 22 0a 58 2e 62 72 0a | 58 2e 42 20 22 44 49 52 |)".X.br.|X.B "DIR|
|00003830| 20 5c 28 2a 2a 64 69 72 | 70 3b 22 0a 58 2e 53 48 | \(**dir|p;".X.SH|
|00003840| 20 44 45 53 43 52 49 50 | 54 49 4f 4e 0a 58 2e 49 | DESCRIP|TION.X.I|
|00003850| 20 4f 70 65 6e 64 69 72 | 0a 58 65 73 74 61 62 6c | Opendir|.Xestabl|
|00003860| 69 73 68 65 73 20 61 20 | 63 6f 6e 6e 65 63 74 69 |ishes a |connecti|
|00003870| 6f 6e 20 62 65 74 77 65 | 65 6e 0a 58 74 68 65 20 |on betwe|en.Xthe |
|00003880| 64 69 72 65 63 74 6f 72 | 79 20 6e 61 6d 65 64 20 |director|y named |
|00003890| 62 79 0a 58 2e 49 20 64 | 69 72 6e 61 6d 65 0a 58 |by.X.I d|irname.X|
|000038a0| 61 6e 64 20 61 20 75 6e | 69 71 75 65 20 6f 62 6a |and a un|ique obj|
|000038b0| 65 63 74 20 6f 66 20 74 | 79 70 65 0a 58 2e 53 4d |ect of t|ype.X.SM|
|000038c0| 20 44 49 52 0a 58 6b 6e | 6f 77 6e 20 61 73 20 61 | DIR.Xkn|own as a|
|000038d0| 0a 58 2e 49 20 22 64 69 | 72 65 63 74 6f 72 79 20 |.X.I "di|rectory |
|000038e0| 73 74 72 65 61 6d 22 0a | 58 74 68 61 74 20 69 74 |stream".|Xthat it|
|000038f0| 20 63 72 65 61 74 65 73 | 2e 0a 58 2e 49 20 4f 70 | creates|..X.I Op|
|00003900| 65 6e 64 69 72 0a 58 72 | 65 74 75 72 6e 73 20 61 |endir.Xr|eturns a|
|00003910| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 62 65 20 75 | pointer| to be u|
|00003920| 73 65 64 20 74 6f 20 69 | 64 65 6e 74 69 66 79 20 |sed to i|dentify |
|00003930| 74 68 65 0a 58 64 69 72 | 65 63 74 6f 72 79 20 73 |the.Xdir|ectory s|
|00003940| 74 72 65 61 6d 0a 58 69 | 6e 20 73 75 62 73 65 71 |tream.Xi|n subseq|
|00003950| 75 65 6e 74 20 6f 70 65 | 72 61 74 69 6f 6e 73 2e |uent ope|rations.|
|00003960| 0a 58 41 0a 58 2e 53 4d | 20 4e 55 4c 4c 0a 58 70 |.XA.X.SM| NULL.Xp|
|00003970| 6f 69 6e 74 65 72 20 69 | 73 20 72 65 74 75 72 6e |ointer i|s return|
|00003980| 65 64 20 69 66 0a 58 2e | 49 20 64 69 72 6e 61 6d |ed if.X.|I dirnam|
|00003990| 65 0a 58 63 61 6e 6e 6f | 74 20 62 65 20 61 63 63 |e.Xcanno|t be acc|
|000039a0| 65 73 73 65 64 20 6f 72 | 20 69 73 20 6e 6f 74 20 |essed or| is not |
|000039b0| 61 20 64 69 72 65 63 74 | 6f 72 79 2c 0a 58 6f 72 |a direct|ory,.Xor|
|000039c0| 20 69 66 0a 58 2e 49 20 | 6f 70 65 6e 64 69 72 0a | if.X.I |opendir.|
|000039d0| 58 69 73 20 75 6e 61 62 | 6c 65 20 74 6f 20 63 72 |Xis unab|le to cr|
|000039e0| 65 61 74 65 20 74 68 65 | 0a 58 2e 53 4d 20 44 49 |eate the|.X.SM DI|
|000039f0| 52 0a 58 6f 62 6a 65 63 | 74 0a 58 28 70 65 72 68 |R.Xobjec|t.X(perh|
|00003a00| 61 70 73 20 64 75 65 20 | 74 6f 20 69 6e 73 75 66 |aps due |to insuf|
|00003a10| 66 69 63 69 65 6e 74 20 | 6d 65 6d 6f 72 79 29 2e |ficient |memory).|
|00003a20| 0a 58 2e 50 0a 58 2e 49 | 20 52 65 61 64 64 69 72 |.X.P.X.I| Readdir|
|00003a30| 0a 58 72 65 74 75 72 6e | 73 20 61 20 70 6f 69 6e |.Xreturn|s a poin|
|00003a40| 74 65 72 20 74 6f 20 61 | 6e 20 69 6e 74 65 72 6e |ter to a|n intern|
|00003a50| 61 6c 20 73 74 72 75 63 | 74 75 72 65 0a 58 63 6f |al struc|ture.Xco|
|00003a60| 6e 74 61 69 6e 69 6e 67 | 20 69 6e 66 6f 72 6d 61 |ntaining| informa|
|00003a70| 74 69 6f 6e 20 61 62 6f | 75 74 20 74 68 65 20 6e |tion abo|ut the n|
|00003a80| 65 78 74 20 61 63 74 69 | 76 65 20 64 69 72 65 63 |ext acti|ve direc|
|00003a90| 74 6f 72 79 20 65 6e 74 | 72 79 2e 0a 58 4e 6f 20 |tory ent|ry..XNo |
|00003aa0| 69 6e 61 63 74 69 76 65 | 20 65 6e 74 72 69 65 73 |inactive| entries|
|00003ab0| 20 61 72 65 20 72 65 70 | 6f 72 74 65 64 2e 0a 58 | are rep|orted..X|
|00003ac0| 54 68 65 20 69 6e 74 65 | 72 6e 61 6c 20 73 74 72 |The inte|rnal str|
|00003ad0| 75 63 74 75 72 65 20 6d | 61 79 20 62 65 20 6f 76 |ucture m|ay be ov|
|00003ae0| 65 72 77 72 69 74 74 65 | 6e 20 62 79 0a 58 61 6e |erwritte|n by.Xan|
|00003af0| 6f 74 68 65 72 20 6f 70 | 65 72 61 74 69 6f 6e 20 |other op|eration |
|00003b00| 6f 6e 20 74 68 65 20 73 | 61 6d 65 0a 58 64 69 72 |on the s|ame.Xdir|
|00003b10| 65 63 74 6f 72 79 20 73 | 74 72 65 61 6d 3b 0a 58 |ectory s|tream;.X|
|00003b20| 74 68 65 20 61 6d 6f 75 | 6e 74 20 6f 66 20 73 74 |the amou|nt of st|
|00003b30| 6f 72 61 67 65 20 6e 65 | 65 64 65 64 20 74 6f 20 |orage ne|eded to |
|00003b40| 68 6f 6c 64 20 61 20 63 | 6f 70 79 0a 58 6f 66 20 |hold a c|opy.Xof |
|00003b50| 74 68 65 20 69 6e 74 65 | 72 6e 61 6c 20 73 74 72 |the inte|rnal str|
|00003b60| 75 63 74 75 72 65 20 69 | 73 20 67 69 76 65 6e 20 |ucture i|s given |
|00003b70| 62 79 20 74 68 65 20 76 | 61 6c 75 65 20 6f 66 20 |by the v|alue of |
|00003b80| 61 20 6d 61 63 72 6f 2c | 0a 58 2e 49 52 20 44 49 |a macro,|.X.IR DI|
|00003b90| 52 45 4e 54 53 49 5a 28 | 73 74 72 6c 65 6e 28 64 |RENTSIZ(|strlen(d|
|00003ba0| 69 72 65 6e 74 70 5c 2d | 3e 64 5f 6e 61 6d 65 29 |irentp\-|>d_name)|
|00003bb0| 29 20 2c 0a 58 6e 6f 74 | 20 62 79 0a 58 2e 49 20 |) ,.Xnot| by.X.I |
|00003bc0| 22 73 69 7a 65 6f 66 28 | 73 74 72 75 63 74 5c 20 |"sizeof(|struct\ |
|00003bd0| 64 69 72 65 6e 74 29 22 | 0a 58 61 73 20 6f 6e 65 |dirent)"|.Xas one|
|00003be0| 20 6d 69 67 68 74 20 65 | 78 70 65 63 74 2e 0a 58 | might e|xpect..X|
|00003bf0| 41 0a 58 2e 53 4d 20 4e | 55 4c 4c 0a 58 70 6f 69 |A.X.SM N|ULL.Xpoi|
|00003c00| 6e 74 65 72 20 69 73 20 | 72 65 74 75 72 6e 65 64 |nter is |returned|
|00003c10| 0a 58 75 70 6f 6e 20 72 | 65 61 63 68 69 6e 67 20 |.Xupon r|eaching |
|00003c20| 74 68 65 20 65 6e 64 20 | 6f 66 20 74 68 65 20 64 |the end |of the d|
|00003c30| 69 72 65 63 74 6f 72 79 | 2c 0a 58 75 70 6f 6e 20 |irectory|,.Xupon |
|00003c40| 64 65 74 65 63 74 69 6e | 67 20 61 6e 20 69 6e 76 |detectin|g an inv|
|00003c50| 61 6c 69 64 20 6c 6f 63 | 61 74 69 6f 6e 20 69 6e |alid loc|ation in|
|00003c60| 20 74 68 65 20 64 69 72 | 65 63 74 6f 72 79 2c 0a | the dir|ectory,.|
|00003c70| 58 6f 72 20 75 70 6f 6e | 20 6f 63 63 75 72 72 65 |Xor upon| occurre|
|00003c80| 6e 63 65 20 6f 66 20 61 | 6e 20 65 72 72 6f 72 20 |nce of a|n error |
|00003c90| 77 68 69 6c 65 20 72 65 | 61 64 69 6e 67 20 74 68 |while re|ading th|
|00003ca0| 65 20 64 69 72 65 63 74 | 6f 72 79 2e 0a 58 2e 50 |e direct|ory..X.P|
|00003cb0| 0a 58 2e 49 20 54 65 6c | 6c 64 69 72 0a 58 72 65 |.X.I Tel|ldir.Xre|
|00003cc0| 74 75 72 6e 73 20 74 68 | 65 20 63 75 72 72 65 6e |turns th|e curren|
|00003cd0| 74 20 70 6f 73 69 74 69 | 6f 6e 20 61 73 73 6f 63 |t positi|on assoc|
|00003ce0| 69 61 74 65 64 20 77 69 | 74 68 20 74 68 65 20 6e |iated wi|th the n|
|00003cf0| 61 6d 65 64 0a 58 64 69 | 72 65 63 74 6f 72 79 20 |amed.Xdi|rectory |
|00003d00| 73 74 72 65 61 6d 0a 58 | 66 6f 72 20 6c 61 74 65 |stream.X|for late|
|00003d10| 72 20 75 73 65 20 61 73 | 20 61 6e 20 61 72 67 75 |r use as| an argu|
|00003d20| 6d 65 6e 74 20 74 6f 0a | 58 2e 49 52 20 73 65 65 |ment to.|X.IR see|
|00003d30| 6b 64 69 72 20 2e 0a 58 | 2e 50 0a 58 2e 49 20 53 |kdir ..X|.P.X.I S|
|00003d40| 65 65 6b 64 69 72 0a 58 | 73 65 74 73 20 74 68 65 |eekdir.X|sets the|
|00003d50| 20 70 6f 73 69 74 69 6f | 6e 20 6f 66 20 74 68 65 | positio|n of the|
|00003d60| 20 6e 65 78 74 0a 58 2e | 49 20 72 65 61 64 64 69 | next.X.|I readdi|
|00003d70| 72 0a 58 6f 70 65 72 61 | 74 69 6f 6e 20 6f 6e 20 |r.Xopera|tion on |
|00003d80| 74 68 65 20 6e 61 6d 65 | 64 0a 58 64 69 72 65 63 |the name|d.Xdirec|
|00003d90| 74 6f 72 79 20 73 74 72 | 65 61 6d 2e 0a 58 54 68 |tory str|eam..XTh|
|00003da0| 65 20 6e 65 77 20 70 6f | 73 69 74 69 6f 6e 20 72 |e new po|sition r|
|00003db0| 65 76 65 72 74 73 20 74 | 6f 20 74 68 65 20 6f 6e |everts t|o the on|
|00003dc0| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 77 69 74 |e associ|ated wit|
|00003dd0| 68 20 74 68 65 0a 58 64 | 69 72 65 63 74 6f 72 79 |h the.Xd|irectory|
|00003de0| 20 73 74 72 65 61 6d 0a | 58 77 68 65 6e 20 74 68 | stream.|Xwhen th|
|00003df0| 65 0a 58 2e 49 20 74 65 | 6c 6c 64 69 72 0a 58 6f |e.X.I te|lldir.Xo|
|00003e00| 70 65 72 61 74 69 6f 6e | 20 66 72 6f 6d 20 77 68 |peration| from wh|
|00003e10| 69 63 68 0a 58 2e 49 20 | 6c 6f 63 0a 58 77 61 73 |ich.X.I |loc.Xwas|
|00003e20| 20 6f 62 74 61 69 6e 65 | 64 20 77 61 73 20 70 65 | obtaine|d was pe|
|00003e30| 72 66 6f 72 6d 65 64 2e | 0a 58 2e 50 0a 58 2e 49 |rformed.|.X.P.X.I|
|00003e40| 20 52 65 77 69 6e 64 64 | 69 72 0a 58 72 65 73 65 | Rewindd|ir.Xrese|
|00003e50| 74 73 20 74 68 65 20 70 | 6f 73 69 74 69 6f 6e 20 |ts the p|osition |
|00003e60| 6f 66 20 74 68 65 20 6e | 61 6d 65 64 0a 58 64 69 |of the n|amed.Xdi|
|00003e70| 72 65 63 74 6f 72 79 20 | 73 74 72 65 61 6d 0a 58 |rectory |stream.X|
|00003e80| 74 6f 20 74 68 65 20 62 | 65 67 69 6e 6e 69 6e 67 |to the b|eginning|
|00003e90| 20 6f 66 20 74 68 65 20 | 64 69 72 65 63 74 6f 72 | of the |director|
|00003ea0| 79 2e 0a 58 41 6c 6c 20 | 62 75 66 66 65 72 65 64 |y..XAll |buffered|
|00003eb0| 20 64 61 74 61 20 66 6f | 72 20 74 68 65 20 64 69 | data fo|r the di|
|00003ec0| 72 65 63 74 6f 72 79 20 | 73 74 72 65 61 6d 20 69 |rectory |stream i|
|00003ed0| 73 20 64 69 73 63 61 72 | 64 65 64 2c 0a 58 74 68 |s discar|ded,.Xth|
|00003ee0| 65 72 65 62 79 20 67 75 | 61 72 61 6e 74 65 65 69 |ereby gu|aranteei|
|00003ef0| 6e 67 20 74 68 61 74 20 | 74 68 65 20 61 63 74 75 |ng that |the actu|
|00003f00| 61 6c 0a 58 66 69 6c 65 | 20 73 79 73 74 65 6d 20 |al.Xfile| system |
|00003f10| 64 69 72 65 63 74 6f 72 | 79 20 77 69 6c 6c 20 62 |director|y will b|
|00003f20| 65 20 72 65 66 65 72 72 | 65 64 20 74 6f 20 66 6f |e referr|ed to fo|
|00003f30| 72 20 74 68 65 20 6e 65 | 78 74 0a 58 2e 49 20 72 |r the ne|xt.X.I r|
|00003f40| 65 61 64 64 69 72 0a 58 | 6f 6e 20 74 68 65 0a 58 |eaddir.X|on the.X|
|00003f50| 64 69 72 65 63 74 6f 72 | 79 20 73 74 72 65 61 6d |director|y stream|
|00003f60| 2e 0a 58 2e 50 0a 58 2e | 49 20 43 6c 6f 73 65 64 |..X.P.X.|I Closed|
|00003f70| 69 72 0a 58 63 6c 6f 73 | 65 73 20 74 68 65 20 6e |ir.Xclos|es the n|
|00003f80| 61 6d 65 64 0a 58 64 69 | 72 65 63 74 6f 72 79 20 |amed.Xdi|rectory |
|00003f90| 73 74 72 65 61 6d 3b 0a | 58 69 6e 74 65 72 6e 61 |stream;.|Xinterna|
|00003fa0| 6c 20 72 65 73 6f 75 72 | 63 65 73 20 75 73 65 64 |l resour|ces used|
|00003fb0| 20 66 6f 72 20 74 68 65 | 0a 58 64 69 72 65 63 74 | for the|.Xdirect|
|00003fc0| 6f 72 79 20 73 74 72 65 | 61 6d 20 61 72 65 20 6c |ory stre|am are l|
|00003fd0| 69 62 65 72 61 74 65 64 | 2c 0a 58 61 6e 64 20 73 |iberated|,.Xand s|
|00003fe0| 75 62 73 65 71 75 65 6e | 74 20 75 73 65 20 6f 66 |ubsequen|t use of|
|00003ff0| 20 74 68 65 20 61 73 73 | 6f 63 69 61 74 65 64 0a | the ass|ociated.|
|00004000| 58 2e 53 4d 20 44 49 52 | 0a 58 6f 62 6a 65 63 74 |X.SM DIR|.Xobject|
|00004010| 20 69 73 20 6e 6f 20 6c | 6f 6e 67 65 72 20 76 61 | is no l|onger va|
|00004020| 6c 69 64 2e 0a 58 2e 49 | 20 43 6c 6f 73 65 64 69 |lid..X.I| Closedi|
|00004030| 72 0a 58 72 65 74 75 72 | 6e 73 20 61 20 76 61 6c |r.Xretur|ns a val|
|00004040| 75 65 20 6f 66 20 7a 65 | 72 6f 20 69 66 20 6e 6f |ue of ze|ro if no|
|00004050| 20 65 72 72 6f 72 20 6f | 63 63 75 72 73 2c 0a 58 | error o|ccurs,.X|
|00004060| 5c 2d 31 20 6f 74 68 65 | 72 77 69 73 65 2e 0a 58 |\-1 othe|rwise..X|
|00004070| 2e 50 0a 58 54 68 65 72 | 65 20 61 72 65 20 73 65 |.P.XTher|e are se|
|00004080| 76 65 72 61 6c 20 70 6f | 73 73 69 62 6c 65 20 65 |veral po|ssible e|
|00004090| 72 72 6f 72 73 20 74 68 | 61 74 20 63 61 6e 20 6f |rrors th|at can o|
|000040a0| 63 63 75 72 0a 58 61 73 | 20 61 20 72 65 73 75 6c |ccur.Xas| a resul|
|000040b0| 74 20 6f 66 20 74 68 65 | 73 65 20 6f 70 65 72 61 |t of the|se opera|
|000040c0| 74 69 6f 6e 73 3b 0a 58 | 74 68 65 20 65 78 74 65 |tions;.X|the exte|
|000040d0| 72 6e 61 6c 20 69 6e 74 | 65 67 65 72 20 76 61 72 |rnal int|eger var|
|000040e0| 69 61 62 6c 65 0a 58 2e | 49 20 65 72 72 6e 6f 0a |iable.X.|I errno.|
|000040f0| 58 69 73 20 73 65 74 20 | 74 6f 20 69 6e 64 69 63 |Xis set |to indic|
|00004100| 61 74 65 20 74 68 65 20 | 73 70 65 63 69 66 69 63 |ate the |specific|
|00004110| 20 65 72 72 6f 72 2e 0a | 58 2e 52 49 20 28 20 52 | error..|X.RI ( R|
|00004120| 65 61 64 64 69 72 20 27 | 73 0a 58 64 65 74 65 63 |eaddir '|s.Xdetec|
|00004130| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 6e 6f 72 6d |tion of |the norm|
|00004140| 61 6c 20 65 6e 64 20 6f | 66 20 61 20 64 69 72 65 |al end o|f a dire|
|00004150| 63 74 6f 72 79 0a 58 69 | 73 20 6e 6f 74 20 63 6f |ctory.Xi|s not co|
|00004160| 6e 73 69 64 65 72 65 64 | 20 74 6f 20 62 65 20 61 |nsidered| to be a|
|00004170| 6e 20 65 72 72 6f 72 2e | 29 0a 58 2e 53 48 20 45 |n error.|).X.SH E|
|00004180| 58 41 4d 50 4c 45 0a 58 | 53 61 6d 70 6c 65 20 63 |XAMPLE.X|Sample c|
|00004190| 6f 64 65 20 77 68 69 63 | 68 20 73 65 61 72 63 68 |ode whic|h search|
|000041a0| 65 73 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 77 |es the c|urrent w|
|000041b0| 6f 72 6b 69 6e 67 20 64 | 69 72 65 63 74 6f 72 79 |orking d|irectory|
|000041c0| 20 66 6f 72 20 65 6e 74 | 72 79 0a 58 2e 49 52 20 | for ent|ry.X.IR |
|000041d0| 6e 61 6d 65 20 3a 0a 58 | 2e 50 0a 58 2e 66 74 20 |name :.X|.P.X.ft |
|000041e0| 42 0a 58 09 64 69 72 70 | 20 3d 20 6f 70 65 6e 64 |B.X.dirp| = opend|
|000041f0| 69 72 28 20 22 2e 22 20 | 29 3b 0a 58 2e 62 72 0a |ir( "." |);.X.br.|
|00004200| 58 09 77 68 69 6c 65 20 | 28 20 28 64 70 20 3d 20 |X.while |( (dp = |
|00004210| 72 65 61 64 64 69 72 28 | 20 64 69 72 70 20 29 29 |readdir(| dirp ))|
|00004220| 20 21 3d 20 4e 55 4c 4c | 20 29 0a 58 2e 62 72 0a | != NULL| ).X.br.|
|00004230| 58 09 09 69 66 20 28 20 | 73 74 72 63 6d 70 28 20 |X..if ( |strcmp( |
|00004240| 64 70 5c 2d 3e 64 5f 6e | 61 6d 65 2c 20 6e 61 6d |dp\->d_n|ame, nam|
|00004250| 65 20 29 20 3d 3d 20 30 | 20 29 0a 58 2e 62 72 0a |e ) == 0| ).X.br.|
|00004260| 58 09 09 09 7b 0a 58 2e | 62 72 0a 58 09 09 09 28 |X...{.X.|br.X...(|
|00004270| 76 6f 69 64 29 20 63 6c | 6f 73 65 64 69 72 28 20 |void) cl|osedir( |
|00004280| 64 69 72 70 20 29 3b 0a | 58 2e 62 72 0a 58 09 09 |dirp );.|X.br.X..|
|00004290| 09 72 65 74 75 72 6e 20 | 46 4f 55 4e 44 3b 0a 58 |.return |FOUND;.X|
|000042a0| 2e 62 72 0a 58 09 09 09 | 7d 0a 58 2e 62 72 0a 58 |.br.X...|}.X.br.X|
|000042b0| 09 28 76 6f 69 64 29 20 | 63 6c 6f 73 65 64 69 72 |.(void) |closedir|
|000042c0| 28 20 64 69 72 70 20 29 | 3b 0a 58 2e 62 72 0a 58 |( dirp )|;.X.br.X|
|000042d0| 09 72 65 74 75 72 6e 20 | 4e 4f 54 5f 46 4f 55 4e |.return |NOT_FOUN|
|000042e0| 44 3b 0a 58 2e 66 74 20 | 50 0a 58 2e 53 48 20 22 |D;.X.ft |P.X.SH "|
|000042f0| 53 45 45 20 41 4c 53 4f | 22 0a 58 67 65 74 64 65 |SEE ALSO|".Xgetde|
|00004300| 6e 74 73 28 32 29 2c 20 | 64 69 72 65 6e 74 28 34 |nts(2), |dirent(4|
|00004310| 29 2e 0a 58 2e 53 48 20 | 57 41 52 4e 49 4e 47 53 |)..X.SH |WARNINGS|
|00004320| 0a 58 45 6e 74 72 69 65 | 73 20 66 6f 72 20 22 2e |.XEntrie|s for ".|
|00004330| 22 20 61 6e 64 20 22 2e | 2e 22 0a 58 6d 61 79 20 |" and ".|.".Xmay |
|00004340| 6e 6f 74 20 62 65 20 72 | 65 70 6f 72 74 65 64 20 |not be r|eported |
|00004350| 66 6f 72 20 73 6f 6d 65 | 20 66 69 6c 65 20 73 79 |for some| file sy|
|00004360| 73 74 65 6d 20 74 79 70 | 65 73 2e 0a 58 2e 50 0a |stem typ|es..X.P.|
|00004370| 58 54 68 65 20 76 61 6c | 75 65 20 72 65 74 75 72 |XThe val|ue retur|
|00004380| 6e 65 64 20 62 79 0a 58 | 2e 49 20 74 65 6c 6c 64 |ned by.X|.I telld|
|00004390| 69 72 0a 58 6e 65 65 64 | 20 6e 6f 74 20 68 61 76 |ir.Xneed| not hav|
|000043a0| 65 20 61 6e 79 20 73 69 | 6d 70 6c 65 20 69 6e 74 |e any si|mple int|
|000043b0| 65 72 70 72 65 74 61 74 | 69 6f 6e 0a 58 61 6e 64 |erpretat|ion.Xand|
|000043c0| 20 73 68 6f 75 6c 64 20 | 6f 6e 6c 79 20 62 65 20 | should |only be |
|000043d0| 75 73 65 64 20 61 73 20 | 61 6e 20 61 72 67 75 6d |used as |an argum|
|000043e0| 65 6e 74 20 74 6f 0a 58 | 2e 49 52 20 73 65 65 6b |ent to.X|.IR seek|
|000043f0| 64 69 72 20 2e 0a 58 53 | 69 6d 69 6c 61 72 6c 79 |dir ..XS|imilarly|
|00004400| 2c 0a 58 74 68 65 0a 58 | 2e 49 20 6c 6f 63 0a 58 |,.Xthe.X|.I loc.X|
|00004410| 61 72 67 75 6d 65 6e 74 | 20 74 6f 0a 58 2e 49 20 |argument| to.X.I |
|00004420| 73 65 65 6b 64 69 72 0a | 58 6d 75 73 74 20 62 65 |seekdir.|Xmust be|
|00004430| 20 6f 62 74 61 69 6e 65 | 64 20 66 72 6f 6d 20 61 | obtaine|d from a|
|00004440| 20 70 72 65 76 69 6f 75 | 73 0a 58 2e 49 20 74 65 | previou|s.X.I te|
|00004450| 6c 6c 64 69 72 0a 58 6f | 70 65 72 61 74 69 6f 6e |lldir.Xo|peration|
|00004460| 20 6f 6e 20 74 68 65 20 | 73 61 6d 65 0a 58 64 69 | on the |same.Xdi|
|00004470| 72 65 63 74 6f 72 79 20 | 73 74 72 65 61 6d 2e 0a |rectory |stream..|
|00004480| 58 2e 50 0a 58 2e 49 20 | 54 65 6c 6c 64 69 72 0a |X.P.X.I |Telldir.|
|00004490| 58 61 6e 64 0a 58 2e 49 | 20 73 65 65 6b 64 69 72 |Xand.X.I| seekdir|
|000044a0| 0a 58 61 72 65 20 75 6e | 72 65 6c 69 61 62 6c 65 |.Xare un|reliable|
|000044b0| 20 77 68 65 6e 20 75 73 | 65 64 20 69 6e 20 63 6f | when us|ed in co|
|000044c0| 6e 6a 75 6e 63 74 69 6f | 6e 20 77 69 74 68 0a 58 |njunctio|n with.X|
|000044d0| 66 69 6c 65 20 73 79 73 | 74 65 6d 73 20 74 68 61 |file sys|tems tha|
|000044e0| 74 20 70 65 72 66 6f 72 | 6d 20 64 69 72 65 63 74 |t perfor|m direct|
|000044f0| 6f 72 79 20 63 6f 6d 70 | 61 63 74 69 6f 6e 20 6f |ory comp|action o|
|00004500| 72 20 65 78 70 61 6e 73 | 69 6f 6e 0a 58 6f 72 20 |r expans|ion.Xor |
|00004510| 77 68 65 6e 20 74 68 65 | 20 64 69 72 65 63 74 6f |when the| directo|
|00004520| 72 79 20 73 74 72 65 61 | 6d 20 68 61 73 20 62 65 |ry strea|m has be|
|00004530| 65 6e 20 63 6c 6f 73 65 | 64 20 61 6e 64 20 72 65 |en close|d and re|
|00004540| 6f 70 65 6e 65 64 2e 0a | 58 49 74 20 69 73 20 62 |opened..|XIt is b|
|00004550| 65 73 74 20 74 6f 20 61 | 76 6f 69 64 20 75 73 69 |est to a|void usi|
|00004560| 6e 67 0a 58 2e 49 20 74 | 65 6c 6c 64 69 72 0a 58 |ng.X.I t|elldir.X|
|00004570| 61 6e 64 0a 58 2e 49 20 | 73 65 65 6b 64 69 72 0a |and.X.I |seekdir.|
|00004580| 58 61 6c 74 6f 67 65 74 | 68 65 72 2e 0a 58 2e 50 |Xaltoget|her..X.P|
|00004590| 0a 58 54 68 65 20 65 78 | 61 63 74 20 73 65 74 20 |.XThe ex|act set |
|000045a0| 6f 66 0a 58 2e 49 20 65 | 72 72 6e 6f 0a 58 76 61 |of.X.I e|rrno.Xva|
|000045b0| 6c 75 65 73 20 61 6e 64 | 20 6d 65 61 6e 69 6e 67 |lues and| meaning|
|000045c0| 73 20 6d 61 79 20 76 61 | 72 79 20 61 6d 6f 6e 67 |s may va|ry among|
|000045d0| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 73 | impleme|ntations|
|000045e0| 2e 0a 58 2e 50 0a 58 42 | 65 63 61 75 73 65 20 64 |..X.P.XB|ecause d|
|000045f0| 69 72 65 63 74 6f 72 79 | 20 65 6e 74 72 69 65 73 |irectory| entries|
|00004600| 20 63 61 6e 20 64 79 6e | 61 6d 69 63 61 6c 6c 79 | can dyn|amically|
|00004610| 0a 58 61 70 70 65 61 72 | 20 61 6e 64 20 64 69 73 |.Xappear| and dis|
|00004620| 61 70 70 65 61 72 2c 0a | 58 61 6e 64 20 62 65 63 |appear,.|Xand bec|
|00004630| 61 75 73 65 20 64 69 72 | 65 63 74 6f 72 79 20 63 |ause dir|ectory c|
|00004640| 6f 6e 74 65 6e 74 73 20 | 61 72 65 20 62 75 66 66 |ontents |are buff|
|00004650| 65 72 65 64 0a 58 62 79 | 20 74 68 65 73 65 20 72 |ered.Xby| these r|
|00004660| 6f 75 74 69 6e 65 73 2c | 0a 58 61 6e 20 61 70 70 |outines,|.Xan app|
|00004670| 6c 69 63 61 74 69 6f 6e | 20 6d 61 79 20 6e 65 65 |lication| may nee|
|00004680| 64 20 74 6f 20 63 6f 6e | 74 69 6e 75 61 6c 6c 79 |d to con|tinually|
|00004690| 20 72 65 73 63 61 6e 0a | 58 61 20 64 69 72 65 63 | rescan.|Xa direc|
|000046a0| 74 6f 72 79 20 74 6f 20 | 6d 61 69 6e 74 61 69 6e |tory to |maintain|
|000046b0| 20 61 6e 20 61 63 63 75 | 72 61 74 65 20 70 69 63 | an accu|rate pic|
|000046c0| 74 75 72 65 0a 58 6f 66 | 20 69 74 73 20 61 63 74 |ture.Xof| its act|
|000046d0| 69 76 65 20 65 6e 74 72 | 69 65 73 2e 0a 45 4e 44 |ive entr|ies..END|
|000046e0| 5f 4f 46 5f 64 69 72 65 | 63 74 6f 72 79 2e 33 63 |_OF_dire|ctory.3c|
|000046f0| 0a 69 66 20 74 65 73 74 | 20 34 31 33 36 20 2d 6e |.if test| 4136 -n|
|00004700| 65 20 60 77 63 20 2d 63 | 20 3c 64 69 72 65 63 74 |e `wc -c| <direct|
|00004710| 6f 72 79 2e 33 63 60 3b | 20 74 68 65 6e 0a 20 20 |ory.3c`;| then. |
|00004720| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 5c 22 64 | echo s|har: \"d|
|00004730| 69 72 65 63 74 6f 72 79 | 2e 33 63 5c 22 20 75 6e |irectory|.3c\" un|
|00004740| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00004750| 67 20 73 69 7a 65 21 3f | 0a 66 69 0a 23 20 65 6e |g size!?|.fi.# en|
|00004760| 64 20 6f 66 20 6f 76 65 | 72 77 72 69 74 69 6e 67 |d of ove|rwriting|
|00004770| 20 63 68 65 63 6b 0a 66 | 69 0a 65 63 68 6f 20 73 | check.f|i.echo s|
|00004780| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|00004790| 5c 22 64 69 72 65 6e 74 | 2e 34 5c 22 20 5c 28 31 |\"dirent|.4\" \(1|
|000047a0| 35 39 33 20 63 68 61 72 | 61 63 74 65 72 73 5c 29 |593 char|acters\)|
|000047b0| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 64 69 72 65 |.if test| -f dire|
|000047c0| 6e 74 2e 34 20 3b 20 74 | 68 65 6e 20 0a 20 20 65 |nt.4 ; t|hen . e|
|000047d0| 63 68 6f 20 73 68 61 72 | 3a 20 57 69 6c 6c 20 6e |cho shar|: Will n|
|000047e0| 6f 74 20 6f 76 65 72 2d | 77 72 69 74 65 20 65 78 |ot over-|write ex|
|000047f0| 69 73 74 69 6e 67 20 66 | 69 6c 65 20 5c 22 64 69 |isting f|ile \"di|
|00004800| 72 65 6e 74 2e 34 5c 22 | 0a 65 6c 73 65 0a 73 65 |rent.4\"|.else.se|
|00004810| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 64 69 72 65 |d "s/^X/|/" >dire|
|00004820| 6e 74 2e 34 20 3c 3c 27 | 45 4e 44 5f 4f 46 5f 64 |nt.4 <<'|END_OF_d|
|00004830| 69 72 65 6e 74 2e 34 27 | 0a 58 2e 54 48 20 44 49 |irent.4'|.X.TH DI|
|00004840| 52 45 4e 54 20 34 20 22 | 53 74 61 6e 64 61 72 64 |RENT 4 "|Standard|
|00004850| 20 45 78 74 65 6e 73 69 | 6f 6e 22 0a 58 2e 53 48 | Extensi|on".X.SH|
|00004860| 20 4e 41 4d 45 0a 58 64 | 69 72 65 6e 74 20 5c 2d | NAME.Xd|irent \-|
|00004870| 20 66 69 6c 65 20 73 79 | 73 74 65 6d 20 69 6e 64 | file sy|stem ind|
|00004880| 65 70 65 6e 64 65 6e 74 | 20 64 69 72 65 63 74 6f |ependent| directo|
|00004890| 72 79 20 65 6e 74 72 79 | 0a 58 2e 53 48 20 53 59 |ry entry|.X.SH SY|
|000048a0| 4e 4f 50 53 49 53 0a 58 | 2e 42 20 22 23 69 6e 63 |NOPSIS.X|.B "#inc|
|000048b0| 6c 75 64 65 20 3c 73 79 | 73 2f 74 79 70 65 73 2e |lude <sy|s/types.|
|000048c0| 68 3e 22 0a 58 2e 62 72 | 0a 58 2e 42 20 22 23 69 |h>".X.br|.X.B "#i|
|000048d0| 6e 63 6c 75 64 65 20 3c | 73 79 73 2f 64 69 72 65 |nclude <|sys/dire|
|000048e0| 6e 74 2e 68 3e 22 0a 58 | 2e 53 48 20 44 45 53 43 |nt.h>".X|.SH DESC|
|000048f0| 52 49 50 54 49 4f 4e 0a | 58 44 69 66 66 65 72 65 |RIPTION.|XDiffere|
|00004900| 6e 74 20 66 69 6c 65 20 | 73 79 73 74 65 6d 20 74 |nt file |system t|
|00004910| 79 70 65 73 0a 58 6d 61 | 79 20 68 61 76 65 20 64 |ypes.Xma|y have d|
|00004920| 69 66 66 65 72 65 6e 74 | 20 64 69 72 65 63 74 6f |ifferent| directo|
|00004930| 72 79 20 65 6e 74 72 69 | 65 73 2e 0a 58 54 68 65 |ry entri|es..XThe|
|00004940| 0a 58 2e 49 20 64 69 72 | 65 6e 74 0a 58 73 74 72 |.X.I dir|ent.Xstr|
|00004950| 75 63 74 75 72 65 20 64 | 65 66 69 6e 65 73 20 61 |ucture d|efines a|
|00004960| 0a 58 66 69 6c 65 20 73 | 79 73 74 65 6d 20 69 6e |.Xfile s|ystem in|
|00004970| 64 65 70 65 6e 64 65 6e | 74 20 64 69 72 65 63 74 |dependen|t direct|
|00004980| 6f 72 79 20 65 6e 74 72 | 79 2c 0a 58 77 68 69 63 |ory entr|y,.Xwhic|
|00004990| 68 20 63 6f 6e 74 61 69 | 6e 73 20 69 6e 66 6f 72 |h contai|ns infor|
|000049a0| 6d 61 74 69 6f 6e 20 63 | 6f 6d 6d 6f 6e 20 74 6f |mation c|ommon to|
|000049b0| 0a 58 64 69 72 65 63 74 | 6f 72 79 20 65 6e 74 72 |.Xdirect|ory entr|
|000049c0| 69 65 73 20 69 6e 20 64 | 69 66 66 65 72 65 6e 74 |ies in d|ifferent|
|000049d0| 20 66 69 6c 65 20 73 79 | 73 74 65 6d 20 74 79 70 | file sy|stem typ|
|000049e0| 65 73 2e 0a 58 41 20 73 | 65 74 20 6f 66 20 74 68 |es..XA s|et of th|
|000049f0| 65 73 65 20 73 74 72 75 | 63 74 75 72 65 73 20 69 |ese stru|ctures i|
|00004a00| 73 20 72 65 74 75 72 6e | 65 64 20 62 79 20 74 68 |s return|ed by th|
|00004a10| 65 0a 58 2e 49 52 20 67 | 65 74 64 65 6e 74 73 20 |e.X.IR g|etdents |
|00004a20| 28 32 29 0a 58 73 79 73 | 74 65 6d 20 63 61 6c 6c |(2).Xsys|tem call|
|00004a30| 2e 0a 58 2e 50 0a 58 54 | 68 65 0a 58 2e 49 20 64 |..X.P.XT|he.X.I d|
|00004a40| 69 72 65 6e 74 0a 58 73 | 74 72 75 63 74 75 72 65 |irent.Xs|tructure|
|00004a50| 20 69 73 20 64 65 66 69 | 6e 65 64 20 62 65 6c 6f | is defi|ned belo|
|00004a60| 77 2e 0a 58 2e 62 72 0a | 58 73 74 72 75 63 74 09 |w..X.br.|Xstruct.|
|00004a70| 64 69 72 65 6e 74 09 7b | 0a 58 2e 62 72 0a 58 09 |dirent.{|.X.br.X.|
|00004a80| 09 09 6c 6f 6e 67 09 09 | 09 64 5f 69 6e 6f 3b 0a |..long..|.d_ino;.|
|00004a90| 58 2e 62 72 0a 58 09 09 | 09 6f 66 66 5f 74 09 09 |X.br.X..|.off_t..|
|00004aa0| 09 64 5f 6f 66 66 3b 0a | 58 2e 62 72 0a 58 09 09 |.d_off;.|X.br.X..|
|00004ab0| 09 75 6e 73 69 67 6e 65 | 64 20 73 68 6f 72 74 09 |.unsigne|d short.|
|00004ac0| 09 64 5f 72 65 63 6c 65 | 6e 3b 0a 58 2e 62 72 0a |.d_recle|n;.X.br.|
|00004ad0| 58 09 09 09 63 68 61 72 | 09 09 09 64 5f 6e 61 6d |X...char|...d_nam|
|00004ae0| 65 5b 31 5d 3b 0a 58 2e | 62 72 0a 58 09 09 7d 3b |e[1];.X.|br.X..};|
|00004af0| 0a 58 2e 50 0a 58 54 68 | 65 20 66 69 65 6c 64 0a |.X.P.XTh|e field.|
|00004b00| 58 2e 49 20 64 5f 69 6e | 6f 0a 58 69 73 20 61 20 |X.I d_in|o.Xis a |
|00004b10| 6e 75 6d 62 65 72 20 77 | 68 69 63 68 20 69 73 20 |number w|hich is |
|00004b20| 75 6e 69 71 75 65 0a 58 | 66 6f 72 20 65 61 63 68 |unique.X|for each|
|00004b30| 20 66 69 6c 65 20 69 6e | 20 74 68 65 20 66 69 6c | file in| the fil|
|00004b40| 65 20 73 79 73 74 65 6d | 2e 0a 58 54 68 65 20 66 |e system|..XThe f|
|00004b50| 69 65 6c 64 0a 58 2e 49 | 20 64 5f 6f 66 66 5c 5e |ield.X.I| d_off\^|
|00004b60| 0a 58 72 65 70 72 65 73 | 65 6e 74 73 20 61 6e 20 |.Xrepres|ents an |
|00004b70| 6f 66 66 73 65 74 20 6f | 66 20 74 68 61 74 20 64 |offset o|f that d|
|00004b80| 69 72 65 63 74 6f 72 79 | 20 65 6e 74 72 79 0a 58 |irectory| entry.X|
|00004b90| 69 6e 20 74 68 65 20 61 | 63 74 75 61 6c 20 66 69 |in the a|ctual fi|
|00004ba0| 6c 65 20 73 79 73 74 65 | 6d 20 64 69 72 65 63 74 |le syste|m direct|
|00004bb0| 6f 72 79 2e 0a 58 54 68 | 65 20 66 69 65 6c 64 0a |ory..XTh|e field.|
|00004bc0| 58 2e 49 20 64 5f 6e 61 | 6d 65 0a 58 69 73 20 74 |X.I d_na|me.Xis t|
|00004bd0| 68 65 20 62 65 67 69 6e | 6e 69 6e 67 20 6f 66 20 |he begin|ning of |
|00004be0| 74 68 65 20 63 68 61 72 | 61 63 74 65 72 20 61 72 |the char|acter ar|
|00004bf0| 72 61 79 0a 58 67 69 76 | 69 6e 67 20 74 68 65 20 |ray.Xgiv|ing the |
|00004c00| 6e 61 6d 65 20 6f 66 20 | 74 68 65 20 64 69 72 65 |name of |the dire|
|00004c10| 63 74 6f 72 79 20 65 6e | 74 72 79 2e 0a 58 54 68 |ctory en|try..XTh|
|00004c20| 69 73 20 6e 61 6d 65 20 | 69 73 20 6e 75 6c 6c 20 |is name |is null |
|00004c30| 74 65 72 6d 69 6e 61 74 | 65 64 0a 58 61 6e 64 20 |terminat|ed.Xand |
|00004c40| 6d 61 79 20 68 61 76 65 | 20 61 74 20 6d 6f 73 74 |may have| at most|
|00004c50| 0a 58 2e 53 4d 20 4e 41 | 4d 45 5f 4d 41 58 0a 58 |.X.SM NA|ME_MAX.X|
|00004c60| 63 68 61 72 61 63 74 65 | 72 73 20 69 6e 20 61 64 |characte|rs in ad|
|00004c70| 64 69 74 69 6f 6e 20 74 | 6f 20 74 68 65 20 6e 75 |dition t|o the nu|
|00004c80| 6c 6c 20 74 65 72 6d 69 | 6e 61 74 6f 72 2e 0a 58 |ll termi|nator..X|
|00004c90| 54 68 69 73 20 72 65 73 | 75 6c 74 73 20 69 6e 20 |This res|ults in |
|00004ca0| 66 69 6c 65 20 73 79 73 | 74 65 6d 20 69 6e 64 65 |file sys|tem inde|
|00004cb0| 70 65 6e 64 65 6e 74 20 | 64 69 72 65 63 74 6f 72 |pendent |director|
|00004cc0| 79 20 65 6e 74 72 69 65 | 73 0a 58 62 65 69 6e 67 |y entrie|s.Xbeing|
|00004cd0| 20 76 61 72 69 61 62 6c | 65 2d 6c 65 6e 67 74 68 | variabl|e-length|
|00004ce0| 20 65 6e 74 69 74 69 65 | 73 2e 0a 58 54 68 65 20 | entitie|s..XThe |
|00004cf0| 76 61 6c 75 65 20 6f 66 | 0a 58 2e 49 20 64 5f 72 |value of|.X.I d_r|
|00004d00| 65 63 6c 65 6e 0a 58 69 | 73 20 74 68 65 20 72 65 |eclen.Xi|s the re|
|00004d10| 63 6f 72 64 20 6c 65 6e | 67 74 68 20 6f 66 20 74 |cord len|gth of t|
|00004d20| 68 69 73 20 65 6e 74 72 | 79 2e 0a 58 54 68 69 73 |his entr|y..XThis|
|00004d30| 20 6c 65 6e 67 74 68 20 | 69 73 20 64 65 66 69 6e | length |is defin|
|00004d40| 65 64 20 74 6f 20 62 65 | 20 74 68 65 20 6e 75 6d |ed to be| the num|
|00004d50| 62 65 72 20 6f 66 20 62 | 79 74 65 73 0a 58 62 65 |ber of b|ytes.Xbe|
|00004d60| 74 77 65 65 6e 20 74 68 | 65 20 62 65 67 69 6e 6e |tween th|e beginn|
|00004d70| 69 6e 67 20 6f 66 20 74 | 68 65 20 63 75 72 72 65 |ing of t|he curre|
|00004d80| 6e 74 20 65 6e 74 72 79 | 20 61 6e 64 20 74 68 65 |nt entry| and the|
|00004d90| 20 6e 65 78 74 20 6f 6e | 65 2c 0a 58 61 64 6a 75 | next on|e,.Xadju|
|00004da0| 73 74 65 64 20 73 6f 20 | 74 68 61 74 20 74 68 65 |sted so |that the|
|00004db0| 20 6e 65 78 74 20 65 6e | 74 72 79 0a 58 77 69 6c | next en|try.Xwil|
|00004dc0| 6c 20 73 74 61 72 74 20 | 6f 6e 20 61 20 6c 6f 6e |l start |on a lon|
|00004dd0| 67 20 62 6f 75 6e 64 61 | 72 79 2e 0a 58 2e 53 48 |g bounda|ry..X.SH|
|00004de0| 20 46 49 4c 45 53 0a 58 | 2f 75 73 72 2f 69 6e 63 | FILES.X|/usr/inc|
|00004df0| 6c 75 64 65 2f 73 79 73 | 2f 64 69 72 65 6e 74 2e |lude/sys|/dirent.|
|00004e00| 68 0a 58 2e 53 48 20 22 | 53 45 45 20 41 4c 53 4f |h.X.SH "|SEE ALSO|
|00004e10| 22 0a 58 67 65 74 64 65 | 6e 74 73 28 32 29 2e 0a |".Xgetde|nts(2)..|
|00004e20| 58 2e 53 48 20 57 41 52 | 4e 49 4e 47 0a 58 54 68 |X.SH WAR|NING.XTh|
|00004e30| 65 20 66 69 65 6c 64 0a | 58 2e 49 20 64 5f 6f 66 |e field.|X.I d_of|
|00004e40| 66 5c 5e 0a 58 64 6f 65 | 73 20 6e 6f 74 20 68 61 |f\^.Xdoe|s not ha|
|00004e50| 76 65 20 61 20 73 69 6d | 70 6c 65 20 69 6e 74 65 |ve a sim|ple inte|
|00004e60| 72 70 72 65 74 61 74 69 | 6f 6e 0a 58 66 6f 72 20 |rpretati|on.Xfor |
|00004e70| 73 6f 6d 65 20 66 69 6c | 65 20 73 79 73 74 65 6d |some fil|e system|
|00004e80| 20 74 79 70 65 73 0a 58 | 61 6e 64 20 73 68 6f 75 | types.X|and shou|
|00004e90| 6c 64 20 6e 6f 74 20 62 | 65 20 75 73 65 64 20 64 |ld not b|e used d|
|00004ea0| 69 72 65 63 74 6c 79 20 | 62 79 20 61 70 70 6c 69 |irectly |by appli|
|00004eb0| 63 61 74 69 6f 6e 73 2e | 0a 45 4e 44 5f 4f 46 5f |cations.|.END_OF_|
|00004ec0| 64 69 72 65 6e 74 2e 34 | 0a 69 66 20 74 65 73 74 |dirent.4|.if test|
|00004ed0| 20 31 35 39 33 20 2d 6e | 65 20 60 77 63 20 2d 63 | 1593 -n|e `wc -c|
|00004ee0| 20 3c 64 69 72 65 6e 74 | 2e 34 60 3b 20 74 68 65 | <dirent|.4`; the|
|00004ef0| 6e 0a 20 20 20 20 65 63 | 68 6f 20 73 68 61 72 3a |n. ec|ho shar:|
|00004f00| 20 5c 22 64 69 72 65 6e | 74 2e 34 5c 22 20 75 6e | \"diren|t.4\" un|
|00004f10| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00004f20| 67 20 73 69 7a 65 21 3f | 0a 66 69 0a 23 20 65 6e |g size!?|.fi.# en|
|00004f30| 64 20 6f 66 20 6f 76 65 | 72 77 72 69 74 69 6e 67 |d of ove|rwriting|
|00004f40| 20 63 68 65 63 6b 0a 66 | 69 0a 65 63 68 6f 20 73 | check.f|i.echo s|
|00004f50| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|00004f60| 5c 22 64 69 72 65 6e 74 | 2e 68 5c 22 20 5c 28 37 |\"dirent|.h\" \(7|
|00004f70| 33 30 20 63 68 61 72 61 | 63 74 65 72 73 5c 29 0a |30 chara|cters\).|
|00004f80| 69 66 20 74 65 73 74 20 | 2d 66 20 64 69 72 65 6e |if test |-f diren|
|00004f90| 74 2e 68 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |t.h ; th|en . ec|
|00004fa0| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|00004fb0| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00004fc0| 73 74 69 6e 67 20 66 69 | 6c 65 20 5c 22 64 69 72 |sting fi|le \"dir|
|00004fd0| 65 6e 74 2e 68 5c 22 0a | 65 6c 73 65 0a 73 65 64 |ent.h\".|else.sed|
|00004fe0| 20 22 73 2f 5e 58 2f 2f | 22 20 3e 64 69 72 65 6e | "s/^X//|" >diren|
|00004ff0| 74 2e 68 20 3c 3c 27 45 | 4e 44 5f 4f 46 5f 64 69 |t.h <<'E|ND_OF_di|
|00005000| 72 65 6e 74 2e 68 27 0a | 58 2f 2a 0a 58 09 3c 64 |rent.h'.|X/*.X.<d|
|00005010| 69 72 65 6e 74 2e 68 3e | 20 2d 2d 20 64 65 66 69 |irent.h>| -- defi|
|00005020| 6e 69 74 69 6f 6e 73 20 | 66 6f 72 20 53 56 52 33 |nitions |for SVR3|
|00005030| 20 64 69 72 65 63 74 6f | 72 79 20 61 63 63 65 73 | directo|ry acces|
|00005040| 73 20 72 6f 75 74 69 6e | 65 73 0a 58 0a 58 09 6c |s routin|es.X.X.l|
|00005050| 61 73 74 20 65 64 69 74 | 3a 09 32 35 2d 41 70 72 |ast edit|:.25-Apr|
|00005060| 2d 31 39 38 37 09 44 20 | 41 20 47 77 79 6e 0a 58 |-1987.D |A Gwyn.X|
|00005070| 0a 58 09 50 72 65 72 65 | 71 75 69 73 69 74 65 3a |.X.Prere|quisite:|
|00005080| 09 3c 73 79 73 2f 74 79 | 70 65 73 2e 68 3e 0a 58 |.<sys/ty|pes.h>.X|
|00005090| 2a 2f 0a 58 0a 58 23 69 | 6e 63 6c 75 64 65 09 3c |*/.X.X#i|nclude.<|
|000050a0| 73 79 73 2f 64 69 72 65 | 6e 74 2e 68 3e 0a 58 0a |sys/dire|nt.h>.X.|
|000050b0| 58 23 64 65 66 69 6e 65 | 09 44 49 52 42 55 46 09 |X#define|.DIRBUF.|
|000050c0| 09 38 31 39 32 09 09 2f | 2a 20 62 75 66 66 65 72 |.8192../|* buffer|
|000050d0| 20 73 69 7a 65 20 66 6f | 72 20 66 73 2d 69 6e 64 | size fo|r fs-ind|
|000050e0| 65 70 2e 20 64 69 72 73 | 20 2a 2f 0a 58 09 2f 2a |ep. dirs| */.X./*|
|000050f0| 20 6d 75 73 74 20 69 6e | 20 67 65 6e 65 72 61 6c | must in| general|
|00005100| 20 62 65 20 6c 61 72 67 | 65 72 20 74 68 61 6e 20 | be larg|er than |
|00005110| 74 68 65 20 66 69 6c 65 | 73 79 73 74 65 6d 20 62 |the file|system b|
|00005120| 75 66 66 65 72 20 73 69 | 7a 65 20 2a 2f 0a 58 0a |uffer si|ze */.X.|
|00005130| 58 74 79 70 65 64 65 66 | 20 73 74 72 75 63 74 0a |Xtypedef| struct.|
|00005140| 58 09 7b 0a 58 09 69 6e | 74 09 64 64 5f 66 64 3b |X.{.X.in|t.dd_fd;|
|00005150| 09 09 09 2f 2a 20 66 69 | 6c 65 20 64 65 73 63 72 |.../* fi|le descr|
|00005160| 69 70 74 6f 72 20 2a 2f | 0a 58 09 69 6e 74 09 64 |iptor */|.X.int.d|
|00005170| 64 5f 6c 6f 63 3b 09 09 | 09 2f 2a 20 6f 66 66 73 |d_loc;..|./* offs|
|00005180| 65 74 20 69 6e 20 62 6c | 6f 63 6b 20 2a 2f 0a 58 |et in bl|ock */.X|
|00005190| 09 69 6e 74 09 64 64 5f | 73 69 7a 65 3b 09 09 2f |.int.dd_|size;../|
|000051a0| 2a 20 61 6d 6f 75 6e 74 | 20 6f 66 20 76 61 6c 69 |* amount| of vali|
|000051b0| 64 20 64 61 74 61 20 2a | 2f 0a 58 09 63 68 61 72 |d data *|/.X.char|
|000051c0| 09 2a 64 64 5f 62 75 66 | 3b 09 09 2f 2a 20 2d 3e |.*dd_buf|;../* ->|
|000051d0| 20 64 69 72 65 63 74 6f | 72 79 20 62 6c 6f 63 6b | directo|ry block|
|000051e0| 20 2a 2f 0a 58 09 7d 09 | 44 49 52 3b 09 09 09 2f | */.X.}.|DIR;.../|
|000051f0| 2a 20 73 74 72 65 61 6d | 20 64 61 74 61 20 66 72 |* stream| data fr|
|00005200| 6f 6d 20 6f 70 65 6e 64 | 69 72 28 29 20 2a 2f 0a |om opend|ir() */.|
|00005210| 58 0a 58 65 78 74 65 72 | 6e 20 44 49 52 09 09 2a |X.Xexter|n DIR..*|
|00005220| 6f 70 65 6e 64 69 72 28 | 29 3b 0a 58 65 78 74 65 |opendir(|);.Xexte|
|00005230| 72 6e 20 73 74 72 75 63 | 74 20 64 69 72 65 6e 74 |rn struc|t dirent|
|00005240| 09 2a 72 65 61 64 64 69 | 72 28 29 3b 0a 58 65 78 |.*readdi|r();.Xex|
|00005250| 74 65 72 6e 20 6f 66 66 | 5f 74 09 09 74 65 6c 6c |tern off|_t..tell|
|00005260| 64 69 72 28 29 3b 0a 58 | 65 78 74 65 72 6e 20 76 |dir();.X|extern v|
|00005270| 6f 69 64 09 09 73 65 65 | 6b 64 69 72 28 29 3b 0a |oid..see|kdir();.|
|00005280| 58 65 78 74 65 72 6e 20 | 76 6f 69 64 09 09 72 65 |Xextern |void..re|
|00005290| 77 69 6e 64 64 69 72 28 | 29 3b 0a 58 65 78 74 65 |winddir(|);.Xexte|
|000052a0| 72 6e 20 69 6e 74 09 09 | 63 6c 6f 73 65 64 69 72 |rn int..|closedir|
|000052b0| 28 29 3b 0a 58 0a 58 23 | 69 66 6e 64 65 66 20 4e |();.X.X#|ifndef N|
|000052c0| 55 4c 4c 0a 58 23 64 65 | 66 69 6e 65 09 4e 55 4c |ULL.X#de|fine.NUL|
|000052d0| 4c 09 30 09 09 09 2f 2a | 20 44 41 47 20 2d 2d 20 |L.0.../*| DAG -- |
|000052e0| 61 64 64 65 64 20 66 6f | 72 20 63 6f 6e 76 65 6e |added fo|r conven|
|000052f0| 69 65 6e 63 65 20 2a 2f | 0a 58 23 65 6e 64 69 66 |ience */|.X#endif|
|00005300| 0a 45 4e 44 5f 4f 46 5f | 64 69 72 65 6e 74 2e 68 |.END_OF_|dirent.h|
|00005310| 0a 69 66 20 74 65 73 74 | 20 37 33 30 20 2d 6e 65 |.if test| 730 -ne|
|00005320| 20 60 77 63 20 2d 63 20 | 3c 64 69 72 65 6e 74 2e | `wc -c |<dirent.|
|00005330| 68 60 3b 20 74 68 65 6e | 0a 20 20 20 20 65 63 68 |h`; then|. ech|
|00005340| 6f 20 73 68 61 72 3a 20 | 5c 22 64 69 72 65 6e 74 |o shar: |\"dirent|
|00005350| 2e 68 5c 22 20 75 6e 70 | 61 63 6b 65 64 20 77 69 |.h\" unp|acked wi|
|00005360| 74 68 20 77 72 6f 6e 67 | 20 73 69 7a 65 21 3f 0a |th wrong| size!?.|
|00005370| 66 69 0a 23 20 65 6e 64 | 20 6f 66 20 6f 76 65 72 |fi.# end| of over|
|00005380| 77 72 69 74 69 6e 67 20 | 63 68 65 63 6b 0a 66 69 |writing |check.fi|
|00005390| 0a 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 |.echo sh|ar: Extr|
|000053a0| 61 63 74 69 6e 67 20 5c | 22 67 65 74 64 65 6e 74 |acting \|"getdent|
|000053b0| 73 2e 32 5c 22 20 5c 28 | 31 39 32 32 20 63 68 61 |s.2\" \(|1922 cha|
|000053c0| 72 61 63 74 65 72 73 5c | 29 0a 69 66 20 74 65 73 |racters\|).if tes|
|000053d0| 74 20 2d 66 20 67 65 74 | 64 65 6e 74 73 2e 32 20 |t -f get|dents.2 |
|000053e0| 3b 20 74 68 65 6e 20 0a | 20 20 65 63 68 6f 20 73 |; then .| echo s|
|000053f0| 68 61 72 3a 20 57 69 6c | 6c 20 6e 6f 74 20 6f 76 |har: Wil|l not ov|
|00005400| 65 72 2d 77 72 69 74 65 | 20 65 78 69 73 74 69 6e |er-write| existin|
|00005410| 67 20 66 69 6c 65 20 5c | 22 67 65 74 64 65 6e 74 |g file \|"getdent|
|00005420| 73 2e 32 5c 22 0a 65 6c | 73 65 0a 73 65 64 20 22 |s.2\".el|se.sed "|
|00005430| 73 2f 5e 58 2f 2f 22 20 | 3e 67 65 74 64 65 6e 74 |s/^X//" |>getdent|
|00005440| 73 2e 32 20 3c 3c 27 45 | 4e 44 5f 4f 46 5f 67 65 |s.2 <<'E|ND_OF_ge|
|00005450| 74 64 65 6e 74 73 2e 32 | 27 0a 58 2e 54 48 20 47 |tdents.2|'.X.TH G|
|00005460| 45 54 44 45 4e 54 53 20 | 32 20 22 53 74 61 6e 64 |ETDENTS |2 "Stand|
|00005470| 61 72 64 20 45 78 74 65 | 6e 73 69 6f 6e 22 0a 58 |ard Exte|nsion".X|
|00005480| 2e 53 48 20 4e 41 4d 45 | 0a 58 67 65 74 64 65 6e |.SH NAME|.Xgetden|
|00005490| 74 73 20 5c 2d 20 67 65 | 74 20 64 69 72 65 63 74 |ts \- ge|t direct|
|000054a0| 6f 72 79 20 65 6e 74 72 | 69 65 73 20 69 6e 20 61 |ory entr|ies in a|
|000054b0| 20 66 69 6c 65 20 73 79 | 73 74 65 6d 20 69 6e 64 | file sy|stem ind|
|000054c0| 65 70 65 6e 64 65 6e 74 | 20 66 6f 72 6d 61 74 0a |ependent| format.|
|000054d0| 58 2e 53 48 20 53 59 4e | 4f 50 53 49 53 0a 58 2e |X.SH SYN|OPSIS.X.|
|000054e0| 42 20 22 23 69 6e 63 6c | 75 64 65 20 3c 73 79 73 |B "#incl|ude <sys|
|000054f0| 2f 74 79 70 65 73 2e 68 | 3e 22 0a 58 2e 62 72 0a |/types.h|>".X.br.|
|00005500| 58 2e 42 20 22 23 69 6e | 63 6c 75 64 65 20 3c 73 |X.B "#in|clude <s|
|00005510| 79 73 2f 64 69 72 65 6e | 74 2e 68 3e 22 0a 58 2e |ys/diren|t.h>".X.|
|00005520| 50 0a 58 2e 42 20 22 69 | 6e 74 20 67 65 74 64 65 |P.X.B "i|nt getde|
|00005530| 6e 74 73 20 28 66 69 6c | 64 65 73 2c 20 62 75 66 |nts (fil|des, buf|
|00005540| 2c 20 6e 62 79 74 65 29 | 22 0a 58 2e 62 72 0a 58 |, nbyte)|".X.br.X|
|00005550| 2e 42 20 22 69 6e 74 20 | 66 69 6c 64 65 73 3b 22 |.B "int |fildes;"|
|00005560| 0a 58 2e 62 72 0a 58 2e | 42 20 22 63 68 61 72 20 |.X.br.X.|B "char |
|00005570| 5c 28 2a 2a 62 75 66 3b | 22 0a 58 2e 62 72 0a 58 |\(**buf;|".X.br.X|
|00005580| 2e 42 20 22 75 6e 73 69 | 67 6e 65 64 20 6e 62 79 |.B "unsi|gned nby|
|00005590| 74 65 3b 22 0a 58 2e 53 | 48 20 44 45 53 43 52 49 |te;".X.S|H DESCRI|
|000055a0| 50 54 49 4f 4e 0a 58 2e | 49 20 46 69 6c 64 65 73 |PTION.X.|I Fildes|
|000055b0| 0a 58 69 73 20 61 20 66 | 69 6c 65 20 64 65 73 63 |.Xis a f|ile desc|
|000055c0| 72 69 70 74 6f 72 20 6f | 62 74 61 69 6e 65 64 20 |riptor o|btained |
|000055d0| 66 72 6f 6d 20 61 6e 0a | 58 2e 49 52 20 6f 70 65 |from an.|X.IR ope|
|000055e0| 6e 20 28 32 29 0a 58 6f | 72 0a 58 2e 49 52 20 64 |n (2).Xo|r.X.IR d|
|000055f0| 75 70 20 28 32 29 0a 58 | 73 79 73 74 65 6d 20 63 |up (2).X|system c|
|00005600| 61 6c 6c 2e 0a 58 2e 50 | 0a 58 2e 49 20 47 65 74 |all..X.P|.X.I Get|
|00005610| 64 65 6e 74 73 0a 58 61 | 74 74 65 6d 70 74 73 20 |dents.Xa|ttempts |
|00005620| 74 6f 20 72 65 61 64 0a | 58 2e 49 20 6e 62 79 74 |to read.|X.I nbyt|
|00005630| 65 0a 58 62 79 74 65 73 | 20 66 72 6f 6d 20 74 68 |e.Xbytes| from th|
|00005640| 65 20 64 69 72 65 63 74 | 6f 72 79 20 61 73 73 6f |e direct|ory asso|
|00005650| 63 69 61 74 65 64 20 77 | 69 74 68 0a 58 2e 49 20 |ciated w|ith.X.I |
|00005660| 66 69 6c 64 65 73 0a 58 | 61 6e 64 20 74 6f 20 66 |fildes.X|and to f|
|00005670| 6f 72 6d 61 74 20 74 68 | 65 6d 20 61 73 0a 58 66 |ormat th|em as.Xf|
|00005680| 69 6c 65 20 73 79 73 74 | 65 6d 20 69 6e 64 65 70 |ile syst|em indep|
|00005690| 65 6e 64 65 6e 74 20 65 | 6e 74 72 69 65 73 0a 58 |endent e|ntries.X|
|000056a0| 69 6e 20 74 68 65 20 62 | 75 66 66 65 72 20 70 6f |in the b|uffer po|
|000056b0| 69 6e 74 65 64 20 74 6f | 20 62 79 0a 58 2e 49 52 |inted to| by.X.IR|
|000056c0| 20 62 75 66 20 2e 0a 58 | 53 69 6e 63 65 20 74 68 | buf ..X|Since th|
|000056d0| 65 20 66 69 6c 65 20 73 | 79 73 74 65 6d 20 69 6e |e file s|ystem in|
|000056e0| 64 65 70 65 6e 64 65 6e | 74 20 64 69 72 65 63 74 |dependen|t direct|
|000056f0| 6f 72 79 20 65 6e 74 72 | 69 65 73 0a 58 61 72 65 |ory entr|ies.Xare|
|00005700| 20 6f 66 20 76 61 72 69 | 61 62 6c 65 20 6c 65 6e | of vari|able len|
|00005710| 67 74 68 2c 0a 58 69 6e | 20 6d 6f 73 74 20 63 61 |gth,.Xin| most ca|
|00005720| 73 65 73 20 74 68 65 20 | 61 63 74 75 61 6c 20 6e |ses the |actual n|
|00005730| 75 6d 62 65 72 20 6f 66 | 20 62 79 74 65 73 20 72 |umber of| bytes r|
|00005740| 65 74 75 72 6e 65 64 0a | 58 77 69 6c 6c 20 62 65 |eturned.|Xwill be|
|00005750| 20 6c 65 73 73 20 74 68 | 61 6e 0a 58 2e 49 52 20 | less th|an.X.IR |
|00005760| 6e 62 79 74 65 20 2e 0a | 58 2e 50 0a 58 54 68 65 |nbyte ..|X.P.XThe|
|00005770| 20 66 69 6c 65 20 73 79 | 73 74 65 6d 20 69 6e 64 | file sy|stem ind|
|00005780| 65 70 65 6e 64 65 6e 74 | 20 64 69 72 65 63 74 6f |ependent| directo|
|00005790| 72 79 20 65 6e 74 72 79 | 20 69 73 20 73 70 65 63 |ry entry| is spec|
|000057a0| 69 66 69 65 64 20 62 79 | 20 74 68 65 0a 58 2e 49 |ified by| the.X.I|
|000057b0| 20 64 69 72 65 6e 74 0a | 58 73 74 72 75 63 74 75 | dirent.|Xstructu|
|000057c0| 72 65 2e 0a 58 46 6f 72 | 20 61 20 64 65 73 63 72 |re..XFor| a descr|
|000057d0| 69 70 74 69 6f 6e 20 6f | 66 20 74 68 69 73 20 73 |iption o|f this s|
|000057e0| 65 65 0a 58 2e 49 52 20 | 64 69 72 65 6e 74 20 28 |ee.X.IR |dirent (|
|000057f0| 34 29 2e 0a 58 2e 50 0a | 58 4f 6e 20 64 65 76 69 |4)..X.P.|XOn devi|
|00005800| 63 65 73 20 63 61 70 61 | 62 6c 65 20 6f 66 20 73 |ces capa|ble of s|
|00005810| 65 65 6b 69 6e 67 2c 0a | 58 2e 49 20 67 65 74 64 |eeking,.|X.I getd|
|00005820| 65 6e 74 73 0a 58 73 74 | 61 72 74 73 20 61 74 20 |ents.Xst|arts at |
|00005830| 61 20 70 6f 73 69 74 69 | 6f 6e 20 69 6e 20 74 68 |a positi|on in th|
|00005840| 65 20 66 69 6c 65 20 67 | 69 76 65 6e 20 62 79 0a |e file g|iven by.|
|00005850| 58 74 68 65 20 66 69 6c | 65 20 70 6f 69 6e 74 65 |Xthe fil|e pointe|
|00005860| 72 20 61 73 73 6f 63 69 | 61 74 65 64 20 77 69 74 |r associ|ated wit|
|00005870| 68 0a 58 2e 49 52 20 66 | 69 6c 64 65 73 20 2e 0a |h.X.IR f|ildes ..|
|00005880| 58 55 70 6f 6e 20 72 65 | 74 75 72 6e 20 66 72 6f |XUpon re|turn fro|
|00005890| 6d 0a 58 2e 49 52 20 67 | 65 74 64 65 6e 74 73 20 |m.X.IR g|etdents |
|000058a0| 2c 0a 58 74 68 65 20 66 | 69 6c 65 20 70 6f 69 6e |,.Xthe f|ile poin|
|000058b0| 74 65 72 20 68 61 73 20 | 62 65 65 6e 20 69 6e 63 |ter has |been inc|
|000058c0| 72 65 6d 65 6e 74 65 64 | 0a 58 74 6f 20 70 6f 69 |remented|.Xto poi|
|000058d0| 6e 74 20 74 6f 20 74 68 | 65 20 6e 65 78 74 20 64 |nt to th|e next d|
|000058e0| 69 72 65 63 74 6f 72 79 | 20 65 6e 74 72 79 2e 0a |irectory| entry..|
|000058f0| 58 2e 50 0a 58 54 68 69 | 73 20 73 79 73 74 65 6d |X.P.XThi|s system|
|00005900| 20 63 61 6c 6c 20 77 61 | 73 20 64 65 76 65 6c 6f | call wa|s develo|
|00005910| 70 65 64 20 69 6e 20 6f | 72 64 65 72 20 74 6f 20 |ped in o|rder to |
|00005920| 69 6d 70 6c 65 6d 65 6e | 74 20 74 68 65 0a 58 2e |implemen|t the.X.|
|00005930| 49 20 72 65 61 64 64 69 | 72 0a 58 72 6f 75 74 69 |I readdi|r.Xrouti|
|00005940| 6e 65 0a 58 5b 66 6f 72 | 20 61 20 64 65 73 63 72 |ne.X[for| a descr|
|00005950| 69 70 74 69 6f 6e 20 73 | 65 65 0a 58 2e 49 52 20 |iption s|ee.X.IR |
|00005960| 64 69 72 65 63 74 6f 72 | 79 20 28 33 43 29 5d 0a |director|y (3C)].|
|00005970| 58 61 6e 64 20 73 68 6f | 75 6c 64 20 6e 6f 74 20 |Xand sho|uld not |
|00005980| 62 65 20 75 73 65 64 20 | 66 6f 72 20 6f 74 68 65 |be used |for othe|
|00005990| 72 20 70 75 72 70 6f 73 | 65 73 2e 0a 58 2e 53 48 |r purpos|es..X.SH|
|000059a0| 20 22 53 45 45 20 41 4c | 53 4f 22 0a 58 64 69 72 | "SEE AL|SO".Xdir|
|000059b0| 65 63 74 6f 72 79 28 33 | 43 29 2c 20 64 69 72 65 |ectory(3|C), dire|
|000059c0| 6e 74 28 34 29 2e 0a 58 | 2e 53 48 20 44 49 41 47 |nt(4)..X|.SH DIAG|
|000059d0| 4e 4f 53 54 49 43 53 0a | 58 55 70 6f 6e 20 73 75 |NOSTICS.|XUpon su|
|000059e0| 63 63 65 73 73 66 75 6c | 20 63 6f 6d 70 6c 65 74 |ccessful| complet|
|000059f0| 69 6f 6e 0a 58 61 20 6e | 6f 6e 2d 6e 65 67 61 74 |ion.Xa n|on-negat|
|00005a00| 69 76 65 20 69 6e 74 65 | 67 65 72 20 69 73 20 72 |ive inte|ger is r|
|00005a10| 65 74 75 72 6e 65 64 0a | 58 69 6e 64 69 63 61 74 |eturned.|Xindicat|
|00005a20| 69 6e 67 20 74 68 65 20 | 6e 75 6d 62 65 72 20 6f |ing the |number o|
|00005a30| 66 20 62 79 74 65 73 20 | 6f 66 0a 58 2e 49 20 62 |f bytes |of.X.I b|
|00005a40| 75 66 5c 5e 0a 58 61 63 | 74 75 61 6c 6c 79 20 66 |uf\^.Xac|tually f|
|00005a50| 69 6c 6c 65 64 2e 0a 58 | 28 54 68 69 73 20 6e 65 |illed..X|(This ne|
|00005a60| 65 64 20 6e 6f 74 20 62 | 65 20 74 68 65 20 6e 75 |ed not b|e the nu|
|00005a70| 6d 62 65 72 20 61 63 74 | 75 61 6c 6c 79 20 75 73 |mber act|ually us|
|00005a80| 65 64 0a 58 69 6e 20 74 | 68 65 20 61 63 74 75 61 |ed.Xin t|he actua|
|00005a90| 6c 20 64 69 72 65 63 74 | 6f 72 79 20 66 69 6c 65 |l direct|ory file|
|00005aa0| 2e 29 5c 7c 5c 7c 0a 58 | 41 20 76 61 6c 75 65 20 |.)\|\|.X|A value |
|00005ab0| 6f 66 20 7a 65 72 6f 0a | 58 69 6e 64 69 63 61 74 |of zero.|Xindicat|
|00005ac0| 65 73 20 74 68 65 20 65 | 6e 64 20 6f 66 20 74 68 |es the e|nd of th|
|00005ad0| 65 20 64 69 72 65 63 74 | 6f 72 79 20 68 61 73 20 |e direct|ory has |
|00005ae0| 62 65 65 6e 20 72 65 61 | 63 68 65 64 2e 0a 58 49 |been rea|ched..XI|
|00005af0| 66 0a 58 2e 49 20 67 65 | 74 64 65 6e 74 73 0a 58 |f.X.I ge|tdents.X|
|00005b00| 66 61 69 6c 73 20 66 6f | 72 20 61 6e 79 20 6f 74 |fails fo|r any ot|
|00005b10| 68 65 72 20 72 65 61 73 | 6f 6e 2c 0a 58 61 20 76 |her reas|on,.Xa v|
|00005b20| 61 6c 75 65 20 6f 66 20 | 5c 2d 31 20 69 73 20 72 |alue of |\-1 is r|
|00005b30| 65 74 75 72 6e 65 64 20 | 61 6e 64 0a 58 74 68 65 |eturned |and.Xthe|
|00005b40| 20 65 78 74 65 72 6e 61 | 6c 20 69 6e 74 65 67 65 | externa|l intege|
|00005b50| 72 20 76 61 72 69 61 62 | 6c 65 0a 58 2e 49 20 65 |r variab|le.X.I e|
|00005b60| 72 72 6e 6f 0a 58 69 73 | 20 73 65 74 20 74 6f 20 |rrno.Xis| set to |
|00005b70| 69 6e 64 69 63 61 74 65 | 20 74 68 65 20 65 72 72 |indicate| the err|
|00005b80| 6f 72 2e 0a 58 2e 53 48 | 20 57 41 52 4e 49 4e 47 |or..X.SH| WARNING|
|00005b90| 53 0a 58 45 6e 74 72 69 | 65 73 20 66 6f 72 20 22 |S.XEntri|es for "|
|00005ba0| 2e 22 20 61 6e 64 20 22 | 2e 2e 22 0a 58 6d 61 79 |." and "|..".Xmay|
|00005bb0| 20 6e 6f 74 20 62 65 20 | 72 65 70 6f 72 74 65 64 | not be |reported|
|00005bc0| 20 66 6f 72 20 73 6f 6d | 65 20 66 69 6c 65 20 73 | for som|e file s|
|00005bd0| 79 73 74 65 6d 20 74 79 | 70 65 73 2e 0a 58 2e 50 |ystem ty|pes..X.P|
|00005be0| 0a 58 54 68 65 20 65 78 | 61 63 74 20 73 65 74 20 |.XThe ex|act set |
|00005bf0| 6f 66 0a 58 2e 49 20 65 | 72 72 6e 6f 0a 58 76 61 |of.X.I e|rrno.Xva|
|00005c00| 6c 75 65 73 20 61 6e 64 | 20 6d 65 61 6e 69 6e 67 |lues and| meaning|
|00005c10| 73 20 6d 61 79 20 76 61 | 72 79 20 61 6d 6f 6e 67 |s may va|ry among|
|00005c20| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 73 | impleme|ntations|
|00005c30| 2e 0a 45 4e 44 5f 4f 46 | 5f 67 65 74 64 65 6e 74 |..END_OF|_getdent|
|00005c40| 73 2e 32 0a 69 66 20 74 | 65 73 74 20 31 39 32 32 |s.2.if t|est 1922|
|00005c50| 20 2d 6e 65 20 60 77 63 | 20 2d 63 20 3c 67 65 74 | -ne `wc| -c <get|
|00005c60| 64 65 6e 74 73 2e 32 60 | 3b 20 74 68 65 6e 0a 20 |dents.2`|; then. |
|00005c70| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|00005c80| 67 65 74 64 65 6e 74 73 | 2e 32 5c 22 20 75 6e 70 |getdents|.2\" unp|
|00005c90| 61 63 6b 65 64 20 77 69 | 74 68 20 77 72 6f 6e 67 |acked wi|th wrong|
|00005ca0| 20 73 69 7a 65 21 3f 0a | 66 69 0a 23 20 65 6e 64 | size!?.|fi.# end|
|00005cb0| 20 6f 66 20 6f 76 65 72 | 77 72 69 74 69 6e 67 20 | of over|writing |
|00005cc0| 63 68 65 63 6b 0a 66 69 | 0a 65 63 68 6f 20 73 68 |check.fi|.echo sh|
|00005cd0| 61 72 3a 20 45 78 74 72 | 61 63 74 69 6e 67 20 5c |ar: Extr|acting \|
|00005ce0| 22 67 65 74 64 65 6e 74 | 73 2e 63 5c 22 20 5c 28 |"getdent|s.c\" \(|
|00005cf0| 36 33 37 35 20 63 68 61 | 72 61 63 74 65 72 73 5c |6375 cha|racters\|
|00005d00| 29 0a 69 66 20 74 65 73 | 74 20 2d 66 20 67 65 74 |).if tes|t -f get|
|00005d10| 64 65 6e 74 73 2e 63 20 | 3b 20 74 68 65 6e 20 0a |dents.c |; then .|
|00005d20| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 57 69 6c | echo s|har: Wil|
|00005d30| 6c 20 6e 6f 74 20 6f 76 | 65 72 2d 77 72 69 74 65 |l not ov|er-write|
|00005d40| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 5c | existin|g file \|
|00005d50| 22 67 65 74 64 65 6e 74 | 73 2e 63 5c 22 0a 65 6c |"getdent|s.c\".el|
|00005d60| 73 65 0a 73 65 64 20 22 | 73 2f 5e 58 2f 2f 22 20 |se.sed "|s/^X//" |
|00005d70| 3e 67 65 74 64 65 6e 74 | 73 2e 63 20 3c 3c 27 45 |>getdent|s.c <<'E|
|00005d80| 4e 44 5f 4f 46 5f 67 65 | 74 64 65 6e 74 73 2e 63 |ND_OF_ge|tdents.c|
|00005d90| 27 0a 58 2f 2a 0a 58 09 | 67 65 74 64 65 6e 74 73 |'.X/*.X.|getdents|
|00005da0| 20 2d 2d 20 67 65 74 20 | 64 69 72 65 63 74 6f 72 | -- get |director|
|00005db0| 79 20 65 6e 74 72 69 65 | 73 20 69 6e 20 61 20 66 |y entrie|s in a f|
|00005dc0| 69 6c 65 20 73 79 73 74 | 65 6d 20 69 6e 64 65 70 |ile syst|em indep|
|00005dd0| 65 6e 64 65 6e 74 20 66 | 6f 72 6d 61 74 0a 58 09 |endent f|ormat.X.|
|00005de0| 09 09 28 53 56 52 33 20 | 73 79 73 74 65 6d 20 63 |..(SVR3 |system c|
|00005df0| 61 6c 6c 20 65 6d 75 6c | 61 74 69 6f 6e 29 0a 58 |all emul|ation).X|
|00005e00| 0a 58 09 6c 61 73 74 20 | 65 64 69 74 3a 09 32 35 |.X.last |edit:.25|
|00005e10| 2d 41 70 72 2d 31 39 38 | 37 09 44 20 41 20 47 77 |-Apr-198|7.D A Gw|
|00005e20| 79 6e 0a 58 0a 58 09 54 | 68 69 73 20 73 69 6e 67 |yn.X.X.T|his sing|
|00005e30| 6c 65 20 73 6f 75 72 63 | 65 20 66 69 6c 65 20 73 |le sourc|e file s|
|00005e40| 75 70 70 6f 72 74 73 20 | 73 65 76 65 72 61 6c 20 |upports |several |
|00005e50| 64 69 66 66 65 72 65 6e | 74 20 6d 65 74 68 6f 64 |differen|t method|
|00005e60| 73 20 6f 66 0a 58 09 67 | 65 74 74 69 6e 67 20 64 |s of.X.g|etting d|
|00005e70| 69 72 65 63 74 6f 72 79 | 20 65 6e 74 72 69 65 73 |irectory| entries|
|00005e80| 20 66 72 6f 6d 20 74 68 | 65 20 6f 70 65 72 61 74 | from th|e operat|
|00005e90| 69 6e 67 20 73 79 73 74 | 65 6d 2e 20 20 44 65 66 |ing syst|em. Def|
|00005ea0| 69 6e 65 0a 58 09 77 68 | 69 63 68 65 76 65 72 20 |ine.X.wh|ichever |
|00005eb0| 6f 6e 65 20 6f 66 20 74 | 68 65 20 66 6f 6c 6c 6f |one of t|he follo|
|00005ec0| 77 69 6e 67 20 64 65 73 | 63 72 69 62 65 73 20 79 |wing des|cribes y|
|00005ed0| 6f 75 72 20 73 79 73 74 | 65 6d 3a 0a 58 0a 58 09 |our syst|em:.X.X.|
|00005ee0| 55 46 53 09 6f 72 69 67 | 69 6e 61 6c 20 55 4e 49 |UFS.orig|inal UNI|
|00005ef0| 58 20 66 69 6c 65 73 79 | 73 74 65 6d 20 28 31 34 |X filesy|stem (14|
|00005f00| 2d 63 68 61 72 61 63 74 | 65 72 20 6e 61 6d 65 20 |-charact|er name |
|00005f10| 6c 69 6d 69 74 29 0a 58 | 09 42 46 53 09 34 2e 32 |limit).X|.BFS.4.2|
|00005f20| 42 53 44 20 28 61 6c 73 | 6f 20 34 2e 33 42 53 44 |BSD (als|o 4.3BSD|
|00005f30| 29 20 6e 61 74 69 76 65 | 20 66 69 6c 65 73 79 73 |) native| filesys|
|00005f40| 74 65 6d 20 28 6c 6f 6e | 67 20 6e 61 6d 65 73 29 |tem (lon|g names)|
|00005f50| 0a 58 09 4e 46 53 09 67 | 65 74 64 69 72 65 6e 74 |.X.NFS.g|etdirent|
|00005f60| 72 69 65 73 28 29 20 73 | 79 73 74 65 6d 20 63 61 |ries() s|ystem ca|
|00005f70| 6c 6c 0a 58 0a 58 09 41 | 6c 73 6f 20 64 65 66 69 |ll.X.X.A|lso defi|
|00005f80| 6e 65 20 61 6e 79 20 6f | 66 20 74 68 65 20 66 6f |ne any o|f the fo|
|00005f90| 6c 6c 6f 77 69 6e 67 20 | 74 68 61 74 20 61 72 65 |llowing |that are|
|00005fa0| 20 70 65 72 74 69 6e 65 | 6e 74 3a 0a 58 0a 58 09 | pertine|nt:.X.X.|
|00005fb0| 42 52 4c 09 42 52 4c 20 | 55 4e 49 58 20 53 79 73 |BRL.BRL |UNIX Sys|
|00005fc0| 74 65 6d 20 56 20 65 6d | 75 6c 61 74 69 6f 6e 20 |tem V em|ulation |
|00005fd0| 65 6e 76 69 72 6f 6e 6d | 65 6e 74 20 6f 6e 20 34 |environm|ent on 4|
|00005fe0| 2e 6e 42 53 44 0a 58 09 | 55 4e 4b 09 68 61 76 65 |.nBSD.X.|UNK.have|
|00005ff0| 20 5f 67 65 74 64 65 6e | 74 73 28 29 20 73 79 73 | _getden|ts() sys|
|00006000| 74 65 6d 20 63 61 6c 6c | 2c 20 62 75 74 20 6b 65 |tem call|, but ke|
|00006010| 72 6e 65 6c 20 6d 61 79 | 20 6e 6f 74 20 73 75 70 |rnel may| not sup|
|00006020| 70 6f 72 74 20 69 74 0a | 58 0a 58 09 49 66 20 79 |port it.|X.X.If y|
|00006030| 6f 75 72 20 43 20 6c 69 | 62 72 61 72 79 20 68 61 |our C li|brary ha|
|00006040| 73 20 61 20 67 65 74 64 | 65 6e 74 73 28 29 20 73 |s a getd|ents() s|
|00006050| 79 73 74 65 6d 20 63 61 | 6c 6c 20 69 6e 74 65 72 |ystem ca|ll inter|
|00006060| 66 61 63 65 2c 20 62 75 | 74 20 79 6f 75 0a 58 09 |face, bu|t you.X.|
|00006070| 63 61 6e 27 74 20 63 6f | 75 6e 74 20 6f 6e 20 61 |can't co|unt on a|
|00006080| 6c 6c 20 6b 65 72 6e 65 | 6c 73 20 6f 6e 20 77 68 |ll kerne|ls on wh|
|00006090| 69 63 68 20 79 6f 75 72 | 20 61 70 70 6c 69 63 61 |ich your| applica|
|000060a0| 74 69 6f 6e 20 62 69 6e | 61 72 69 65 73 20 6d 61 |tion bin|aries ma|
|000060b0| 79 0a 58 09 72 75 6e 20 | 74 6f 20 73 75 70 70 6f |y.X.run |to suppo|
|000060c0| 72 74 20 69 74 2c 20 63 | 68 61 6e 67 65 20 74 68 |rt it, c|hange th|
|000060d0| 65 20 73 79 73 74 65 6d | 20 63 61 6c 6c 20 69 6e |e system| call in|
|000060e0| 74 65 72 66 61 63 65 20 | 6e 61 6d 65 20 74 6f 0a |terface |name to.|
|000060f0| 58 09 5f 67 65 74 64 65 | 6e 74 73 28 29 20 61 6e |X._getde|nts() an|
|00006100| 64 20 64 65 66 69 6e 65 | 20 22 55 4e 4b 22 20 74 |d define| "UNK" t|
|00006110| 6f 20 65 6e 61 62 6c 65 | 20 74 68 65 20 73 79 73 |o enable| the sys|
|00006120| 74 65 6d 2d 63 61 6c 6c | 20 76 61 6c 69 64 69 74 |tem-call| validit|
|00006130| 79 0a 58 09 74 65 73 74 | 20 69 6e 20 74 68 69 73 |y.X.test| in this|
|00006140| 20 22 77 72 61 70 70 65 | 72 22 20 61 72 6f 75 6e | "wrappe|r" aroun|
|00006150| 64 20 5f 67 65 74 64 65 | 6e 74 73 28 29 2e 0a 58 |d _getde|nts()..X|
|00006160| 0a 58 09 49 66 20 79 6f | 75 72 20 73 79 73 74 65 |.X.If yo|ur syste|
|00006170| 6d 20 68 61 73 20 61 20 | 67 65 74 64 65 6e 74 73 |m has a |getdents|
|00006180| 28 29 20 73 79 73 74 65 | 6d 20 63 61 6c 6c 20 74 |() syste|m call t|
|00006190| 68 61 74 20 69 73 20 67 | 75 61 72 61 6e 74 65 65 |hat is g|uarantee|
|000061a0| 64 20 0a 58 09 74 6f 20 | 61 6c 77 61 79 73 20 77 |d .X.to |always w|
|000061b0| 6f 72 6b 2c 20 79 6f 75 | 20 73 68 6f 75 6c 64 6e |ork, you| shouldn|
|000061c0| 27 74 20 62 65 20 75 73 | 69 6e 67 20 74 68 69 73 |'t be us|ing this|
|000061d0| 20 73 6f 75 72 63 65 20 | 66 69 6c 65 20 61 74 20 | source |file at |
|000061e0| 61 6c 6c 2e 0a 58 2a 2f | 0a 58 0a 58 23 69 6e 63 |all..X*/|.X.X#inc|
|000061f0| 6c 75 64 65 09 3c 73 79 | 73 2f 65 72 72 6e 6f 2e |lude.<sy|s/errno.|
|00006200| 68 3e 0a 58 23 69 6e 63 | 6c 75 64 65 09 3c 73 79 |h>.X#inc|lude.<sy|
|00006210| 73 2f 74 79 70 65 73 2e | 68 3e 0a 58 23 69 66 64 |s/types.|h>.X#ifd|
|00006220| 65 66 20 42 52 4c 0a 58 | 23 69 6e 63 6c 75 64 65 |ef BRL.X|#include|
|00006230| 09 3c 73 79 73 2f 5f 64 | 69 72 2e 68 3e 09 09 2f |.<sys/_d|ir.h>../|
|00006240| 2a 20 42 53 44 20 66 6c | 61 76 6f 72 2c 20 6e 6f |* BSD fl|avor, no|
|00006250| 74 20 53 79 73 74 65 6d | 20 56 20 2a 2f 0a 58 23 |t System| V */.X#|
|00006260| 65 6c 73 65 0a 58 23 69 | 6e 63 6c 75 64 65 09 3c |else.X#i|nclude.<|
|00006270| 73 79 73 2f 64 69 72 2e | 68 3e 0a 58 23 75 6e 64 |sys/dir.|h>.X#und|
|00006280| 65 66 09 4d 41 58 4e 41 | 4d 4c 45 4e 09 09 09 2f |ef.MAXNA|MLEN.../|
|00006290| 2a 20 61 76 6f 69 64 20 | 63 6f 6e 66 6c 69 63 74 |* avoid |conflict|
|000062a0| 20 77 69 74 68 20 53 56 | 52 33 20 2a 2f 0a 58 09 | with SV|R3 */.X.|
|000062b0| 2f 2a 20 47 6f 6f 64 20 | 74 68 69 6e 67 20 77 65 |/* Good |thing we|
|000062c0| 20 64 6f 6e 27 74 20 6e | 65 65 64 20 74 6f 20 75 | don't n|eed to u|
|000062d0| 73 65 20 74 68 65 20 44 | 49 52 53 49 5a 28 29 20 |se the D|IRSIZ() |
|000062e0| 6d 61 63 72 6f 21 20 2a | 2f 0a 58 23 69 66 64 65 |macro! *|/.X#ifde|
|000062f0| 66 20 64 5f 69 6e 6f 09 | 09 09 09 2f 2a 20 34 2e |f d_ino.|.../* 4.|
|00006300| 33 42 53 44 2f 4e 46 53 | 20 75 73 69 6e 67 20 64 |3BSD/NFS| using d|
|00006310| 5f 66 69 6c 65 6e 6f 20 | 2a 2f 0a 58 23 75 6e 64 |_fileno |*/.X#und|
|00006320| 65 66 09 64 5f 69 6e 6f | 09 09 09 09 2f 2a 20 28 |ef.d_ino|..../* (|
|00006330| 6e 6f 74 20 61 62 73 6f | 6c 75 74 65 6c 79 20 6e |not abso|lutely n|
|00006340| 65 63 65 73 73 61 72 79 | 29 20 2a 2f 0a 58 23 65 |ecessary|) */.X#e|
|00006350| 6c 73 65 0a 58 23 64 65 | 66 69 6e 65 09 64 5f 66 |lse.X#de|fine.d_f|
|00006360| 69 6c 65 6e 6f 09 64 5f | 69 6e 6f 09 09 2f 2a 20 |ileno.d_|ino../* |
|00006370| 28 73 74 72 75 63 74 20 | 64 69 72 65 63 74 29 20 |(struct |direct) |
|00006380| 6d 65 6d 62 65 72 20 2a | 2f 0a 58 23 65 6e 64 69 |member *|/.X#endi|
|00006390| 66 0a 58 23 65 6e 64 69 | 66 0a 58 23 69 6e 63 6c |f.X#endi|f.X#incl|
|000063a0| 75 64 65 09 3c 73 79 73 | 2f 64 69 72 65 6e 74 2e |ude.<sys|/dirent.|
|000063b0| 68 3e 0a 58 23 69 6e 63 | 6c 75 64 65 09 3c 73 79 |h>.X#inc|lude.<sy|
|000063c0| 73 2f 73 74 61 74 2e 68 | 3e 0a 58 23 69 66 64 65 |s/stat.h|>.X#ifde|
|000063d0| 66 20 55 4e 4b 0a 58 23 | 69 66 6e 64 65 66 20 55 |f UNK.X#|ifndef U|
|000063e0| 46 53 0a 58 23 69 6e 63 | 6c 75 64 65 20 22 2a 2a |FS.X#inc|lude "**|
|000063f0| 2a 2a 2a 20 45 52 52 4f | 52 20 2a 2a 2a 2a 2a 20 |*** ERRO|R ***** |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.