From: | Eirik Nygaard <eirikn@xxxxxxxxxxxx> |
Date: | Sat, 22 Nov 2003 11:53:30 +0100 |
I am working on removing perlism in userland and have come over a little problem when I am rewriting sockstat. I try to get all the open fd's from the kern.file sysctl with this code: void get_files(void) { size_t size; if (sysctlbyname("kern.file", NULL, &size, NULL, 0) < 0) err(1, "sysctlbyname()"); if ((files = malloc(size)) == NULL) err(1, "malloc()"); if (sysctlbyname("kern.file", files, &size, NULL, 0) < 0) err(1, "sysctlbyname()"); nfiles = size / sizeof(struct file); { int i; for(i = 0; i < nfiles; i++) printf("Type: %d\n", files[i].f_type); } } but it only gives me bogus results for some reason. Output: Type: -16333 Type: -14424 [...] Type: -14424 Would be grateful if someone knows what I am doing wrong here. -- Eirik Nygaard eirikn@xxxxxxxxxxxx
Attachment:
pgp00011.pgp
Description: PGP signature