* How to open and write to a block driver within a character driver?
@ 2011-10-04 17:42 Yang Xiang
2011-10-04 17:46 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Yang Xiang @ 2011-10-04 17:42 UTC (permalink / raw)
To: kernelnewbies
I am taksed to develop a Block device driver which will be used within a character device driver so the write to the character driver will be also formatted, converted and duplicated to the block drvice.
I am new at this. And I am doing all this within kernel space so I really don't know I can open a block device without using "open" and "write" syscalls. I know there is a generic_make_request call to block driver but it requires the bio vec to be filled out with data and I don't know where to start on that.
Any quick solution to this plase?
Thanks so much in advance,
yx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111004/5f858f41/attachment.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-04 17:42 How to open and write to a block driver within a character driver? Yang Xiang
@ 2011-10-04 17:46 ` Greg KH
2011-10-04 17:52 ` Yang Xiang
0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2011-10-04 17:46 UTC (permalink / raw)
To: kernelnewbies
On Tue, Oct 04, 2011 at 10:42:15AM -0700, Yang Xiang wrote:
> I am taksed to develop a Block device driver which will be used within a
> character device driver so the write to the character driver will be also
> formatted, converted and duplicated to the block drvice.
Why? That really makes no sense. Please explain what type of problem
you are trying to solve with this design?
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-04 17:46 ` Greg KH
@ 2011-10-04 17:52 ` Yang Xiang
2011-10-04 18:04 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Yang Xiang @ 2011-10-04 17:52 UTC (permalink / raw)
To: kernelnewbies
The design is not up to me and I am just developing the code and I need to develop the filter layer to convert the character buf to bio vects. But I am wondering if there is a easy way to do this.
thanks,
yx
> Date: Tue, 4 Oct 2011 10:46:18 -0700
> From: greg at kroah.com
> To: pointyx at live.com
> CC: kernelnewbies at kernelnewbies.org
> Subject: Re: How to open and write to a block driver within a character driver?
>
> On Tue, Oct 04, 2011 at 10:42:15AM -0700, Yang Xiang wrote:
> > I am taksed to develop a Block device driver which will be used within a
> > character device driver so the write to the character driver will be also
> > formatted, converted and duplicated to the block drvice.
>
> Why? That really makes no sense. Please explain what type of problem
> you are trying to solve with this design?
>
> greg k-h
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111004/2ffab072/attachment.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-04 17:52 ` Yang Xiang
@ 2011-10-04 18:04 ` Greg KH
2011-10-06 22:43 ` Yang Xiang
0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2011-10-04 18:04 UTC (permalink / raw)
To: kernelnewbies
On Tue, Oct 04, 2011 at 10:52:33AM -0700, Yang Xiang wrote:
> The design is not up to me and I am just developing the code and I need to
> develop the filter layer to convert the character buf to bio vects. But I am
> wondering if there is a easy way to do this.
Then I suggest you push back on the design, just because someone told
you to do something incorrect, are you supposed to do it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-04 18:04 ` Greg KH
@ 2011-10-06 22:43 ` Yang Xiang
2011-10-06 23:03 ` Greg Freemyer
2011-10-07 3:09 ` Greg KH
0 siblings, 2 replies; 7+ messages in thread
From: Yang Xiang @ 2011-10-06 22:43 UTC (permalink / raw)
To: kernelnewbies
Hi Greg,
Let me rephrase my question then.
If I am in kernel space and in another device driver and I need to write a log entry of some sort to another block device, do I just perform an "open" and "write" as if I am in user space?
I am very new at this so bear with me on this.
Thanks in advance.
yx
> Date: Tue, 4 Oct 2011 11:04:09 -0700
> From: greg at kroah.com
> To: pointyx at live.com
> Subject: Re: How to open and write to a block driver within a character driver?
> CC: kernelnewbies at kernelnewbies.org
>
> On Tue, Oct 04, 2011 at 10:52:33AM -0700, Yang Xiang wrote:
> > The design is not up to me and I am just developing the code and I need to
> > develop the filter layer to convert the character buf to bio vects. But I am
> > wondering if there is a easy way to do this.
>
> Then I suggest you push back on the design, just because someone told
> you to do something incorrect, are you supposed to do it?
>
> thanks,
>
> greg k-h
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111006/58b97a65/attachment.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-06 22:43 ` Yang Xiang
@ 2011-10-06 23:03 ` Greg Freemyer
2011-10-07 3:09 ` Greg KH
1 sibling, 0 replies; 7+ messages in thread
From: Greg Freemyer @ 2011-10-06 23:03 UTC (permalink / raw)
To: kernelnewbies
On Thu, Oct 6, 2011 at 6:43 PM, Yang Xiang <pointyx@live.com> wrote:
> Hi Greg,
>
> Let me rephrase my question then.
>
> If I am in kernel space and in another device driver and I need to write a
> log entry of some sort to another block device, do I just perform an "open"
> and "write" as if I am in user space?
>
> I am very new at this so bear with me on this.
>
> Thanks in advance.
> yx
First, always post replies at the bottom of messages on kernel mailing
lists. Note how I had to delete much of the earlier thread in order to
reply properly.
Second,
If by log, you mean output text based log messages:
The standard behavior is you log your messages to the ring buffer.
(kprintf and family will do that for you.)
Then userspace pulls it out of the ring buffer and writes it to a file
(or block device). Your distro probably uses syslogd or rsyslogd for
the userspace side. It is highly configurable and you can setup a
dedicated logfile for just you.
If you mean more of a binary transaction log like a filesystem uses,
then it gets more complicated. There are very few kernel drivers that
maintain a transaction log on a dedicated block device. I don't know
how they do it, but I'd look at filesystem code the supports an
external partition for the transaction logs.
HTH
Greg (not KH)
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to open and write to a block driver within a character driver?
2011-10-06 22:43 ` Yang Xiang
2011-10-06 23:03 ` Greg Freemyer
@ 2011-10-07 3:09 ` Greg KH
1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2011-10-07 3:09 UTC (permalink / raw)
To: kernelnewbies
On Thu, Oct 06, 2011 at 03:43:08PM -0700, Yang Xiang wrote:
> Hi Greg,
>
> Let me rephrase my question then.
>
> If I am in kernel space and in another device driver and I need to write a log
> entry of some sort to another block device, do I just perform an "open" and
> "write" as if I am in user space?
No, you never do that, no device driver ever opens a file and writes to
it. It's that simple.
Please see the kernelnewbies.org site for more details about why this is
so.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-10-07 3:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-04 17:42 How to open and write to a block driver within a character driver? Yang Xiang
2011-10-04 17:46 ` Greg KH
2011-10-04 17:52 ` Yang Xiang
2011-10-04 18:04 ` Greg KH
2011-10-06 22:43 ` Yang Xiang
2011-10-06 23:03 ` Greg Freemyer
2011-10-07 3:09 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.