LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-11-2010, 07:31 AM   #1
kindlike
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
How to get the current user's id when in write() function in kernel bin.c


I want to modify the write() function located in bin.c file in linux kernel and want to access the current user's id at that place. write() function code as follows in bin.c:

static ssize_t write(struct file *file, const char __user *userbuf,
size_t bytes, loff_t *off)

{ struct bin_buffer *bb = file->private_data;
struct dentry *dentry = file->f_path.dentry;
int size = dentry->d_inode->i_size;
int uid=dentry->d_inode->i_uid;
loff_t offs = *off;
int count = min_t(size_t, bytes, PAGE_SIZE);
char *temp;

...
/*want to access current user's id here*/
}

But I don't know how to access the user's id.

Any help?Thanks a lot.
 
Old 01-16-2010, 04:24 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
There is a command named id !
Code:
anisha@linux:~> id
uid=1000(anisha) gid=100(users) groups=26(postgres),33(video),100(users),114(vboxusers)
Code:
anisha@linux:~> id -u
1000
Ever thought of creating a process through the function system() so that it executes the command id and thus gives you the user id!

Last edited by Aquarius_Girl; 01-16-2010 at 04:29 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GNOME: Gain privileges using current user's password instead of root's password maxkukartsev Fedora 5 02-10-2012 09:46 AM
sis191 ethernet controller failing to function with current kernel/drivers OnlyPeroxide Linux - Networking 8 12-21-2010 08:06 PM
sudo requires current user's password robogymnast Linux - General 5 08-04-2008 08:14 AM
which linux c function can change user's passwd henryluo Programming 1 07-15-2005 10:16 PM
write function cxel91a Programming 4 01-15-2004 11:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration