Find the answer to your Linux question:
Results 1 to 3 of 3
Dear All, I have a buffer_head object (struct buffer_head) in my driver code. I want to take a copy of this structure object which is independent of address space. In ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Location
    Bangalore
    Posts
    7

    How to clone buffer_head structure for different cpu cores?


    Dear All,

    I have a buffer_head object (struct buffer_head) in my driver code. I want to take a copy of this structure object which is independent of address space. In other words how to create per cpu buffer_head structure objects.

    Example:

    struct buffer_head *bh1, *bh2;

    I have some data in bh1 object. I want a copy of this data in bh2 also. This copy doesn´t mean that bh2 is another reference for bh1. It should be totally independent of bh1 in terms of memory allocation.

    Please give me your suggestions...

    Regards,
    Sundar

  2. #2
    Just Joined!
    Join Date
    May 2008
    Posts
    36
    You mean make a deep copy?
    Just allocate new memory and copy all of the struct elements one by one.

  3. #3
    Just Joined!
    Join Date
    Sep 2005
    Location
    Bangalore
    Posts
    7
    I tried that, but i am getting "Segmentation fault". Actually i have a block device and i want to copy the contents from the block device to one temproray buffer for some operations. In most of the driver and file system code, kernel developers are using buffer_head structure to do this.

    In the sameway i am also trying the buffer_head structure. Here the ordinary memory allocation and memcopy will not help. We need to find some other way to allocate space for buffer_head structure and also the copy operation between two buffer_head structures.

    If you have any suggetions to do this, please help me.

    Thanks

Posting Permissions

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