diff options
author | Theodore Ts'o <tytso@mit.edu> | 2001-06-22 21:52:14 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2001-06-22 21:52:14 -0400 |
commit | b23520d0501095dee715d0829c365933c216e612 (patch) | |
tree | ced6b01eb3022795fe00298d23e3f11afc267770 /lib/ext2fs/mkjournal.c | |
parent | 7833262585b0f9f85915c387fa35708cf3ff3609 (diff) | |
download | e2fsprogs-b23520d0501095dee715d0829c365933c216e612.tar.gz |
mkjournal.c (ext2fs_add_journal_inode): Move close of file
descriptor so that adding a journal to a mounted
filesystem doesn't die. (Fixes a bug accidentally
introduced in e2fsprogs 1.21.)
Diffstat (limited to 'lib/ext2fs/mkjournal.c')
-rw-r--r-- | lib/ext2fs/mkjournal.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index adf6ea58..8c722e68 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -321,14 +321,13 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) /* Create the journal file */ if ((fd = open(jfile, O_CREAT|O_WRONLY, 0600)) < 0) return errno; - close(fd); if ((retval = write_journal_file(fs, jfile, size, flags))) - return retval; - + goto errout; + /* Get inode number of the journal file */ if (fstat(fd, &st) < 0) - return errno; + goto errout; #if defined(HAVE_CHFLAGS) && defined(UF_NODUMP) retval = fchflags (fd, UF_NODUMP|UF_IMMUTABLE); @@ -339,8 +338,9 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) #endif #endif if (retval) - return retval; - + goto errout; + + close(fd); journal_ino = st.st_ino; } else { journal_ino = EXT2_JOURNAL_INO; @@ -357,6 +357,9 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) ext2fs_mark_super_dirty(fs); return 0; +errout: + close(fd); + return retval; } #ifdef DEBUG |