services: herdd: getdents test
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/remote.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
static void *thread_func(void *arg)
|
static void *thread_func(void *arg)
|
||||||
{
|
{
|
||||||
@@ -13,6 +16,8 @@ static void *thread_func(void *arg)
|
|||||||
|
|
||||||
int main(int argc, const char *argv[], const char *envp[])
|
int main(int argc, const char *argv[], const char *envp[])
|
||||||
{
|
{
|
||||||
|
sys_remote_set(SYS_REMOTE_NSD, 0, 0);
|
||||||
|
|
||||||
kern_logf("herdd");
|
kern_logf("herdd");
|
||||||
kern_logf("args:");
|
kern_logf("args:");
|
||||||
|
|
||||||
@@ -29,6 +34,28 @@ int main(int argc, const char *argv[], const char *envp[])
|
|||||||
kern_logf("self = %p", pthread_self());
|
kern_logf("self = %p", pthread_self());
|
||||||
errno = 200;
|
errno = 200;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
int dir = open("/", 0);
|
||||||
|
if (dir >= 0) {
|
||||||
|
kern_logf("opened '/'");
|
||||||
|
char buf[4096] = {0};
|
||||||
|
struct dentry *dent = (struct dentry *)buf;
|
||||||
|
long len = getdents(dir, dent, sizeof buf);
|
||||||
|
if (len < 0) {
|
||||||
|
kern_logf("getdents failed (%s)", strerror(errno));
|
||||||
|
} else {
|
||||||
|
for (long i = 0; i < len;) {
|
||||||
|
dent = (struct dentry *)(buf + i);
|
||||||
|
kern_logf(" - %s", dent->d_name);
|
||||||
|
i += dent->d_reclen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(dir);
|
||||||
|
} else {
|
||||||
|
kern_logf("open() failed: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
pthread_create(&thread, NULL, thread_func, (void *)0xdeafcafe);
|
pthread_create(&thread, NULL, thread_func, (void *)0xdeafcafe);
|
||||||
kern_logf("started thread %p", thread);
|
kern_logf("started thread %p", thread);
|
||||||
@@ -36,8 +63,5 @@ int main(int argc, const char *argv[], const char *envp[])
|
|||||||
pthread_join(thread, &ret);
|
pthread_join(thread, &ret);
|
||||||
kern_logf("thread returned %p", ret);
|
kern_logf("thread returned %p", ret);
|
||||||
|
|
||||||
kern_logf("errno...");
|
|
||||||
kern_logf("%u", errno);
|
|
||||||
kern_logf("...errno");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user