diff options
author | Theodore Ts'o <tytso@mit.edu> | 2000-05-27 15:15:40 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2000-05-27 15:15:40 +0000 |
commit | 2e8d40d562ec93d68505800a46c5b9dcc229264e (patch) | |
tree | bf8ed86faf47684b7770eb006f8b6b22ddd1b743 /lib/ext2fs/mkdir.c | |
parent | d647a1ea4db5fa4e4ed48573c63a1bde56e071db (diff) | |
download | e2fsprogs-2e8d40d562ec93d68505800a46c5b9dcc229264e.tar.gz |
ChangeLog, debug_cmds.ct, debugfs.8.in, debugfs.c, dump.c, ls.c:
debugfs.8.in: Documented new behaviour.
ls.c (ls_l_file): Fix Y2K bug -- was printing 22-May-100 for recent
files. Switched to 4-digit years.
dump.c, debug_cmds.ct (do_rdump): Add new debugfs command "rdump",
which recursively dumps a directory and its contents.
(fix_perms): New function. Break permission-fixing code out of
dump_file() so it can be called by rdump code as well.
(dump_file): Call fix_perms().
debugfs.c, debug_cmds.ct (do_lcd): Add new debugfs command "lcd",
which changes the cwd on the native filesystem.
debugfs.c (open_filesystem): Extra args for superblock, blocksize, and
catastrophic mode. Changed callers.
(do_open_filesys, main): Accept new -b, -s, -c options for
open_filesystem.
ChangeLog, mkdir.c:
mkdir.c (ext2fs_mkdir): Read the parent directory's inode earlier, so
that if there's an error reading it, we can more cleanly back out of
the operation.
version.h:
Update version file for WIP release.
Diffstat (limited to 'lib/ext2fs/mkdir.c')
-rw-r--r-- | lib/ext2fs/mkdir.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index eca9a1d1..98c5ccf2 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -39,7 +39,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, const char *name) { errcode_t retval; - struct ext2_inode inode; + struct ext2_inode parent_inode, inode; ino_t ino = inum; ino_t scratch_ino; blk_t blk; @@ -73,6 +73,16 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, goto cleanup; /* + * Get the parent's inode, if necessary + */ + if (parent != ino) { + retval = ext2fs_read_inode(fs, parent, &parent_inode); + if (retval) + goto cleanup; + } else + memset(&parent_inode, 0, sizeof(parent_inode)); + + /* * Create the inode structure.... */ memset(&inode, 0, sizeof(struct ext2_inode)); @@ -116,11 +126,8 @@ 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); + parent_inode.i_links_count++; + retval = ext2fs_write_inode(fs, parent, &parent_inode); if (retval) goto cleanup; } |