]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
ext2fs: update allocation info earlier in ext2fs_mkdir() and ext2fs_symlink()
authorJan Kara <jack@suse.cz>
Thu, 13 Feb 2020 10:15:58 +0000 (11:15 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 15 Mar 2020 16:14:48 +0000 (12:14 -0400)
commita25a84c6aa2a19987b0aeced363c4bf1dcc89ec8
tree2af2aa79095abb6de09d76a1fff17fcda7475ff8
parent9e6ec24e709d9a0ad5d2f11b5ec5ed232b87b16e
ext2fs: update allocation info earlier in ext2fs_mkdir() and ext2fs_symlink()

Currently, ext2fs_mkdir() and ext2fs_symlink() update allocation bitmaps
and other information only close to the end of the function, in
particular after calling to ext2fs_link(). When ext2fs_link() will
support indexed directories, it will also need to allocate blocks and
that would cause filesystem corruption in case allocation info isn't
properly updated. So make sure ext2fs_mkdir() and ext2fs_symlink()
update allocation info before calling into ext2fs_link().

[ Added error handling so the calls to ext2fs_{block,inode}_alloc_stats()
  can be undone if the newly created directory or symlink can not be linked
  into the directory. -- TYT ]

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/mkdir.c
lib/ext2fs/symlink.c