Re: driverfs API Updates

From: Patrick Mochel (mochel@osdl.org)
Date: Tue Aug 06 2002 - 11:48:33 EST


> > DEVICE_ATTR(name,"strname",mode,show,store);
>
> Do you any plans to simplify the show or store interfaces?

Yes. But, I'm not sure how I want to do it. A while back, I converted it
to use the seq_file interface, with a (probably broken) implementation of
seq_write(). I'm not sure how well it would fit into what we have now, but
I definitely agree that it should be simpler.

> Passing a single page or two (4k to 8k buffer), with no offset, and letting
> the driverfs_read_file fill buf might be OK, but breaks seeks (and short
> buffer usage), but at least the show/restore functions would be less likely
> to be broken. Limiting the offset to a fit in a page might help.
>
> If the show and store interfaces could return a pointer, lengths, and
> a specifier ("%s", "%d", etc.), that might be pretty simple, and would
> allow for correct offset and overflow checks.

The seq_file interface would allow for that.

One purely evil solution might be to just pass a zero'd page-sized buffer
to be filled one time. We then do strlen() on it for the size, and copy
what the user wants. It would still require some extra state, but it would
force people to stick to ASCII, instead of trying to sneak in some binary
data ;)

> Most of the current show interfaces are broken for a short buffer or seek,
> and they are being copied to create new interfaces, example usage:
>
> [patman@elm3a50 linux-2.5.29-p1]$ cat /devices/root/pci0/00:0f.2/name
> PCI device 1166:0220
> [patman@elm3a50 linux-2.5.29-p1]$ dd if=/devices/root/pci0/00:0f.2/name of=/tmp/xx bs=1 count=10 ; cat /tmp/xx ; echo
> 1+0 records in
> 1+0 records out
> P

Yeah, that's definitely broken.

> For the above to function I also had to change:

Thanks, applied.

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 07 2002 - 22:00:31 EST