From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Hudec Subject: Re: userspace buffer in read/write system call Date: Sat, 20 May 2006 18:23:32 +0200 Message-ID: <20060520162332.GC4128@efreet.light.src> References: <20060519140148.93081.qmail@web37211.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bAmEntskrkuBymla" Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from cimice0.lam.cz ([212.71.168.90]:51380 "EHLO cimice.yo.cz") by vger.kernel.org with ESMTP id S1751421AbWETQXf (ORCPT ); Sat, 20 May 2006 12:23:35 -0400 To: UZAIR LAKHANI Content-Disposition: inline In-Reply-To: <20060519140148.93081.qmail@web37211.mail.mud.yahoo.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org --bAmEntskrkuBymla Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 19, 2006 at 07:01:48 -0700, UZAIR LAKHANI wrote: > Hello All, >=20 > 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 >=20 > ssize_t (*read) (struct file *, char *, size_t, loff_t > *); >=20 > 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. >=20 > Consider what I am doing now is >=20 > static ssize_t > foo_read(file_t *file, char *buf, size_t count, loff_t > *ppos) > { > ... > char __user local_buffer[10]; //TODO > count =3D 10; // setting a new count=09 >=20 > // read_XXX below is to be taken as a function that=20 > // will do read for us e.g. generic_file_read can be=20 > // such a function > err =3D read_XXX( file, local_buffer, count, ppos); >=20 > // now copy local_buffer into buf=20 > ... >=20 > // the err is -14 or BAD ADDRESS > return err; > } >=20 > Any help regrading this is welcome. >=20 > Thanks, > Uzair Lakhani, > Karachi, Pakistan. >=20 >=20 > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around=20 > http://mail.yahoo.com=20 > - > 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 --=20 Jan 'Bulb' Hudec --bAmEntskrkuBymla Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFEb0KERel1vVwhjGURAuz+AKDbOV7BLLQC25XSZZvv+aL1m7vp6wCdHPU0 eEHFqATqjpNCo66a3S5SfWQ= =0KOr -----END PGP SIGNATURE----- --bAmEntskrkuBymla--