0

after successfully reading the file inode with this:

retval = ext2fs_read_inode_full(current_fs, inode, inode_buf, EXT2_INODE_SIZE(current_fs->super));
if (retval) {
    fprintf(stderr, "Failed to read inode\n");
    free(fs);
    free(inode_buf);
    return retval;
}

(At this point I have verified the inode contains the correct data of the file in question)

I immediately attempt to write it back with this :

  retval = ext2fs_write_inode_full(current_fs, inode, inode_buf, EXT2_INODE_SIZE(current_fs->super));
  if (retval) {
      fprintf(stderr, "Failed to write inode %d\n", retval);
  }

(Of course it's my intention to change some date values in the inode before writing back)

But ext2fs_write_inode_full returns an error value 2133571349.

The program executes with root privileged!

WallyZ
  • 326
  • 2
  • 17
  • Have you looked at the documentation fully? [libext2fs - Manual](http://www.giis.co.in/libext2fs.pdf) I ask, because tinkering with it, I don't even get the filesystem open. There is a project on [github - planetlabs / crtime](https://github.com/planetlabs/crtime/blob/master/crtime.c) that may be helpful. Hopefully others will have more specifics. – David C. Rankin Mar 27 '20 at 07:33
  • I used the code from crtime as my base. I just added the call to ext2fs_read_inode_full. Thanks for the pointer to the manual. – WallyZ Mar 27 '20 at 07:45
  • There's not a lot in the manual regarding ext2fs_read_inode_full – WallyZ Mar 27 '20 at 07:47
  • Correction to my previous comment I added the call to ext2fs_write_inode_full to crtime!!! – Walter ZAMBOTTI Mar 28 '20 at 02:17

1 Answers1

0

The issue turned out to be the way crtime was opening the FS with ext2fs_open.

I needed to pass the EXT2_FLAG_RW flag otherwise the open is by default read only.

WallyZ
  • 326
  • 2
  • 17