linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* userspace buffer in read/write system call
@ 2006-05-19 14:01 UZAIR LAKHANI
  2006-05-19 14:20 ` Dave Kleikamp
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: UZAIR LAKHANI @ 2006-05-19 14:01 UTC (permalink / raw)
  To: linux-fsdevel

Hello All,

Suppose I want to implement read/write file operations
of a simple file system. Consider the read system
call. The file system's struct file_operations
function that will be called is this

ssize_t (*read) (struct file *, char *, size_t, loff_t
*);

The char * in the arguments of read is a user-space
buffer pointer. Suppose I don't want to send this
buffer that we have got to the generic_file_read
function or some other function and instead want to
create a new buffer and send it to the
generic_file_read (or other) function. Then copy this
buffer that we have sent to the generic_file_read to
the actual buffer that we had received so that the
call can be completed and the buffer received is
filled.

Consider what I am doing now is

static ssize_t
foo_read(file_t *file, char *buf, size_t count, loff_t
*ppos)
{
	...
	char __user local_buffer[10];	//TODO
	count = 10;			// setting a new count	

	// read_XXX below is to be taken as a function that 
	// will do read for us e.g. generic_file_read can be 
	// such a function
	err = read_XXX( file, local_buffer, count, ppos);

	// now copy local_buffer into buf 
	...

	// the err is -14 or BAD ADDRESS
	return err;
}

Any help regrading this is welcome.

Thanks,
Uzair Lakhani,
Karachi, Pakistan.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-20 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-19 14:01 userspace buffer in read/write system call UZAIR LAKHANI
2006-05-19 14:20 ` Dave Kleikamp
2006-05-19 16:31 ` Bryan Henderson
2006-05-20 16:23 ` Jan Hudec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).