Yes, this is homework. No, I don't want /prog/ to do it for me, I'm simply not quite sure how to do something and would like a push in the right direction or a reference of some sort.
In brief, I am implementing a new syscall in the Linux kernel, and I need to get the user making the system call. Poking around told me that it is better to get the UID with getuid() because the kernel doesn't know about usernames, but how do I then get the username?
I hate this course, we learn general theory about operating system design (which is great) but then suddenly we are told to do specific modifications in the Linux kernel without having been taught the basics of how things work in the Linux kernel. i have no aversion to learning on my own, but that is a LOT to learn in a couple weeks' time with a full schedule.
Anyway, any gentle nudge in the right direction would be greatly appreciated.
Name:
Anonymous2009-10-10 5:34
Oh and before anyone comments, yes, I've looked around a lot on my own, including looking through the Linux kernel API as available online and I haven't found what I need, unless I missed something.
__________________________________ http://bayimg.com/image/aadbjaace.jpg
Now Playing:The End of All Hope by Nightwish
My Blog: http://frozenvoid.blogspot.com/
«Death cannot be struggled against, brother. It ever arrives, defiant of every hiding place, of every frantic attempt to escape. Death is every mortal's shadow, his true shadow, and time is its servant, spinning that shadow slowly round, until what stretched before one now stretched before him.»
Thanks for the replies, but I think I phrased my problem incorrectly - sorry, I'm tired.
The code I'm writing runs in the kernel, and I need to get the username of the user that made the system call. In the function I wrote, how might I go about finding out which user has called the function? I looked at getuid() for example, but that returns the UID of the current process, and therefore doesn't make sense to call within the kernel.
I am getting data from user space memory, so my first thought was whether there is some way to check which process (and thus which UID and which username) is associated with the memory being passed, I'm still googling but I haven't found anything.
Name:
Anonymous2009-10-10 5:59
Why would you need username? uid is all you need. If you need actual user name from /etc/passwd in your syscall, you made some serious mistake while designing it.
>>6
ah. i think i understand now.
the system call should be passed a pointer to a structure (a thread struct in freebsd).
you should be able to get the uid from that.
i've never done this so i don't know for sure, but i would start by looking at what that structure contains if i was you.