From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <1491636459.3063398.938223400.7B35C566@webmail.messagingengine.com> From: David Arroyo To: 9fans@9fans.net MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In-Reply-To: <20170407234654.40b4e23976d220cea4ab3daf@eigenstate.org> References: <167A2E66-33F8-4909-8FDB-06F92E930D8B@gmail.com> <795C88A6-B6FE-4B29-AD74-50A0E4D80D97@orthanc.ca> <6C339BCD-FF90-4C03-9AC9-D4098E63EDD8@gmail.com> <789A602E-FC47-40AE-96F4-64E2D2A5B375@orthanc.ca> <4B168609-E25A-4D3C-9A80-1457BA0EE830@gmail.com> <20170407234654.40b4e23976d220cea4ab3daf@eigenstate.org> Date: Sat, 8 Apr 2017 03:27:39 -0400 Subject: Re: [9fans] p9p: 9 ls /dev Topicbox-Message-UUID: b9758960-ead9-11e9-9d60-3106f5b1d025 This should be doable with some combination of fdopendir(3) and readdir(3). I'm not sure how to avoid leaking memory through the returned DIR pointer and any memory allocated with by readdir(3). This is usually free'd by closedir(3), which we can't use without closing the underlying file. It should be OK to use free() on the return value of fdopendir, and stick to the uglier readdir_r(3) interface. I can definitely see why Russ went with the simpler system-specific interfaces on this. David On Sat, Apr 8, 2017, at 02:46 AM, Ori Bernstein wrote: > On Sat, 8 Apr 2017 15:21:47 +0900, arisawa wrote: >=20 > > but how to? > >=20 > > unix doesn=E2=80=99t have something like fdreaddir(int fd). > > my guess: russ unwillingly used a low level function such as > > int getdirentries(int fd, char *buf, int nbytes, long *basep). > >=20 > > readdirall() might be OK in regular usage. >=20 > I don't use OSX regularly, although I do maintain the syscall > layer for Myrddin on it. >=20 > Getdirentries64 exists, and rudimentary testing doesn't show > any difficulties with using it. >=20 > --=20 > Ori Bernstein >=20