From: Theodore Ts'o Date: Thu, 11 Dec 2003 16:54:48 +0000 (-0500) Subject: debugfs.c (do_write, do_mkdir): If the directory is full, X-Git-Tag: E2FSPROGS-1_35-WIP-0131~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d9f0804bf6265f36f50fcde80b4cb5ef89fa936;p=thirdparty%2Fe2fsprogs.git debugfs.c (do_write, do_mkdir): If the directory is full, automatically call ext2fs_expand_dir() and then retry to add the link to the directory as a convenience to the user. (Addresses Debian Bug: #217892) (do_mknod): Clean up expand_dir error handling. --- diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index 0e3a5ef38..839c04e63 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,11 @@ +2003-12-11 Theodore Ts'o + + * debugfs.c (do_write, do_mkdir): If the directory is full, + automatically call ext2fs_expand_dir() and then retry to + add the link to the directory as a convenience to the + user. (Addresses Debian Bug: #217892) + (do_mknod): Clean up expand_dir error handling. + 2003-12-07 Theodore Ts'o * debugfs.c (do_write): Mask off the file type bits, and OR in the diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 2173c13b4..f33e08eab 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -1108,6 +1108,15 @@ void do_write(int argc, char *argv[]) printf("Allocated inode: %u\n", newfile); retval = ext2fs_link(current_fs, cwd, argv[2], newfile, EXT2_FT_REG_FILE); + if (retval == EXT2_ET_DIR_NO_SPACE) { + retval = ext2fs_expand_dir(current_fs, cwd); + if (retval) { + com_err(argv[0], retval, "while expanding directory"); + return; + } + retval = ext2fs_link(current_fs, cwd, argv[2], newfile, + EXT2_FT_REG_FILE); + } if (retval) { com_err(argv[2], retval, ""); close(fd); @@ -1186,18 +1195,18 @@ void do_mknod(int argc, char *argv[]) } printf("Allocated inode: %u\n", newfile); retval = ext2fs_link(current_fs, cwd, argv[1], newfile, filetype); - if (retval) { - if (retval == EXT2_ET_DIR_NO_SPACE) { - retval = ext2fs_expand_dir(current_fs, cwd); - if (!retval) - retval = ext2fs_link(current_fs, cwd, - argv[1], newfile, - filetype); - } + if (retval == EXT2_ET_DIR_NO_SPACE) { + retval = ext2fs_expand_dir(current_fs, cwd); if (retval) { - com_err(argv[1], retval, ""); + com_err(argv[0], retval, "while expanding directory"); return; } + retval = ext2fs_link(current_fs, cwd, argv[1], newfile, + filetype); + } + if (retval) { + com_err(argv[1], retval, ""); + return; } if (ext2fs_test_inode_bitmap(current_fs->inode_map,newfile)) com_err(argv[0], 0, "Warning: inode already set"); @@ -1237,8 +1246,16 @@ void do_mkdir(int argc, char *argv[]) name = argv[1]; } - +try_again: retval = ext2fs_mkdir(current_fs, parent, 0, name); + if (retval == EXT2_ET_DIR_NO_SPACE) { + retval = ext2fs_expand_dir(current_fs, parent); + if (retval) { + com_err("argv[0]", retval, "while expanding directory"); + return; + } + goto try_again; + } if (retval) { com_err("ext2fs_mkdir", retval, ""); return;