Bat
Bat

Reputation: 833

Getting username of current user in kernel space

I'm trying to implement a system call which prints hello "current username". I tried using getpwuid(getuid()) but didn't work cause I was unable to include pwd.h or unistd.h or sys/types.h. I currently have no idea how to do the work.

Upvotes: 2

Views: 914

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66061

Linux kernel has no notion about username; it knows only user identificator (uid).

Mapping from uid to username is contained in user database, which is stored as a file /etc/passwd. You need to parse this file for extract username.

Upvotes: 2

Related Questions