Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6767785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:59:33+00:00 2026-05-26T14:59:33+00:00

For a university assignment, we have to modify the ext2 file system to store

  • 0

For a university assignment, we have to modify the ext2 file system to store files in the inode’s block pointers if it’s smaller than 60 bytes, and move to regular block storage once the file grows larger than that.

I copied the ext2 code from the 2.6 linux kernel source (as instructed) and went from there.

When the file grows larger than 60 bytes, I need to copy any data that is currently in the inode’s block pointer array into real blocks. So, I need to write kernel memory into ext2 blocks. A simple call to do_sync_write won’t work here because it takes user-space memory.

I’ve looked at the implementation of do_sync_write and I’m not really sure how to replicate what it does, but with kernel memory instead.

This is my current implementation of this specific part (does not work):

ssize_t extmod_write(struct file *filp, const char *buf,
            size_t len, loff_t *ppos)
{
...
printk(KERN_INFO "Switching to regular file");
temp = kmalloc(inode->i_size, GFP_KERNEL);
memcpy(temp, EXT2_I(inode)->i_data, inode->i_size);

/* Need to clear the block pointers before they are allocated by kernel */
memset(EXT2_I(inode)->i_data, 0, sizeof(EXT2_I(inode)->i_data));

if (do_sync_write(filp, temp, inode->i_size, &dummy) < 0) {
    printk(KERN_INFO "DAMN! Writing current buffer failed");
    return -EINVAL;
}
kfree(temp);
return do_sync_write(filp, buf, len, ppos);

Edit:

I looked at symlinks. Basically, ext2 has the concept of “fast symlinks”; i.e. the link name is less than 60 bytes long. If it’s a fast symlink, the data gets stored in the block pointers. This is easy to do and I’ve already implemented this for regular files. If the link is a not a fast symlink, the data is handled the same way as regular files. I think I’m back to square one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:59:34+00:00Added an answer on May 26, 2026 at 2:59 pm

    I managed to figure it out. It required getting struct buffer_head instances and reading/writing the data in them. By looping through the logical block numbers and using to ext2_get_block to retrieve blocks (allocating them if necessary) and then using sb_getblk to get the real buffer out and write to it. I’ve posted an implementation on my blog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my university assignment I have to design some basic managment system for sicknesses
For my university assignment I have to make a networkable version of pacman. I
I have written a C++ program for a University assignment. I used Netbeans 6.8
I have to write a multiplayer pacman game in Java for a university assignment
The university I work at uses Oracle for the database system. We currently have
I have an assignment at university, and I have started developing for this in
So I have this University assignment in which I have to create a trigger
Hi I have a been set an assignment in university for which i have
For a university assignment I have been assigned I have a Prize object which
I have been given an assignment for university where i have to read from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.