kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: mulyadi.santosa@gmail.com (Mulyadi Santosa)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Clarification regarding design of a device.
Date: Fri, 6 May 2011 06:22:07 +0700	[thread overview]
Message-ID: <BANLkTikwmaK1J9SDBOs=o6+2z266nNs2aQ@mail.gmail.com> (raw)
In-Reply-To: <201105060006.10751.mindentropy@gmail.com>

Hi :)

On Fri, May 6, 2011 at 01:36, mindentropy <mindentropy@gmail.com> wrote:
>
> Sounds silly but how do I get access to the file descriptor?

to the best I know, kernel assign it for you and you access it from
the give file structure. For example, look at open handler
fs/proc/cpuinfo.c. You will see these:
static int cpuinfo_open(struct inode *inode, struct file *file)

Ok, I revise, perhaps not filedescriptor, but file structure itself.

> Also If I make the user create a session for an operation similar to this
> paper
> http://www.usenix.org/event/usenix03/tech/full_papers/keromytis/keromytis_html/node8.html#SECTION00042000000000000000,
> should I remove the read, write operations and do all operations using ioctl
> commands i.e. reading the user buffer etc?
>

There's a plus and minus of simply using ioctl for all read and write.
IMHO, ioctls are needed if you need various "sub command" toward the
device file, i.e if I took KVM for example: to setup new guest
structure, to ask for memory and so on. So, if you don't really need
to do such "extra" things, I believe it's better to still use
read/write handler for read/write operation.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

      reply	other threads:[~2011-05-05 23:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 17:23 Clarification regarding design of a device mindentropy
2011-05-02 17:28 ` Mulyadi Santosa
2011-05-02 18:02   ` mindentropy
2011-05-05 18:36   ` mindentropy
2011-05-05 23:22     ` Mulyadi Santosa [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='BANLkTikwmaK1J9SDBOs=o6+2z266nNs2aQ@mail.gmail.com' \
    --to=mulyadi.santosa@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).