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 shoul

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 t

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 somew