mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] read() from driverfs files can read more bytes
@ 2002-02-07 18:15 Petr Vandrovec
  2002-02-07 18:27 ` Patrick Mochel
  0 siblings, 1 reply; 11+ messages in thread
From: Petr Vandrovec @ 2002-02-07 18:15 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: linux-kernel

On  7 Feb 02 at 9:43, Patrick Mochel wrote:
> > And neither of driverfs_read_file nor driverfs_write_file supports
> > semantic we use with other filesystems: If at least one byte was 
> > read/written, return byte count (even if error happens). Only if zero 
> > bytes was written, return error code.
> 
> I would think that you would want to return the error code. Say you did:
> 
> echo "action parameter" > file
> 
> and 'parameter' is an invalid parameter, as determined by the driver. It 
> would require another arbitrary check to determine if the command 
> succeeded or not if it returned the number of bytes written. Returning 
> -EINVAL lets userspace know that it made a boo-boo. Is that not good?

If you want bidirectional communication, something like SOCK_SEQPACKET
or SOCK_DGRAM is better suitable. And if we learn open() to open
unix sockets, even 'echo' can be still used for configuring. I understand 
that it is radical change, but why these configuration points should
look like real files if they are not ones? And you do not have troubles
with supporting lseek() on them - if contents of file is "minutes\n",
is it correct to do lseek(fd, 1, SEEK_SET); write(fd, "onths\n", 6);
or is it incorrect usage?

If you do not want to change these objects from files to sockets,
I agree with your explanation for write(). But I do not agree with this
semantic for read() - reading byte after byte, and reading in one big 
chunk should not yield in different results on regular files, otherwise 
couple of nasty surprises is hidding there.
                                    Thanks,
                                        Petr Vandrovec
                                        vandrove@vc.cvut.cz
                                        

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH] read() from driverfs files can read more bytes
@ 2002-02-07 20:11 Petr Vandrovec
  2002-02-07 20:21 ` Patrick Mochel
  0 siblings, 1 reply; 11+ messages in thread
From: Petr Vandrovec @ 2002-02-07 20:11 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: linux-kernel

On  7 Feb 02 at 10:27, Patrick Mochel wrote:

> Concerning reading/writing from offsets, it's up to the drivers for them 
> to either support it or not. In the files I've done so far, I return 0 if 
> show() is called with an offset. Which will give different results if you 
> read byte-by-byte or an entire chunk. 
> 
> It makes the callbacks simpler, but it is not technically correct. 

What about extremelly nice stuff Al Viro made for us in
fs/seq_file.c ? It made putting stuff into procfs really easy...
                                            Petr Vandrovec
                                            vandrove@vc.cvut.cz
                                            
 

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH] read() from driverfs files can read more bytes
@ 2002-02-07 18:11 Thomas Hood
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Hood @ 2002-02-07 18:11 UTC (permalink / raw)
  To: linux-kernel

> Can you also check for size >= PAGE_SIZE on enter
> to entry->show() procedure?

FYI I recently wrote a patch for procfs which addresses a
similar problem there.  See the link at:
   http://panopticon.csustan.edu/thood/pnpbios.html

--
Thomas Hood



^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH] read() from driverfs files can read more bytes
@ 2002-02-07 17:25 Petr Vandrovec
  2002-02-07 17:43 ` Patrick Mochel
  0 siblings, 1 reply; 11+ messages in thread
From: Petr Vandrovec @ 2002-02-07 17:25 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: linux-kernel

On  7 Feb 02 at 8:45, Patrick Mochel wrote:
> On Thu, 7 Feb 2002, Andrey Panin wrote:
> > Attached patch adds check that returned value is less then requested 
> > byte count. I know that actual callback function device_read_status()
> > should also be fixed, but I found this bug after midnight and 
> > decided to sleep a little :)
> 
> That sanity check was in there, once upon a time. However, in moving the 
> weight from the driver callbacks to the driverfs read_file() and 
> write_file(), it must have got dropped...
> 
> Thank you. It's been applied and will be pushed forward.

[I have only 2.5.3 sources here yet]

Can you also check for size >= PAGE_SIZE on enter to entry->show()
procedure? It looks ugly to me that each driver has to check for this
constant unless it wants to smash some innocent kernel memory.

And neither of driverfs_read_file nor driverfs_write_file supports
semantic we use with other filesystems: If at least one byte was 
read/written, return byte count (even if error happens). Only if zero 
bytes was written, return error code.
                                Thanks,
                                            Petr Vandrovec
                                            vandrove@vc.cvut.cz


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

end of thread, other threads:[~2002-02-08 21:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-07 18:15 [PATCH] read() from driverfs files can read more bytes Petr Vandrovec
2002-02-07 18:27 ` Patrick Mochel
2002-02-08 19:18   ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2002-02-07 20:11 Petr Vandrovec
2002-02-07 20:21 ` Patrick Mochel
2002-02-07 20:26   ` Alexander Viro
2002-02-07 20:59     ` Patrick Mochel
2002-02-07 21:37       ` Alexander Viro
2002-02-07 18:11 Thomas Hood
2002-02-07 17:25 Petr Vandrovec
2002-02-07 17:43 ` Patrick Mochel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®