From dab278af8180bc85783da0b908e2a1af1388522d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 19 Nov 1999 18:49:27 +0000 Subject: [PATCH] ChangeLog, mkdir.c: mkdir.c (ext2fs_mkdir): Only update the parent's inode link counts if the link was successful. Patch suggested by jeremy@goop.org. --- lib/ext2fs/ChangeLog | 4 ++++ lib/ext2fs/mkdir.c | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index d669693..e282a0a 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,9 @@ 1999-11-19 + * mkdir.c (ext2fs_mkdir): Only update the parent's inode link + counts if the link was successful. Patch suggested by + jeremy@goop.org. + * Makefile.in (distclean): Remove TAGS and Makefile.in.old from the source directory. diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index 06fd903..eca9a1d 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -95,19 +95,6 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, goto cleanup; /* - * Update parent inode's counts - */ - if (parent != ino) { - retval = ext2fs_read_inode(fs, parent, &inode); - if (retval) - goto cleanup; - inode.i_links_count++; - retval = ext2fs_write_inode(fs, parent, &inode); - if (retval) - goto cleanup; - } - - /* * Link the directory into the filesystem hierarchy */ if (name) { @@ -126,6 +113,19 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, } /* + * Update parent inode's counts + */ + if (parent != ino) { + retval = ext2fs_read_inode(fs, parent, &inode); + if (retval) + goto cleanup; + inode.i_links_count++; + retval = ext2fs_write_inode(fs, parent, &inode); + if (retval) + goto cleanup; + } + + /* * Update accounting.... */ ext2fs_mark_block_bitmap(fs->block_map, blk); -- 1.8.3.1