X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=helper%2Fext2.c;h=2fc8036e00eccc850d05766496272ec34501ce0d;hb=refs%2Ftags%2F3.4;hp=9d60da9bfb5ecfec74813c2f72824cc906f39a2a;hpb=89e336ee166be538e376d288fb2b3fbbffd66d4c;p=febootstrap.git diff --git a/helper/ext2.c b/helper/ext2.c index 9d60da9..2fc8036 100644 --- a/helper/ext2.c +++ b/helper/ext2.c @@ -52,7 +52,7 @@ ext2_filsys fs; #define APPLIANCE_SIZE (1024*1024*1024) static void -ext2_start (const char *appliance, +ext2_start (const char *hostcpu, const char *appliance, const char *modpath, const char *initrd) { initialize_ext2_error_table (); @@ -135,10 +135,20 @@ ext2_mkdir (ext2_ino_t dir_ino, const char *dirname, const char *basename, if (err != 0) error (EXIT_FAILURE, 0, "ext2fs_new_inode: %s", error_message (err)); + try_again: err = ext2fs_mkdir (fs, dir_ino, ino, basename); - if (err != 0) - error (EXIT_FAILURE, 0, "ext2fs_mkdir: %s/%s: %s", - dirname, basename, error_message (err)); + if (err != 0) { + /* See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=217892 */ + if (err == EXT2_ET_DIR_NO_SPACE) { + err = ext2fs_expand_dir (fs, dir_ino); + if (err) + error (EXIT_FAILURE, 0, "ext2fs_expand_dir: %s/%s: %s", + dirname, basename, error_message (err)); + goto try_again; + } else + error (EXIT_FAILURE, 0, "ext2fs_mkdir: %s/%s: %s", + dirname, basename, error_message (err)); + } /* Copy the final permissions, UID etc. to the inode. */ struct ext2_inode inode; @@ -304,9 +314,19 @@ ext2_clean_path (ext2_ino_t dir_ino, if (err != 0) error (EXIT_FAILURE, 0, "ext2fs_write_inode: %s", error_message (err)); - if (ext2fs_inode_has_valid_blocks (&inode)) - ext2fs_block_iterate (fs, ino, BLOCK_FLAG_READ_ONLY, NULL, + if (ext2fs_inode_has_valid_blocks (&inode)) { + int flags = 0; + /* From the docs: "BLOCK_FLAG_READ_ONLY is a promise by the + * caller that it will not modify returned block number." + * RHEL 5 does not have this flag, so just omit it if it is + * not defined. + */ +#ifdef BLOCK_FLAG_READ_ONLY + flags |= BLOCK_FLAG_READ_ONLY; +#endif + ext2fs_block_iterate (fs, ino, flags, NULL, release_block, NULL); + } ext2fs_inode_alloc_stats2 (fs, ino, -1, isdir); }