Whamcloud - gitweb
debugfs.c (do_write, do_mkdir): If the directory is full,
authorTheodore Ts'o <tytso@mit.edu>
Thu, 11 Dec 2003 16:54:48 +0000 (11:54 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Dec 2003 16:54:48 +0000 (11:54 -0500)
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.

debugfs/ChangeLog
debugfs/debugfs.c

index 0e3a5ef..839c04e 100644 (file)
@@ -1,3 +1,11 @@
+2003-12-11  Theodore Ts'o  <tytso@thunk.org>
+
+       * 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  <tytso@mit.edu>
 
        * debugfs.c (do_write): Mask off the file type bits, and OR in the
index 2173c13..f33e08e 100644 (file)
@@ -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;