site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=iW2oyeosZ94gO9X53mfdJJO2uMmE4SnsDK64Gsks1JaSjHsoWE6sygyHdA866EOafqYb3oNMQJZWbhraDtey1ZgjiK/PO0M2s/QpG4HvHrtEgM0xRisZjFyt/b7SWpbD2J4HjFR90q2aNUxHf7mAzYmK5tvZ6wvV7qzAnXzHfRw=; I don't have a direct answer to your problem, but couldn't you look at the source code of lsof and see what it does with the data? http://www.opensource.apple.com/darwinsource/ -T --- anukriti_shrimal <anukriti_shrimal@persistent.co.in> wrote:
Hi All,
I am currently working on Mac Os X 10.4.7.
I m trying to retrieve the list of files opened by a process using sysctl(). The code snippet that I've written is :
void* pBuff = NULL ;
mib[0] = CTL_KERN;
mib[1] = KERN_FILE;
size = sizeof(struct filedesc) ; // This is what I tried. This struct is defined in file sys/filedesc.h
pBuff = malloc(size) ;
while (sysctl((int *)mib, 2, pBuff, &size, NULL, 0) < 0)
{
if (errno == ENOMEM)
{
printf("Not sufficient memory allocated\n");
}
size *= 2 ;
if ((arguments = realloc(pBuff, size)) == NULL)
{
printf("Realloc error\n");
}
printf("Error in getting file struct %s\n and error no is %d\n", strerror(errno),errno) ;
}
This code compiles and fills the buffer pBuff.
Now my question is that the buffer pBuff should to mapped to which structure on Mac 10.4.7??
I have found that it fills struct file or struct xfile on Free BSD. But on Mac Os, I've tried it with struct extern_file and struct filedesc, but both didn't work. Why are the two structs 'file' and 'xfile' not exposed on Mac 10.4.7?
If none of the above, then which struct is getting filled by the above sysctl call?
I know that there is an alternative way to do the same task, i.e., through lsof. But my project constraints don't let me use that. Also, when I saw the ktrace dump of lsof, I found that it also uses sysctl.
Is there some other way to do the same task?
Thanks in advance,
Princess
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/dj_thorrin71%40yahoo.co...
This email sent to dj_thorrin71@yahoo.com
"Everyone is allergic to giant rocks hitting them in the head!" -Thorrin's elf chick after casting a 'meteor swarm' spell ;) ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com