Re: [9fans] p9p: 9 ls /dev

2017-04-08 Thread arisawa
thanks david. using dup() is very nice idea! your code works with CFLAGS=-D__DARWIN_64_BIT_INO_T # manual is wrong and a fix: // buf = ((char*)buf) + d_reclen(buf); buf = (struct dirent *)(((char*)buf) + d_reclen(buf)); and adding #define NAME_MAX 256 in

Re: [9fans] p9p: 9 ls /dev

2017-04-08 Thread David Arroyo
Ignore my previous post, I was tired and forgot about dup(). How about something like this? (attached) I only tested this on Ubuntu, I don't have an OS X machine. I still went with readdir_r because the AIX and Solaris man pages for readdir were vague about its behavior when called from multiple

Re: [9fans] p9p: 9 ls /dev

2017-04-08 Thread David Arroyo
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

Re: [9fans] p9p: 9 ls /dev

2017-04-08 Thread Ori Bernstein
On Sat, 8 Apr 2017 15:21:47 +0900, arisawa wrote: > but how to? > > unix doesn’t 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). > > readdirall() might be

Re: [9fans] p9p: 9 ls /dev

2017-04-08 Thread arisawa
but how to? unix doesn’t 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). readdirall() might be OK in regular usage. > 2017/04/08 13:06、Lyndon Nerenberg のメール: >