tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Some beginner questions relating to cgd-on-root



Hello,

I'm trying to figure out how to configure a cgd device on boot. Since this is my first kernel project, I would appreciate some help; mostly I need to understand some concepts, and get pointers to where I can find more information.

While reading this mail, keep in mind that I'm in a "pre root" context. I'm trying to set up a cgd device so that setroot() can be configured to use it.

As a first step, I thought I'd simply hard code a stored-key parameter "file" in the kernel and use it to configure the cgd device. The goal is to replicate the above behavior on kernel init.

   Questions which have surfaced so far:

- Does the kernel at all work with file descriptors? As far as I can gather, file descriptors are for userland (tightly tied to the vfs stuff).

- Is it conceptually ok to call a pseudo-device's functions directly? I.e. can cgdopen() be called directly, or should one go via some higher level kernel function? In the latter case, which function would one use? I get the feeling that the open() syscall does more than merely pass along the call to the appropriate device specific open() handler.

- How does one do something akin to a "read()" in the kernel (remember, no root has been set up yet). sbin/cgdconfig/cgdconfig.c does this:
        -----------------------
        ret = pread(fd, buf, 8192, 0);
        if (ret < 0) {
                warn("can't read disklabel area");
                return -1;
        }
        -----------------------
But since there's no vfs stuff, no user land, read() seems to be out of the question. Related to the previous question, I guess one could set up the proper structures and call cgdread() manually, but those structures seem seem to be somewhat of a pain to set up. If that's what I need to do, is there prior art somewhere?

   Thankful for any pointers.


--
Kind regards,
Jan Danielsson


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index