kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: martinez.javier@gmail.com (Javier Martinez Canillas)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Getting a block from a block device?
Date: Tue, 8 Nov 2011 13:08:41 +0100	[thread overview]
Message-ID: <CAAwP0s3NczSfkeY-LQ-dGMCWxDJ1QFm-s+X1WP9ZZK4XqTPBFA@mail.gmail.com> (raw)
In-Reply-To: <CAAfuxnKBfMNusYQ4VDX=GNc5KcjgmE8Wk9Jk-NtiiaXycHhA3g@mail.gmail.com>

On Tue, Nov 8, 2011 at 12:06 PM, Dan Luedtke <maildanrl@googlemail.com> wrote:
> Hallo everyone,
>
> could someone please give me a hint on how to get a block (e.g. 512
> bytes) from a block device from a kernel module?
>
> What .txt should I consult? Which headerfiles must I include?
> Where can I find the required function's definitions?
>
> In userspace I used fopen() with the device path as filename, I bet it
> isn't that easy in kernel mode.
>

Well even when is not considered a good practice, you can invoke the
file operations syscall handlers from your module.

Look at this LJ article: http://www.linuxjournal.com/node/8110/print

But I think that the right question is not _how_ to do it but _why_.

The kernel can't assume a filesystem layout and the location of a file.

Can you tell what are you trying to achieve? Maybe there are better
ways to do it.

Best regards,

-- 
Javier Mart?nez Canillas
(+34) 682 39 81 69
Barcelona, Spain

      parent reply	other threads:[~2011-11-08 12:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 11:06 Getting a block from a block device? Dan Luedtke
     [not found] ` <CACzurzsCpKN_9Ew+g-HLvH=GuPQU=Tzf8yrimf-zDOjPtFsF2w@mail.gmail.com>
2011-11-08 11:56   ` Dan Luedtke
2011-11-08 11:59     ` rohan puri
2011-11-08 12:28       ` mani
2011-11-08 14:02         ` Dan Luedtke
2011-11-08 15:18           ` Manish Katiyar
2011-11-09  4:54             ` rohan puri
2011-11-09  7:32               ` Dan Luedtke
2011-11-08 12:12     ` Alexandru Juncu
2011-11-08 12:21       ` Stephen Gream
2011-11-08 12:08 ` Javier Martinez Canillas [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=CAAwP0s3NczSfkeY-LQ-dGMCWxDJ1QFm-s+X1WP9ZZK4XqTPBFA@mail.gmail.com \
    --to=martinez.javier@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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).