linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Hudec <bulb@ucw.cz>
To: UZAIR LAKHANI <uzairr_bs1b@yahoo.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: userspace buffer in read/write system call
Date: Sat, 20 May 2006 18:23:32 +0200	[thread overview]
Message-ID: <20060520162332.GC4128@efreet.light.src> (raw)
In-Reply-To: <20060519140148.93081.qmail@web37211.mail.mud.yahoo.com>

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

On Fri, May 19, 2006 at 07:01:48 -0700, UZAIR LAKHANI wrote:
> 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

Particularly to generic_file_read you **DO** want to pass it --
generic_file_read takes a user-space address just like the read file
operation. In fact some filesystems assign generic_file_read directly to
their read file operation slot.

> create a new buffer and send it to the
> generic_file_read (or other) function. Then copy this

Just have a look in any other filesystem. Does it do anything like that?!?!

> 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 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      parent reply	other threads:[~2006-05-20 16:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060520162332.GC4128@efreet.light.src \
    --to=bulb@ucw.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=uzairr_bs1b@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).