Find the answer to your Linux question:
Results 1 to 5 of 5
Hello Developers, I am currently attempting to modify the bio struct in bio.h for linux-3.2.0. All I need to do to this structure, at the moment, is add an additional ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    11

    Modifying the bio struct (in bio.h)


    Hello Developers,

    I am currently attempting to modify the bio struct in bio.h for linux-3.2.0. All I need to do to this structure, at the moment, is add an additional integer variable to the existing structure, but simply adding "int var;" to the struct leads to an error while booting.

    Specifically, the boot sequence stops with:

    Gave up wiating for root device. Common problems:
    - Boot args
    - check rootdelay= ...
    - check root= ...
    - missing modules (cat /proc/modules; ls /dev)

    ALERT! /dev/disk/by-uuid/15448888-84a0-4ccf-a02a-0feb3f150a84 does not exist. Dropping to a shell!

    BusyBox Built In Shell ...
    (initramfs)

    I explored the file system with BusyBox and the target disk is not perceivable (whether by UUID or otherwise).

    Since all I have done is add a variable and re-compile my best guess is that the struct is no longer being allocated correctly when used, as the size will have changed. I have had no success in troubleshooting this error and so, naturally, I go to the internet.

    Would anyone have any insight as to what may be happening or how to fix it? I would also appreciate any suggestions as to how to properly go about such things in the future.

    Thank you,

    -Misiu

  2. #2
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    345
    Well... no one else has said anything yet, so I'll have a go.

    I'm no kernel expert, but I know that the kernel keeps structs aligned perfectly. If you add a byte, or 4 bytes to a struct, you need to compensate some way. It's not the same as normal C coding where everything is very forgiving of sloppy structs that come in at 37 bytes or something.

    Ever noticed those reserved pointers that bluff the struct up to 64 or 128 bytes or something. Try adding 8 ints instead of 1 and see what happens. But the problems could be elsewhere, that something else is expecting your struct to fit exactly into 64/128/256/etc bytes. It's what happens when things are trying to be super efficient.

    I believe you're getting into the deep magic of kernel hacking.

    Good luck.

  3. #3
    Just Joined!
    Join Date
    May 2012
    Posts
    11
    Hello Miven,

    Thanks for your reply. I will experiment with some different sizes, and will pay special attention to the allocation and initialization functions relating to the struct to see if I can find what you mentioned. (I was doing similar things already, but it certainly helps to have a proper idea as to what I might be looking for).

    Any suggestions as to how I might debug a related situation? My instinct tells me that if the kernel is crashing due to data being misaligned there should be some sort of indication.

    Thanks for your help,

    -Misiu

  4. #4
    Just Joined!
    Join Date
    May 2012
    Posts
    11
    I have tried experimenting with some different variable sizes to no avail. I am continuing to comb the allocation functions (which tend to send me on a merry chase involving mem-pools and other allocations), but have not found anything that might indicate the problem. If anyone has any other suggestions, specifically any regarding to how I might debug, or glean more information about, my problem, please let me know.

    -Misiu

  5. #5
    Just Joined!
    Join Date
    May 2012
    Posts
    11
    I think I managed to fix my problem. I re-configured the kernel to build in the SATA drivers, as opposed to leaving them as loadable modules and it now boots. I don't know why my changes caused such a problem, but it seems to have just been a configuration issue.

    To clarify with anyone dealing with similar issues, I discussed with some professional kernel developers and they mentioned that the compiler will handle any alignment issues, and that it should not be a concern for the developers at this stage. Thanks for the suggestion Miven, but it turned out to be configuration related.

    -Misiu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •